Farm-Data-Relay-System/README.md

52 lines
6.1 KiB
Markdown
Raw Normal View History

2022-02-07 03:55:04 +00:00
# <p align="center">Farm Data Relay System
##### <p align="center">[***In loving memory of Gay Holman, an extraordinary woman.***](https://www.facebook.com/CFECI/posts/2967989419953119) #####
2020-12-18 13:56:29 +00:00
2022-04-08 23:22:16 +00:00
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.
2021-10-09 02:05:53 +00:00
2022-06-10 01:15:24 +00:00
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 at boot.
2020-12-18 13:56:29 +00:00
2021-11-26 18:22:49 +00:00
## Getting Started
2022-03-08 18:36:20 +00:00
2022-06-10 01:15:24 +00:00
### [Sensors](https://github.com/timmbogner/Farm-Data-Relay-System/tree/main/FDRS_Sensor2000)
Sensors gather data and send it to a gateway via ESP-NOW or LoRa.
2022-03-08 18:28:18 +00:00
2022-06-10 01:15:24 +00:00
### [Gateways](https://github.com/timmbogner/Farm-Data-Relay-System/tree/main/FDRS_Gateway2000)
2022-06-13 04:57:12 +00:00
Gateways listen for packets over ESP-NOW, LoRa, UART, and/or MQTT, then retransmit the packets using one or more of the same interfaces.
2022-06-13 04:56:33 +00:00
2022-05-21 12:33:08 +00:00
### Front-end
The Node-RED front-end can be set up with these nodes to format and send the data to InfluxDB:
2022-03-08 18:28:18 +00:00
```
[{"id":"66d36c0f.cedf94","type":"influxdb out","z":"d7346a99.716ef8","influxdb":"905dd357.34717","name":"","measurement":"DataReading","precision":"","retentionPolicy":"","database":"database","precisionV18FluxV20":"ms","retentionPolicyV18Flux":"","org":"the_organization","bucket":"bkt","x":760,"y":240,"wires":[]},{"id":"93e9822a.3ad59","type":"mqtt in","z":"d7346a99.716ef8","name":"","topic":"esp/fdrs","qos":"2","datatype":"auto","broker":"c513f7e9.760658","nl":false,"rap":true,"rh":0,"x":170,"y":220,"wires":[["d377f9e0.faef98"]]},{"id":"d377f9e0.faef98","type":"json","z":"d7346a99.716ef8","name":"","property":"payload","action":"obj","pretty":false,"x":290,"y":220,"wires":[["ca383562.4014e8"]]},{"id":"ca383562.4014e8","type":"split","z":"d7346a99.716ef8","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":410,"y":220,"wires":[["6eaba8dd.429e38"]]},{"id":"6eaba8dd.429e38","type":"function","z":"d7346a99.716ef8","name":"Fields","func":"msg.payload = [{\n data: msg.payload.data\n},{\n id: msg.payload.id,\n type: msg.payload.type\n}]\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":220,"wires":[["296d0f4b.37a46","66d36c0f.cedf94"]]},{"id":"296d0f4b.37a46","type":"debug","z":"d7346a99.716ef8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":200,"wires":[]},{"id":"905dd357.34717","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"database","name":"","usetls":false,"tls":"d50d0c9f.31e858","influxdbVersion":"2.0","url":"http://localhost:8086","rejectUnauthorized":true},{"id":"c513f7e9.760658","type":"mqtt-broker","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"d50d0c9f.31e858","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false}]
```
2022-03-28 01:18:58 +00:00
2022-02-07 18:04:14 +00:00
![Basic](/FDRS_Gateway2000/Basic_Setup.png)
2022-04-17 01:58:24 +00:00
![Advanced](/FDRS_Gateway2000/Advanced_Setup.png)
2022-02-07 03:53:29 +00:00
### Sensors
2021-10-09 02:40:53 +00:00
```
typedef struct DataReading {
float d;
uint16_t id;
uint8_t t;
} DataReading;
```
2022-02-16 12:49:33 +00:00
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.
2022-04-20 13:42:06 +00:00
## Future Plans
A few things that I intend to add are:
- 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.
2022-04-29 02:07:36 +00:00
- I am going to look into adding an option to change the channel that the system runs on, so that WiFi and ESP-NOW might run together harmoniously.
2022-04-20 13:42:06 +00:00
- Support for several new devices and protocols: ethernet, nRF24L01, 4G LTE, and the E5 LoRa module from Seeed Studio.
2022-04-20 16:19:30 +00:00
- 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.
2022-04-20 13:42:06 +00:00
2021-10-09 02:05:53 +00:00
## Thank you
2022-02-21 13:36:15 +00:00
...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.
2021-11-26 23:14:45 +00:00
2022-05-25 11:05:04 +00:00
If you have any extra money, **please consider [supporting me](https://www.buymeacoffee.com/TimmB).** I'm a farmer, landscaper, and grocery store clerk by occupation, so donations would help me to spend more time developing farm gadgets.
2021-11-26 23:10:42 +00:00
2022-05-21 12:17:40 +00:00
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!
2022-02-07 19:50:40 +00:00
2022-02-07 03:57:05 +00:00
A huge thanks to the ever-instructional [**Andreas Spiess**](https://www.youtube.com/channel/UCu7_D0o48KbfhpEohoP7YSQ).
2022-02-07 03:53:29 +00:00
2022-02-07 03:57:05 +00:00
[**Random Nerd Tutorials**](https://randomnerdtutorials.com/) is also an indispensable source of ESP knowledge.