March 13, 2024
If this sounds interesting to you and you'd like to request a demo or learn more, please contact sales.
I live nestled in the heart of an agrarian country. Here, the soil holds tasteful tales of the past and the future of our economy. If you like numbers, here’s a bunch for you, Agriculture contributes approximately 33% of our GDP and employs more than 40% of our total population. You see, my journey into this project wasn’t fueled by a quest for innovation, but if I end up innovating something, I accept that. It was fueled by a need to improve, even just a tiny bit, the current state of affairs. USAID published an article saying that in recent years agricultural productivity has stagnated. Current methods of farming are pretty archaic and if we are to depend on these same methods to boost our productivity, we risk being obsolete as well.
One of the biggest challenges that farmers currently face is the gap that exists between them and the technology that could improve their output. This project aims to eliminate that gap. I have built an IoT sensor node that can be deployed to the farm and collect important parameters for a farmer which can be analyzed and used to maximize productivity. With this aim in mind, I have to solve several challenges including:
To solve these four main problems, I started by drafting a block diagram that provides an overview of the electronics.
Generally, the aim is to have a node that includes a high-performance, low-power, low-cost microcontroller at the heart of the board which can support industry-grade sensors using RS485 protocols, a low-power wide area networking module, a power management circuit that can supply power to both the MCU and any peripherals connected.
In this project, I will be describing how I accomplished that in the Green Dot Board. You can head to the Project and clone or fork it to have edit access.
One of the most important features of the Green Dot Board is power management. As described in the core requirements of the system, is the ability to work autonomously for years without any power concerns. I therefore decided to start by designing a power management circuit and making sure that works fine first to de-risk the whole system.
Most of the sensors that can be hooked onto this system require either 3.3V, 5V, or 12V. I therefore designed the power management circuit to be able to deliver all these powers. You can check out the Brave Power management circuit here. This board can be powered by either LiPo batteries, 4V - 6V solar power panels, or a Micro USB. From these inputs, there is a set of dedicated components to generate and regulate each of the mentioned outputs.
a) 12V and 5V Rail
Starting with the 12V and 5V rail, I used the high-efficiency MT3608L 1.2MHz step-up converter. I used a voltage divider circuit to adjust the output of the component and used an SPDT switch to enable switching between the 12V and 5V output.
Vout = Vref x (1 + R1/R2) where Vref = 0.6V as per the datasheet
b) 3.3V Rail
For the 3.3V rail, I first use an RT8059 converter which is a high-efficiency Pulse Width Modulated (PWM) step-down DC/DC converter, capable of delivering 1A output current over a wide input voltage range from 2.8V to 5.5V. This was very ideal for my case since the LiPo batteries I will be using have a nominal voltage of 3.7V, a maximum of 4.2V when fully charged, and a minimum of about 3.0V when fully discharged.
where the ripple current can be approximated as 30% - 40% of the maximum output current
I then used an ultra-low loss power distribution switch with a programmable current limit to protect the power source from overcurrent and short circuit conditions. Current limiting is set by connecting a resistor Rset from ISET Pin to GND. To get the value of the Rset you want, you can use the following equation.
Rset = 6800/Current(A)
c) Charging circuit
For charging the batteries, I used the CN3063 which is a constant-current /constant-voltage linear charger for single-cell Li-ion and Li-Polymer rechargeable batteries. This device is ideally suited for solar-powered applications but it can also work with the USB specifications. It has a regulation voltage preset at 4.2V with 1% accuracy but can also be changed using a resistor. the device accepts input voltages of 4.4V to 6V meaning we would have to use a small solar panel delivering about 5W.
Some interesting features I haven’t mentioned yet of this device include the following.
The charge current is set by connecting a resistor Riset from the ISET pin to GND. The ISET pin’s voltage is regulated to 2V during constant charge current mode.
Ich = (Vset / Rset) x 900
I then used two diodes to direct current from both USB and Solar to the charging circuit.
Improvements for a V2 level, so reading the value with an MCU will prove invaluable.
For wireless connectivity, LoRaWAN was an obvious selection. I won’t go deep into the theory behind LoRaWAN, all I can say now is that LoRaWAN stands as a low-power, wide-area networking protocol, leveraging the LoRa radio modulation technique as its foundation. Its primary function lies in establishing wireless connectivity for devices to the internet. For example, enabling your motion sensor to have a heart-to-heart with your alarm system and notify you when unprecedented motion is recorded.
LoRaWAN boasts several features that position it as an ideal fit for our IoT applications:
I decided to choose the SEEED Studio’s LoRa-E5 module because it has built-in AT command firmware, making it easy to create prototypes or applications with just a few simple commands. However, soldering the module onto the board was probably the most challenging bit of the whole Green Dot development process. The module is small, and I don’t believe I had the right tools to handle that kind of hand soldering. It was only after I got soldering flux, and a better soldering iron tip that I was able to finish the job.
Designing around this module is quite simple. I connect UART and NRST to the host MCU to send AT commands. In addition, I connect Pin24 to a tactile push button because the grounding of the module will force the module to enter Boot upgrade mode. This module works on 3.3V so I also make sure to provide that.
a) Registering our LoRa Module
To register a device to a LoRaWAN platform, you can choose either of two options, Activation By Personalization (ABP) or Over The Air Activation (OTAA). One of the main differences between the two is that ABP offers simplicity and speed, while OTAA provides enhanced security through dynamic key exchange so for our case we will use OTAA to register our device.
When registering a device using OTAA (Over-The-Air Activation) in a LoRaWAN network, you typically need the following information:
I’ll be using Loriot for this demonstration because that was readily available to me, but the same concepts apply to other similar platforms like The Things Network (TTN). Step 1 would be to enroll a device by providing the generated keys and a name for the device.
The next step would be to make sure those same keys are written to the LoRa module. This can be done as shown below.
Choosing the right microcontroller is pivotal for the success of an IoT sensor node. Considering the requirements of low cost, low power, efficiency, and an easy development environment. I decided to go with the Seeed Studio’s XIAO RP2040. This breakout features the RP2040 microcontroller from Raspberry Pi bringing with it high performance, low cost, and ease of use to the microcontroller space.
Some of the features outlined on Seeed Studio’s website include:
This SEEED module has an onboard RGB LED which we will use to visually illustrate the state of the system.
Sensor Interface
When it comes to interacting with sensors, the green dot board can hook up UART, I2C, and RS485 sensors. The connection block also has a set of two pins which can be used as programmable IO pins using the RP2040.
For the RS485, I’m using the SP3485 a +3.3V low-power half-duplex RS485 transceiver with a 10Mbps data rate. The RS485 standard allows for multi-drop (multiple devices on the same bus) and long cabling lengths. In addition, it offers great noise immunity. Some of the sensors that can be connected include the following;
The supporting components around the RS3485 include a bypass capacitor, a pull-up resistor on the RO line, and a termination 120-ohm resistor at the end of the twisted pair A B cables. I used a 120 ohm because the twisted pair cable used in RS485 is defined to have a characteristic impedance of 120 ohms and so by adding a 120-ohm resistor at the end of an RS485 transmission line, the signal will be dampened by the resistor instead of reflected into the bus.
The last bit is to route to my microcontroller.
NOTE: During testing, I realized something that you might have already noticed from this schematic, I had forgotten to connect the ENABLE pins from the SP3485 to my microcontroller. This will be done in my second revision.
I wrote a simple MicroPython code to that sends some data to the cloud as proof of concept. The code can be found on my GitHub Profile. I started by writing simple functions to interact with the LoRa module and then used those functions to join the network and send data to the cloud.
In the main file, I start by importing the required libraries and defining the firmware parameters.
I then enter an infinite loop that first checks whether It’s the first time we are running the code, if it is then we join the network, if not we continue with the rest of the code that first reads sensor values and then sends then converts the values into hexadecimal for transmission. After transmission, the system sleeps for the defined uplink interval period.
The final setup looks as shown below. I’m looking into getting a 3D-printed enclosure to just keep everything nice and tidy.
And there you have it folks, The Green Dot Board. This journey has been a total delight for me from the very beginning and I hope you can say the same thing. You can see below an illustration of how data is being received in the cloud. The next step from here would be to build either a custom dashboard to display all this information or to use a platform like Datacake which would integrate seamlessly with Loriot or TTN to do the data visualization.
I will be implementing some of the issues that arose along the way and updating the design in flux. You should be getting prompts of new updates as I do then and either choose to receive or deny them. Accepting updates is as simple as clicking the accept button.