# Using Perimeter Detect: Zymkey 4

**URL:** <https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204>\
**Category:** Perimeter Detect\
**Created:** [July 29, 2017, 10:57pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204 "2017-07-29T22:57:32Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [July 29, 2017, 10:57pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/1 "2017-07-29T22:57:32Z")

</div>

See [Zymbit’s Documentation Site](https://docs.zymbit.com/tutorials/perimeter-detect/zymkey4/) for the most recent Perimeter Detect documentation.

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [July 29, 2017, 10:58pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/2 "2017-07-29T22:58:35Z")

</div>



---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [July 30, 2017, 12:50am UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/3 "2017-07-30T00:50:38Z")

</div>



---

<div class="post-metadata">

**Author:** ![Tgratier](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tgratier](https://community.zymbit.com/u/Tgratier)\
**Post date:** [September 7, 2017, 12:44pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/4 "2017-09-07T12:44:25Z")

</div>

Hi

I am very interested by the zymkey 4i product, especially by the physical tamper protection.

But I have few question:

I readed in the RTC tutorial that the coin cell only serves for the RTC, does it mean than the perimeter detection is only working when the zymkey is powered on thanks to my raspberry? In this case, how to protect from an attacker who would destroy the “enclosure” of my system while it is powered off, and also the perimeter two perimeters loop circuits? I mean, in “therory”, I guess it could easily identify the zimkey, and juste put two illegitimate loops circuit in the receptacle, to fake the zimkey before to put the system on again. Am I wrong? or maybe I am missing something?

In this case, does it mean the perimeter features is “nothing” without a strong “physical” protection like expoxy on the SD and the zymkey? So why to not use the coin cell to make the perimeter protection always activated?

By the way, is it possible to extend the RTC battery life, for example if I put many CR2032 coins in parallel?

And to finish, do you know when you could be able to release application examples and dev kits for the perimeter detection?

Thanks by advance!

By the way, your product looks really cool, good job!

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [September 7, 2017, 4:43pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/5 "2017-09-07T16:43:20Z")

</div>

Hi Tgratier,

1. Perimeter detect does already work with battery backup, Otherwise, as you point out, its pretty useless. The Pi, Zymkey and Battery should be enclosed in one or both of the perimeter loops.

2. Zymkey 4i is designed to accept CR1025 coin cells, with nomimal lifetime of 1.5 years (host not powered), 3-5 years (host powered 75% of time). There is no mechanical provision for larger coin cells, but electrically if you wanted to hot wire a larger battery of the same voltage, that should work, with some caveats. We do have some OEM products in the works that will allow the user to apply an ‘external battery’. Contact Zymbit to discuss the specifics of your application in more detail.

3. We will release some application notes for perimeter detect in a couple of weeks. (Sept 21).

Thanks for your interest.

---

<div class="post-metadata">

**Author:** ![Tgratier](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tgratier](https://community.zymbit.com/u/Tgratier)\
**Post date:** [September 7, 2017, 4:54pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/6 "2017-09-07T16:54:46Z")

</div>

Ok thanks for the quick answer! I am glad to see I was misunderstood haha.  
And sorry for my mistake about the coin model.

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [September 7, 2017, 4:59pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/7 "2017-09-07T16:59:18Z")

</div>

No apologies required. We are hear to help !

---

<div class="post-metadata">

**Author:** ![Tgratier](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tgratier](https://community.zymbit.com/u/Tgratier)\
**Post date:** [September 28, 2017, 10:03pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/8 "2017-09-28T22:03:59Z")

</div>

Hi,  
do you have any news about some applications notes release for perimeter detect?  
Thanks by advance 🙂

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [October 12, 2017, 12:38am UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/10 "2017-10-12T00:38:03Z")

</div>

Hi

Putting together a general use case app note always takes longer than a specific use case, so sorry for the delay. We should having something up next week.

If you have a specific use case and need answers now then please [contact us here](https://zymbit.com/contact-form/)

---

<div class="post-metadata">

**Author:** ![Tgratier](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tgratier](https://community.zymbit.com/u/Tgratier)\
**Post date:** [October 12, 2017, 5:11pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/11 "2017-10-12T17:11:48Z")

</div>

Ok cool, I will wait!  
Thx 🙂

---

<div class="post-metadata">

**Author:** ![Iker](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@Iker](https://community.zymbit.com/u/Iker)\
**Post date:** [October 18, 2017, 9:35am UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/12 "2017-10-18T09:35:32Z")

</div>

From the initial specs I read “Optional accelerometer detects shock and orientation change events”. How can I use acceleromoter? Is this one of the two perimeters loops? What means optional? I am interested in ZYMKEY 4i.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [October 18, 2017, 6:40pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/13 "2017-10-18T18:40:29Z")

</div>

If you bought the Zymkey 4i, the accellerometer comes as standard.

You will find details of how to use the accellerometer in the documentation, here: [API Documentation](https://community.zymbit.com/t/api-documentation/189)

![zymkey 4i 3i feature matrix 1707](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex027/uploads/zymbit/original/1X/0a9eea9c92fcfc6172de26aabc1072feecbfdf08.png)

---

<div class="post-metadata">

**Author:** ![Iker](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@Iker](https://community.zymbit.com/u/Iker)\
**Post date:** [October 19, 2017, 9:16am UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/14 "2017-10-19T09:16:54Z")

</div>

Thanks, I understand acceleremeter is device integrated and doesn’t use(occupies) any of the two perimeter loop circuits  
.  
From introduction I also read “Power rail monitor detects anomolies like brown-out events”. I can not find any reference in the API documentation, can you tell me where to read about? Is this the mechanism used by perimeter loop system or something I can check from the API?

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [October 19, 2017, 3:24pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/15 "2017-10-19T15:24:14Z")

</div>

Your Zymkey contains three different layers of Tamper Detection. Each operates independent of the other:

1. Accellerometer - accessible through API
2. Perimeter detection loops x 2 - accessible through API
3. Power rail monitor - for internal defense only. NOT accessible through the API

---

<div class="post-metadata">

**Author:** ![Iker](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@Iker](https://community.zymbit.com/u/Iker)\
**Post date:** [October 24, 2017, 11:51am UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/16 "2017-10-24T11:51:07Z")

</div>

While waiting for the sample app, if USB is open (nothing connected) and run a script with these commands, should event happen?:  
zymkey.client.clear\_perimeter\_detect\_info()  
zymkey.client.wait\_for\_perimeter\_event ()

---

<div class="post-metadata">

**Author:** ![Iker](https://avatars.discourse-cdn.com/v4/letter/i/a6a055/32.png) [@Iker](https://community.zymbit.com/u/Iker)\
**Post date:** [October 25, 2017, 2:50pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/17 "2017-10-25T14:50:34Z")

</div>

I forgot to configure notification:  
zymkey.client.set\_perimeter\_event\_actions ( channel = 1, **action\_notify = _True_** , action\_self\_destruct = False )

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [October 25, 2017, 6:05pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/18 "2017-10-25T18:05:12Z")

</div>

Happy to hear you found the solution.

---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [October 25, 2017, 6:05pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/19 "2017-10-25T18:05:19Z")

</div>



---

<div class="post-metadata">

**Author:** ![Phil\_S\_Zymbit\_1](https://avatars.discourse-cdn.com/v4/letter/p/45deac/32.png) [@Phil\_S\_Zymbit\_1](https://community.zymbit.com/u/Phil_S_Zymbit_1)\
**Post date:** [December 28, 2017, 11:00pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/20 "2017-12-28T23:00:13Z")

</div>



---

<div class="post-metadata">

**Author:** ![Tgratier](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@Tgratier](https://community.zymbit.com/u/Tgratier)\
**Post date:** [January 14, 2018, 4:26pm UTC](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204/21 "2018-01-14T16:26:54Z")

</div>

Hi

it’s me again, for few questions.

I am trying to execute a periodic check of the PERIM1 circuit.  
The code below works well during first rounds, but suddenly the breach action is not anymore detected.  
After few minutes, it start to work well again, etc. If I reboot the pi, the code will works directly (during few rounds again).

I simply connect a USB cable with white and black wires connected, and make them touch themselves during the tests. I can’t see anything wrong in /var/log/syslog.

Is this my routine code which is not the best way to check the perimeter loop? Why is my zymkey just “stop to work” during few minutes? Should I use “zkWaitForPerimeterEvent(ctx, 0);” ?

By the way, in the code below the “num\_timestamps” value is ALWAYS equal to “2”. Why 2 whereas I only set an action for the PERIM1 circuit and not PERIM2?

Thx by advance.

```
int num_timestamps = 0;
uint32_t *tab_event;
zkCTX ctx;

if(zkOpen(&ctx) <0)
{
	printf("Unable to setup RTC module\n");
	return 0;
}
zkSetPerimeterEventAction(ctx, 0, ZK_PERIMETER_EVENT_ACTION_NOTIFY);

while(1)
{
	/*
	 *	do_something
	 */ 

	zkGetPerimeterDetectInfo(ctx, &tab_event, &num_timestamps);
	if(num_timestamps > 0)
	{
		printf("num timestamp = %d\n", num_timestamps);
		printf("Last event = %ld\n", tab_event[0]);
		zkLEDFlash(ctx, 500, 500, 4);
		zkClearPerimeterDetectEvents(ctx);
		num_timestamps = 0;
	}

	delay(1000);
}
```

[Next page](https://community.zymbit.com/t/using-perimeter-detect-zymkey-4/204.md?page=2)
