esp32-sensornode/README.md

94 lines
3.6 KiB
Markdown
Raw Normal View History

2020-03-25 12:49:32 +00:00
# ESP32-based Environmental Sensor
2020-04-08 17:00:59 +00:00
Author: Jannik Beyerstedt
**license:** GNU GPL v3
2020-03-25 12:49:32 +00:00
A simple temperature and humidity sensor node using an ESP32 and a Si7021 sensor element running of a 18650 LiIon battery cell.
The sensor outputs the data to an influxDB instance, which must be reachable via HTTP.
To save energy, we use a lower CPU frequency.
But this requires compiling the core framework again with the changed settings (see below).
This repository contains the code running on the ESP32, as well as the PCB and case design.
## Dependencies
2020-05-23 20:44:19 +00:00
The [esp32-idf](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#installation-step-by-step) is needed to compile software for the ESP32.
The following sections will install to `~/Development/esp32` as an example.
Prepare toolchain (macOS):
```
2020-05-23 20:44:19 +00:00
cd ~/Development/
mkdir ./esp32
cd esp32
curl https://dl.espressif.com/dl/xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz -o xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz
tar -xzf xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz
rm xtensa-esp32-elf-osx-1.22.0-80-g6c4433a-5.2.0.tar.gz
```
2021-04-05 18:53:35 +00:00
Prepare toolchain (Debian, Ubuntu):
2018-08-01 12:27:10 +00:00
```
sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial
cd ~/Development/
mkdir ./esp32
cd esp32
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-73-ge28a011-5.2.0.tar.gz
tar -xzf xtensa-esp32-elf-linux64-1.22.0-73-ge28a011-5.2.0.tar.gz
rm xtensa-esp32-elf-linux64-1.22.0-73-ge28a011-5.2.0.tar.gz
```
Add to your bash profile, zshrc or other:
```
2018-08-01 12:27:10 +00:00
export PATH=$PATH:$HOME/Development/esp32/xtensa-esp32-elf/bin
export IDF_PATH = $HOME/Development/esp32/esp-idf
```
2018-08-01 12:27:10 +00:00
Install esp-idf:
```
2020-05-23 20:44:19 +00:00
cd ~/Development/esp32
git clone --recursive https://github.com/espressif/esp-idf.git
```
2020-03-25 12:49:32 +00:00
## Checkout this project and configure arduino-esp32 with esp-idf:
```
2020-05-23 20:44:19 +00:00
mkdir -p components && cd components
git clone https://github.com/espressif/arduino-esp32.git arduino && cd arduino
git submodule update --init --recursive
cd ../..
```
Configure `make menuconfig`:
* under "Arduino Configuration":
* "Autostart Arduino setup and loop on boot": off
* "Disable mutex locks for HAL": off
* under "Serial flasher config":
* change flash size to 4 MB
* optionally set your serial port
* under "Component config" -> "ESP32-secific":
* set CPU frequency to 80 MHz
Make and flash:
```
make all
make flash
```
You would probably have to adapt the `UPLOAD_PORT` in the `Makefile` or set it via an environment variable.
2020-03-25 12:49:32 +00:00
## Battery Life
The hardware was designed with two options to drop the battery voltage to a level, which can be fed to the ESP32: A voltage regulator or a simple diode.
2021-04-05 18:53:35 +00:00
A test with increased data rate (for a shorter test duration) resulted in a slightly better battery life using the voltage regulator.
2020-03-25 12:49:32 +00:00
Using a measurement interval of 30 seconds and a WiFi connection interval of 3 minutes, the 2500mAh LiIon (3.7V) battery lasted 30 days with the diode and 36 days using the voltage regulator.
2021-04-05 18:53:35 +00:00
In real-world application, a battery life of about 9 months can be expected (with good WLAN reception).
2020-03-25 12:49:32 +00:00
The selected voltage regulator has a quite low drop-out voltage and more importantly a low leaking current during the deep-sleep phases, which have a very low current needed by the ESP32.
In comparison a diode has no leaking current at all, but a more or less fixed voltage drop.
The benefit of the voltage regulator is, that the battery voltage range can be exploited further than what can be done with the diode.
The lowest operational battery level was 3.2 V using the diode and 2.8 V using the voltage regulator.