It's almost gardening season, which means monitoring your plant beds for adequate sunlight, warmth, and pesky critters is more necessary than ever. But, there's an issue; most IoT gardens rely on WiFi, which can be a large problem if your garden happens to be more than a couple hundred feet away. A potential solution is logging the data and reading it back, but that can't occur in real-time, and using a cellular network costs a lot of money. This project aims to solve that issue by utilizing a pair of Adafruit M0 Feathers with integrated RFM69 radio modules to provide real-time monitoring across a large distance. Adafruit's M0 Feather with RFM69HCW Radio Module
Imagine taking an ARM M0 microcontroller and giving it the ability to send data up to 350 meters away with ease. In a nutshell, that is what Adafruit's M0 Feather with RFM69 Radio Module is able to do.
It uses an efficient-yet-powerful ATSAMD21G18 processor, which is the same one on the Arduino Zero. The processor runs at 48MHz and has 256KB of flash and 32KB of RAM, which is a massive step up from something like an Arduino Uno, and it has all of this while still consuming relatively little power. Sensors
For this project, I wanted to keep track of three things in the surrounding area: temperature, ambient light, and if there are any animals nearby. To do this, I went with Adafruit's ADT7410 High Accuracy Temperature Sensor, which is able to measure temperature with an accuracy of.5C and a resolution of.0078C.
To monitor ambient light levels, I chose a simple photoresistor, which changes its resistance based on the level of light it receives. Finally, there is a Passive InfraRed (PIR) sensor that sets its output pin to high whenever a warm object passes in front of it, such as a small animal. Power Options
There are three ways to power the device. First, there is a JST connector on the side where a 3.7V LiPo battery can be attached, plus it has a builtin charge circuit. Second, a 5V USB power bank and micro USB cable could be used for extended monitoring. And finally, a solar panel could keep the project going in perpetuity without the need to charge anything.
Configuring Communication and Sending Information
When the M0 Feather is first powered on, it tries to initialize all of its peripherals (depending on how its set up) and then starts its radio module. In the attached code, the radio is set to use maximum power, but this can be adjusted based on how far away the two radios are from each other. For an antenna, I simply cut a piece of 3-inch wire and soldered it onto the ANT pad on the back of the Feather, and then repeated the same process for the other one.
Since the modules use packet mode to send information, they each get an address. The transmitting device sends out information every second, which includes the temperature, if there is an animal, and the value provided from the photoresistor. It uses the sendtoWait() function that attempts to send the packet to a destination and waits for a response. If there is none, then it times out and prints an error message.Displaying Values
The receiver constantly loops and checks for a new message to arrive, and once it does, it sends an ACK (acknowledgement) packet and then decodes the information to be displayed on an SSD1306 OLED.
Because the ambient light value takes up two bytes, it has to get converted back to a single variable by setting an unsigned 2-byte int to the buffers pointer + 2 bytes. Next, the temperature is decoded by casting the second byte to an int. The animal present value is cast to a boolean. Finally, all of these values are drawn to a blank OLED screen and displayed.