Skip to content

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.

License

Notifications You must be signed in to change notification settings

lamasseriadipolverara/Farm-Data-Relay-System

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Farm Data Relay System

Farm Data Relay System is an easy way to communicate with remote IoT devices without relying on WiFi or LoRaWAN infrastructure. It establishes a series of inexpensive, low-power access points and repeaters to provide ESP-NOW and LoRa coverage for remote devices. FDRS can be used to transport sensor readings and control messages in situations where it would be too cumbersome to provide full WiFi/LoRaWAN coverage. While the system was designed with farming in mind, FDRS could also be beneficial in a classroom, home, or research setting.

Devices are classified into two types: Gateways and Nodes. Gateways comprise the infrastructure of the network, moving data along pre-directed routes and providing coverage to all devices. Nodes allow the user to exchange data with a gateway. Each gateway is identified with an 8-bit physical hex address (MAC), while nodes use 16-bit integers to identify datapoints as they move through the system.

If you are having fun with FDRS, please consider supporting me so that I can spend more time building it.

Getting Started

Libraries Required:

Included:

To install FDRS:

  1. Download or clone this repository and copy it into your Arduino 'libraries' folder.

  2. After installing, edit the 'src/fdrs_globals.h' file with your WiFi credentials and other global parameters.

  3. The first sketch you'll want to try is the 1_UART_Gateway.ino example. This device will listen for incoming ESP-NOW packets, then route them to the serial port (and vice versa). Next, flash the ESPNOW_Sensor.ino example to see how to send data to the gateway.

  4. To use MQTT: Connect the second gateway to the first via the Rx and Tx pins (crossed), and flash it with the 0_MQTT_Gateway.ino example. If your WiFi and MQTT configurations are correct, data will be published to the topic 'fdrs/data'.

  5. To extend your range, try the 2_ESPNOW_Repeater.ino or 3_LoRa_Repeater.ino. Just change the GTWY_MAC of your sensor to the address of your new repeater.

Nodes

Node Documentation

Nodes can be described as sensors, controllers, or both:

  • A Sensor node aggregates data into a packet, then sends it to a gateway via ESP-NOW or LoRa.
  • A Controller node subscribes to one or more reading IDs. When data arrives from an ID the device is subscribed to, a callback function is called where the user can access the incoming data.

Gateways

Gateway Documentation

Gateways are modular and configurable microcontroller devices that can perform a variety of useful functions including collecting, distributing, and relaying wireless data. They provide a flexible and cohesive interface between various wired and wireless protocols, and are generally arranged in a line or star topology. As a general rule, the gateway that uses MQTT always has the address 0x00, and ESP-NOW and LoRa gateways start at 0x01.

In its most common usage, an FDRS gateway is deployed as an access point for remote ESP-NOW and LoRa user nodes. If it receives a packet from an unknown ESP-NOW or LoRa address, the gateway assumes that these are sensor readings and passes them downstream towards the front-end. The gateway will also broadcast packets coming from the front-end out to any controller nodes that are registered/listening.

Gateways can also be configured as simple repeaters; passing data from one neighbor directly to another neighbor or vice versa. This can create a data wormhole that will carry packets upstream or downstream ad infinitum. You can configure your gateways to share data headed upstream with connected peers, thus providing them with any data being sent from the front-end.

Front-end

The front-end is where all data is entered or consumed by another application. This could be anything from a microcontroller communicating through UART and displaying data on a screen to a server/database platform logging the data via MQTT.

My recommended method of accessing your data is using a computer, server, or Raspberry Pi linked to an FDRS Gateway device via either MQTT or UART. Node-RED is my favorite platform for accessing/manipulating data on the front-end, and InfluxDB+Grafana is the dream team for storage and visualization.

Future Plans

Upcoming goals for FDRS include:

  • A method for FDRS gateways to keep track of the time via NTP or an RTC module, then seamlessly distribute it amongst its neighbors and connected nodes.
  • More sensor and controller examples. If you are using a device or sensor that is not covered in the examples, feel free to contribute an example of its basic usage!
  • Support for cellular radios with TinyGSM.
  • Channel Activity Detection (CAD) for LoRa.

Thank you

...very much for checking out my project! I truly appreciate everyone who has reached out with contributions and assistance, especially those featured in the "Contributors" section. If you have any questions, comments, issues, or suggestions please don't hesitate to contact me at [email protected] or open a discussion here on Github.

Many thanks go to the ever-instructional Andreas Spiess. His insight and ideas took this project from a roughly-hewn stone to the "diamond" you see today.

Thanks to LilyGo for sending me new LoRa32 modules when mine were damaged. Much of this project was created using TTGO devices, and I highly recommend their products!

It is a great honor to have been featured on Hackaday and hackster.io!

I started this project with instructions from Random Nerd Tutorials. If you are a beginner and trying to learn more about microcontrollers, I highly recommend starting there.

Basic - UART

Basic - MQTT

About

A system that uses ESP-NOW, LoRa, and other protocols to transport sensor data in remote areas without relying on WiFi.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 53.1%
  • C++ 40.3%
  • HTML 6.6%