> For the complete documentation index, see [llms.txt](https://projectwerk.gitbook.io/project/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://projectwerk.gitbook.io/project/assignment/measurements.md).

# Battery life

In this page we will discuss the currency of every component and calculate the lifetime of the PCB board (with 3 AAA batteries). The lifetime should at least be 1 year.

## Datasheets

You can find al the values that you need for calculating the lifetime of the PCB in the datasheets that are given below.

* PIR sensor (Panasonic AMN31111)&#x20;
  * <https://www.panasonic-electric-works.com/cps/rde/xbcr/pew_eu_en/ca_pir_motionsensors_en.pdf>
* Humidity & temperature sensor (Si7012-A20)&#x20;
  * <https://www.silabs.com/documents/public/data-sheets/Si7020-A20.pdf>
* Processor (STM32L476)&#x20;
  * <https://www.digchip.com/datasheets/parts/datasheet/456/STM32L476-pdf.php>
* LoRaWAN&#x20;
  * <http://www.hoperf.com/upload/rf/RFM95_96_97_98W.pdf>

## Measured values

### PIR sensor

![Image 1 - Current PIR](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXMMCbpGP8PURtuZok%2F-LDXQdc7wvsux5TkQF5b%2FPIR_current.bmp?alt=media\&token=42b18619-3bfe-47b5-a52c-2c00a5718944)

The average current that we measured of the PIR is about 128 µA. In the datasheets you can read that the average current should be around 170 µA. Why? The environment condition could be different.

![Image 2 - Startup PIR](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXZ23Ckc4Hd7siCUMg%2F-LDXZnSTpa5cT6UEa2LK%2FPIR_data_startup.PNG?alt=media\&token=c4ce3eae-1e66-42f5-9b66-e3015de45362)

When you apply the power to the sensor it will take about 4.140 seconds to startup. This pattern was always the same in my environment (no movement)\
Afterwards the out will be zero if there is no movement. Otherwise you'll see pulses by every movement. Some pulses are longer than others. Because the sensor sees more movement or the object comes closer to the sensor.

### Humidity & temperature sensor

![Image 2 - Humidity & temperature](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXMMCbpGP8PURtuZok%2F-LDXT8ImWzfhe8UWpplv%2FTemp_current.jpg?alt=media\&token=3b048281-0505-4e5d-8c30-67202633d293)

### Processor

#### Active mode

![Image 3 - Processor active mode](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXTW8cYo1FO6H1WVJj%2F-LDXUvPI_NjCUJQZIg08%2Factivemode_current_processor.jpg?alt=media\&token=f2e0453d-2264-4f25-a0a9-f61254691b44)

#### Sleep mode

![Image 4 - Processor sleep mode](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXTW8cYo1FO6H1WVJj%2F-LDXVJex3xwhtSSoSxDv%2Fsleepmode_current_processor.jpg?alt=media\&token=06866646-36b8-4dad-a21a-175a5b73b528)

The following code is an example to move the processor into a sleep mode. And this is equal to stop mode 2 as specified in the datasheets.

> Stop 2  mode : 1.4 µA w/RTC
>
> RTC = Real Time Clock

{% code title="Sleepmode" %}

```cpp
#include "mbed.h"
void main(void) {
    sleep();
    while(true) {
    }
}
```

{% endcode %}

{% hint style="info" %}
Make sure to implement the mbed.h file.
{% endhint %}

### LoRaWAN

![Image 5 - LoRaWAN](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDXZ23Ckc4Hd7siCUMg%2F-LDXZJ7TRJY9LX9I-xEj%2FLorawan_current.jpg?alt=media\&token=3b1ce464-b1d9-4b4e-8db7-6b117b04a346)

We send a package with random data every 10 seconds. There can be an issue to send the packages, as you can see.

## Computation

Requirements:

* Measure for 2.5 seconds
* Transmit via LoRaWAN for 500 µs

A sample how we calculate the battery life.

First of all calculate the currencies that you need.

![Calculation - I](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDmHKD656z7z-xaDVYZ%2F-LDmM39sQr78gBO1UBSF%2FdeelI.PNG?alt=media\&token=d4945650-6f04-434a-b30a-93f7a876dfb9)

After that implement the time.

![Calculation - II](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDmHKD656z7z-xaDVYZ%2F-LDmMHEsriM-wOpC6Ydt%2FdeelII.PNG?alt=media\&token=cdacf756-443d-4053-8523-fc96c314fbfd)

At least calculate the lifetime.

![Calculation -- III](https://2007275357-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LDLySMRFlYdWwoVZLq7%2F-LDmHKD656z7z-xaDVYZ%2F-LDmMY5S4JvurffvO3M7%2FdeelIII.PNG?alt=media\&token=df54147f-cd9e-4519-946a-36240464d27a)

## Conclusion

With the requirements from above I calculated a battery life of 3.99 years theoretical and practical 1.29 years.

The values of the PIR, LoRaWAN and the processor were not exactly the same as in de datasheets.
