Where I live, there are community gardens available where you can plant things like herbs and small crops. I think it is a great initiative to get a community together, and a perfect opportunity to develop an IoT system.
I would love to monitor the moisture of the soil so that I know when the plants are thirsty and need water. Monitoring other data points like humidity and temperature in the garden may also help to chart how well the plants grow.
However, the issue is that these gardens are often established in a communal area with little access to power or data outlets, so that adds an additional wrinkle to my IoT plans.
Garden to CloudTo make an IoT system truly independent of outlets, there are two problems to be solved: power and data. For power we have plenty of energy harvesting solutions, and for a garden, solar is perfect. But for data, there are only a few methods that are truly wireless: cellular or satellite. Satellite data is globally available but very expensive. Cellular data is cheaper, but your carrier has to support it. Luckily, Blues Wirelesshas made it very easy with their eSIM enabled devices, the Blues Wireless Notecard. I don't have to navigate a complicated process to request and purchase an IoT SIM. Even better, 500 MB of data is included with no monthly spend required to keep a data line open on the SIM.
Locally SourcedHaving a system that is independent of power and data is great. But I want to monitor a few areas at once. A few multiples of this device isn't scalable, and I don't fancy snaking wires all over the garden to plant sensors everywhere.
So I decided to use Bluetooth as a way to bridge local sensor nodes to the main device powered by the Notecard. Bluetooth is fantastic for transmitting data wirelessly within a local network. It has a low overhead and keeps the power draw low, perfect for IoT projects. The data from these sensors are bridged directly to the Blues Wireless cloud service, Notehub, for processing at periodic intervals and downloaded for analysis.
I am using Adafruit's nRF52840 Feather Express with CircuitPython. It is paired with a Cellular Notecard from Blues Wireless, along with the Notecarrier-AFpaired with a small solar array to ensure power independence. A 6V 2W solar cell from Volatic systems is connected to theNotecarrier to provide solar power, and a lipo battery is connected to provide power where the sun is not sufficient.
Before we go out to deploy and debug sensors under the hot sun (and it can get really hot), I think it makes sense to prototype them at home first. To simulate my other sensors, I'm using the Mijia BLE Temperature and Humidity Sensor. They are popular and cheap home sensors that are battery powered and broadcast sensor data over BLE.
I located two of these sensors in different places. The data is collected every 10 minutes and uploaded to the server every two hours.
The code was written in CircuitPython for easy extensibility and prototyping. The key part of the code is the inclusion of the ENVservice file which details the expected characteristics of the Environment Service GATT entry that the Mijia broadcasts.
The Feather will scan periodically for Bluetooth advertisements containing this service, and will connect to any device that is broadcasting this service. On connecting, it will extract the temperature and humidity data before closing the connection. By adding new characteristics to the ENVservice file, new data types can be captured and represented for different types of sensors, e.g. rain sensors, soil sensors, etc.
list_of_devices = ble_scan.scanForDevices()
print(list_of_devices)
print("Getting data from devices")
list_of_collected_data = ble_scan.getInfoFromDevices(list_of_devices)
Two types of services are already represented in the ble_scan.py file, which consists of helper functions to scan for devices with a certain prefix, ATC in my case, and to collect data from these devices. The Device Info Service and the Environment Service as examples of BLE Services that can be probed for data.
Data being collected from the Feather in the console. At this particular point of collection the temperature is 30.7 degrees with 72.01% humidity: a very hot day indeed! My plants would definitely require more water.
RoutesThe great thing about collecting data this way is that Notehub already handles all the authentication and provisioning for you. I have rolled my own cellular module and webservice before and getting data to the cloud was challenging because it was difficult to debug, but with Notehub, everything just works and the data is waiting for me: no more mucking about trying to insert the proper certificate into the device. Don't get me wrong, I love mucking about with IoT, but there are some parts I'd rather not mess with and spend more time
The next step is to move data to somewhere where we can parse and process it. For me I chose to use Google Cloud because I'm familiar with the service and it is integrated with Notehub, but you can roll your own webhooks as Notehub supports that as well.
I tested by setting up a route with webhook.site (it only took 5 minutes!), and when it was working, I spun up a Google Cloud Function that would receive the endpoint request and display it, and we can see that Notehub has successfully sent the data over to Google.
In Google Cloud, I set up a simple table in BigQuery and had the Cloud Function pass the data to it, which was later connected and visualized in Google Sheets. This is a great dashboard that will allow me to quickly determine what the temperature and humidity are like from anywhere securely without needing to host a website.
If you’re looking to get started with low-power and low-bandwidth cellular IoT, take a look at one of the starter kits offered by Blues Wireless.
Comments