Sensor System
This repository contains code used on the ESP32 devices within the forest.
Project Structure
The project is structured as follows:
-
client
: Contains library code and source files for ESP32 client devices (i.e. sensors)-
lib
: Contains library code for the ESP32 client devices that is shared among all client devices. For a list of libraries, see thelib
directory.-
lib/includes
: Contains header files used by both library and client code.
-
-
client_central_mast
: Contains source files for the central mast client device. -
client_satellite
: Contains source files for the satellite client device (used by dendrometers). -
ESPCamera
: Contains source files for the ESP32 camera client device (camera and SHT85).
-
-
host/host_central_mast
: Contains source code for the ESP32 host device (LTE capabilities) -
code_snippets
: Contains code snippets that may be useful for future development. These are not intended to be compiled and run as-is. -
hardware
: Contains hardware design files.
Dependencies
All of the software in this repository requires PlatformIO to compile. We also use PlatformIO for dependency management and flashing of our ESP32 devices. You can install it on all major operating systems via https://docs.platformio.org/en/latest/integration/ide/pioide.html or https://platformio.org/.
To build, run, and flash each project, change directory to the individual project and run pio run
on the command line.
When using PlatformIO in Visual Studio Code, this can also be done via a graphical user interface.
We also provide a dockerfile that will compile all relevant projects and store the files within the container under /app/buildfiles
.
You can build the docker image using docker build -t forte:1.0 .
and then running docker run -it --rm forte:1.0
.
You can follow https://stackoverflow.com/a/22050116/10266066 to retrieve the data from the container.
Client Dependencies
wollewald/ADS1115_WE@^1.3.1
- MIT License
- URL: https://github.com/wollewald/ADS1115_WE
- We use this library to interface with the ADS1115 ADC. It allows us to readAnalog sensors such as the DR26 dendrometer or the TEROS10 soil moisture sensor through an I2 C connection. We chose this library over the official one provided by Adafruit as it was more power efficient.
wollewald/INA219_WE@^1.3.1
- MIT License
- URL: https://github.com/wollewald/INA219_WE
- This library provides an implementation to interface with the INA219 current and voltage sensor via I2C.
adafruit/Adafruit LC709203F@^1.3.2
- BSD License
- URL: https://github.com/adafruit/Adafruit_LC709203F
- We use this library to interface with the LC709203F LiPoly / LiIon Fuel Gauge and Battery Monitor via I2C.
fbiego/ESP32Time@^2.0.0
- MIT License
- URL: https://github.com/fbiego/ESP32Time
- We use ESP32Time to set and retrieve the time of the internal RTC of an ESP32.
bblanchon/ArduinoJson@^6.19.4
- MIT License
- URL: https://github.com/bblanchon/ArduinoJson
- During early development of the system, we used this library to serialize sensor data to JSON objects for transmission to the host.
sensirion/arduino-sht@^1.2.2
- BSD 3-Clause "New" or "Revised" License
- URL: https://github.com/Sensirion/arduino-sht
- This library enables us to interface with the SHT line of humidity and temperature sensors (i.e., SHT85) via I2C.
envirodiy/SDI-12@^2.1.4
- BSD 3-Clause "New" or "Revised" License
- URL: https://github.com/EnviroDIY/Arduino-SDI-12
- This library implements all necessary functions to easily interface with sensors using the SDI-12 communication protocol. In our case, the library is used to communicate with the TEROS11 soil moisture and temperature sensors.
emelianov/modbus-esp8266@^4.1.0
- BSD New License
- URL: https://github.com/emelianov/modbus-esp8266
- This library implements all functions to interface with sensors using the Modbus communication protocol. We use the library to retrieve sensor data from the SEM228A solar radiation sensor and the SEM404 precipitation sensor through RS485.
Host Dependencies
vshymanskyy/TinyGSM@^0.11.5
- GNU Lesser General Public License v3.0
- URL: https://github.com/vshymanskyy/TinyGSM
- We use this library to interface with the LTE-M Modem of the Host and establish a connection to the mobile network. This library proofed to be essential for implementing the LTE-Connection manager, as it provides a multitude of convenience functions, code examples, and existing documentation.
vshymanskyy/StreamDebugger@^01.0.1
- MIT License
- URL: https://github.com/vshymanskyy/StreamDebugger
- Used by TinyGSM to allow for debug output of the LTE-M modem.
arduino-libraries/ArduinoHttpClient@^0.4.0
- Apache License, version 2.0
- URL: https://github.com/arduino-libraries/ArduinoHttpClient
- This library provides simple functions that allow CRUD requests to a URL. We use it to transmit data within the global deque or from the ResendManager to the Backend via HTTP POST requests. Further, we use HTTP GET requests within the TimeManager to retrieve the current UTC time from the Backend.
adafruit/RTClib@^2.1.1
- MIT License
- URL: https://github.com/adafruit/RTClib
- We use this library to interface with the DS3231 precision RTC, which we use instead of the ESP32 internal RTC. As soon as we receive the current UTC time from the server, we update the DS3231 through this library. Further, we retrieve the UTC time from the RTC using this library when sending HostPackage DTOs to Clients.
fbiego/ESP32Time@^2.0.0
- MIT License
- URL: https://github.com/fbiego/ESP32Time
- This library can be used to set and retrieve the time of the internal RTC of an ESP32. While it is currently unused, it could be used as a fallback for the DS3231 RTC in the future.
bblanchon/ArduinoJson@^6.19.4
- MIT License
- URL: https://github.com/bblanchon/ArduinoJson
- We use this library to serialize the JSON object containing sensor data that is sent to the Backend. In early stages of the system, we also used it to deserialize incoming JSON messages from Clients.