The Farm Data Relay System is an easy way to collect data from remote sensors without relying on WiFi. It is based around the ESP-NOW protocol, which is readily available on ESP32 and ESP8266 microcontroller boards. The system can be used to collect and transmit sensor data in situations where it would be too difficult or energy-consuming to provide full WiFi coverage.
Using an assigned MAC address scheme allows for the whole system to be configured by setting just a handful of values in code. Every wireless gateway is assigned a single-byte identifier, known as the UNIT_MAC. This, along with a set, 5-byte prefix is assigned to the MAC address of the ESP's radio at boot.
Gateways can be configured to send an ESP-NOW transmission to the serial port using JSON, another ESP-NOW gateway, or broadcast it via LoRa PHY. They can also be configured to transmit incoming serial packets over MQTT, ESP-NOW, or LoRa PHY.
To use FDRS with Node-Red and MQTT you'll need two ESP devices (gateways) that are connected via UART, plus additional ESP or LoRa devices with sensors connected.
The [Sensor2000](https://github.com/timmbogner/Farm-Data-Relay-System/tree/main/FDRS_Sensor2000) sketch is an example of how a sensor is configured in FDRS. The configuration parameters and functional code are located in the 'fdrs_sensor.h' file, so the user is free to use the main sketch for individual sensor code.
Gateways are programmed using the instructions [found with the Gateway2000 sketch](https://github.com/timmbogner/Farm-Data-Relay-System/tree/main/FDRS_Gateway2000).
### Front-end
The Node-RED front-end can be set up with these nodes to format and send the data to InfluxDB:
The following nodes do the same as above, but I added the ability to add an alias to each sensor ID via the dashboard using globals. It could use improvement, but might be helpful to some:
Each sensor in the system sends its data over ESP-NOW as a float 'd' inside of a structure called a DataReading. Its global sensor address is represented by an integer 'id', and each type is represented by a single byte 't'. If a sensor module needs to send multiple types of readings, then they are sent in an array of DataReadings. A single DataReading.id may have readings of multiple types associated with it.
- A way for the sensors to seek out a nearby gateway and pair with it.
- The ability to send data in reverse, and have nodes to control irrigation, ventilation, and LED illumination. This will be acheived using a similar pairing technique to the above.
- More sensor sketches! If you have designed any open source sensor modules for ESP32 or 8266, please contact me and I will provide a link and/or code for your device in this repo.
- Some ability to compress data for more efficient LoRa usage and to avoid using floats. Better documentation/development of the DataReading 'type' attribute will come with this.
...very much for checking out my project! I truly appreciate everyone across the net who has reached out with assistance and encouragement. If you have any questions, comments, or issues please feel free to contact me at timmbogner@gmail.com.
If you have any extra money, please consider [supporting me](https://www.buymeacoffee.com/TimmB). I'm a farmer by occupation, and donations would help me to spend more time developing farm gadgets.
Development of this project would not have been possible without the gracious support of my former employer, **Sola Gratia Farm** of **Urbana, IL, USA**. Sola Gratia is a community-based farm dedicated to growing high-quality produce and sharing it with those in need. Thank you!