XIAOS3
| LoRa
| LoRaWAN
| Wio-E5
| Arduino
As an avid home gardener, tending to my plants in my backyard has always been a joyous and therapeutic activity for me. But I always wondered, "Is their environment suitable for their growth?" I wanted to ensure they were getting the optimal conditions to thrive.
After I moved to my current flat earlier this year on an internship, I have a rooftop garden and use some nice looking pots as planting beds. I often spend the whole day inside my garden, and I grow more than just some flowers, I also grow some of my favourite vegetables. As a new gardener, none of the vegetable seeds I sowed germinated. I looked up all kinds of information and realised that the soil temperature was too high and I watered it too much, so I made my own device to monitor both the soil temperature and humidity as well as the air quality.
That's when my neighbor, Yvone, a Seeed enthusiast, introduced me to the Seeed XIAO S3 and the Grove SEN54 for air quality monitoring. They were perfect - small, efficient, and precise. And typecally the name in Chinese means small, tiny.
With Yvone's help, I also started using the Seeed LoRaE5, embracing the power of LoRa and LoRaWAN network. Fortunately, with Yvone's Seeed M2 Gateway at home, I didn't need to purchase a LoRa gateway myself.
Soon, I was able to bind the LoRaE5 device on The Things Network (TTN) and visualize the data on Datacake. It was a revelation to see the living conditions of my plants visualized in real-time!
But my journey doesn't stop here. I am constantly thinking about how to mature and expand this project.
Here are some of my ideas:
- With LoRa for communication, I am thinking about creating a local network for data display, something akin to a SenseCAP Indicator.
- I am also considering using an I2C Hub to connect many I2C devices. With the right pre-written code, I can just plug in the corresponding sensor, and it will upload the corresponding data packet.
- I can then use the Network Server for preprocessing and connect to platforms other than Datacake for application development, data visualization, and analysis.
- I also plan to send downlink commands for various actions like watering plants, setting alarms, turning on sunlight lamps (when plants need light), and more.
- An additional idea is to share this environmental data with my neighborhood, providing valuable insights into our local air quality and other environmental factors.
[Here.]
In this section, based on my experience, I'll cover the following aspects:
- How I connected these various components and wrote the code.
- How to utilize AT commands to enable the Wio-E5 to transmit data via LoRa modulation.
- How to establish a connection with TTN and forward data to Datacake.
As to follow the the architecture of LoRaWAN, I also made my things into four parts, but for features into five parts as to IoT Architecture.
in this architecture, it is very clear that, the End nodes will collect all the data and send data to Gateway Wireless forward to the Network server, then I just need to focus on how to use these data instead of caring about the data collected.
Before I chose the Seeed XIAO S3, I looked for three things in a microcontroller:
1. Small size2. Low cost3. Works with Arduino
When I compared it with other boards, the Seeed XIAO S3 was clearly the best value for money and offered more room for growth (thanks to Yvonne).
As the architecture design shows, it will collect all the data from the sensor. But it can do more. With the I2C hub and some pins I didn't use, I can add more to it later. So even though it's small, it can control a lot of devices.
[PICTURE]
Ⅲ. Seamless Integration with LoRaLoRa, with its long-range and low-power characteristics, is a perfect wireless protocol for IoT applications that demand broad and energy-efficient communication. In the realm of gardening, it facilitates accurate environmental monitoring and intelligent automation over vast distances, even in demanding urban environments.
For the swift implementation of LoRa technology, I employed the Grove-Wio-E5 Wireless Module, a compact device controllable via AT commands. I'll detail the fundamental AT commands used for configuring the Wio-E5, along with the relevant code.
/*AT COMMANDs: Query the info*/
AT+ID /*Read all, DevAddr(ABP), DevEui(OTAA), AppEui(OTAA)*/
AT+ID=DevAddr /*Read DevAddr*/
AT+ID=DevEui /*Read DevEui*/
AT+ID=AppEui /*Read AppEui*/
/*AT COMMANDs: Set*/
AT+ID=DevEui, "deveui" /*Set new DevEui*/
AT+ID=AppEui, "appeui" /*Set new AppEui*/
AT+KEY=APPSKEY, "16 bytes length key" /*Change application session key (APPSKEY)*/
AT+KEY=NWKSKEY, "16 bytes length key" /*Change network session key*/
/*AT COMMANDs: Send msg*/
AT+MSG="Data to send" /*send string format frame which is no need to be confirmed by the server.*/
AT+CMSG="Data to send" /*send string format frame which must be confirmed by the server.*/
AT+MSGHEX="xx xx xx xx" /*send hex format frame which is no need to be confirmed by the server.*/
AT+CMSGHEX="Data to send" /*send hex format frame which must be confirmed by the server*/
AT+DR=band /*Change the Band Plans*/
AT+DR=SCHEME /*Check current band*/
AT+CH=NUM, 0-7 /*Enable channel 0~7*/
AT+MODE="mode" /*Select work mode: LWOTAA, LWABP or TEST*/
AT+JOIN /*Send JOIN request*/
Using LoRa Tech, it’s very easy to connect each main controller, as the LoRa is wireless broadcast(only in the same configuration, the SF and …), every controller try to listen will capture the payload and parse them into the right data in the specific decoder.
If I need to plug into the cloud I’ll need a gateway to help me as the architecture shows.
Leveraging LoRa technology simplifies the connection between main controllers, given its wireless broadcast capabilities. When set with the same configuration parameters (like Frequency band, Spreading Factor, etc.), each controller attempts to listen, captures the payload, and parses it into the correct data using the specific decoder.
To connect to the cloud, as depicted in the architecture, a gateway is necessary to facilitate the process.
Ⅳ. Connecting to The Things NetworkUpon connecting the devices: Sensors (through the I2C Hub), Grove-E5 module, and XIAO ESP32S3
The Things Network (TTN) is a worldwide, open-source, community-driven IoT data network that uses LoRaWAN. With features such as straightforward device management and secure end-to-end encryption, TTN serves as a key component in my project, acting as the data transmission backbone from my garden's LoRa-enabled sensors.
To establish a connection with TTN, two steps are required:
1. Register your LoRaWAN Gateway2. Register your Node deviceRegister your LoRaWAN Gateway
I'm using the SenseCAP LoRaWAN Gateway, which is very user-friendly. Simply plug in the power supply and connect the Ethernet cable.
Register your Node device
Before you register a node device, you need to set up an application in TTN:
Create an application and register an end device.
Enter any ID you like →
Pressing the `Register end device` button and then choose the second choice to set up the parameters as followed:
The `JoinEUI` is the same as `AppEUI`
When you confirm the configuration, it will show more parameters that need to be set.
Or you can just generate them and reset them to your end device(Wio-E5). Go to [](https://www.notion.so/a9c387fa4c9d4f2f87a27ac990175e3e?pvs=21) to know how to set it or get it.
When we register end device well, the TTN will guide us to `Overview` to see general information where you had set.
Ⅴ. Visualizing Data with DatacakeFor those new to Datacake, six steps are required:
1. Create a Datacake Account2. Add Device (Wio-E5) via LoRaWAN on Datacake3. Obtain Datacake's API token4. Set up Datacake Integration (Webhooks) on TTN5. Configure the Dashboard on Datacake6. Monitor your data (Note: Data display is not in real-time)
1) Create a new account, website: https://datacake.co/
2)Add the Wio-E5 on Datacake
3)Choose “LoRaWAN”.
4)Select New Product
5) Click the “Account Setting” → “API Token” → Get API token
In this part we will show you how you connect the The Things Stack LNS, which powers The Things Network v3 and The Things Industries, to Datacake and how you set up the configuration for both Uplinks
6)Create Integration on TTI
On your TTI Application select Integrations on the Side-Bar
7)Navigate into the "Webhook" Section of the Integrations on your Application
Add a new Webhook by clicking the Button "+ Add webhook"
8)This will show you a list of available webhook-templates you can chose from:
9)Chose the "Datacake" Webhook Template
10)Your browser will show you the following page
Now we need to create an API Key on Datacake for Webhook Authentication
Navigate over to your Datacake Workspace and select "Members" from Sidebar:
In the members section you select "API Users" from Tab-Bar
After switching to the API Users Tab you click on the upper right Button "Add API User"
This will show you the following dialog:
First of all enter a name for your API User (like "TTI Webhook API User")Next select "Devices" from Workspace Permissions List
Click on "Add Permission for all Devices in Workspace"
The following element will be added to the modal:
Here you select "Can record measurements"
Press "Save" to create the Token
This API Token is now valid for all devices in your workspace. Everytime you create a new device, this Token does automatically work for that device.
If you are interested in creating a Token for selected Devices only, you can navigate into the device and select the token from there. But you have to leave out the "All devices in workspace"-Permission here.
Next copy the Token from Datacake (click on the "Show" Button to see and copy the Token)
Now switch back to your Application on TTI:
Paste the copied Token into the field "Token"
Create Datacake Webhook on TTI by clicking on the "Create datacake webhook" Button
DownlinksIn order to be able to queue up Downlinks on your TTI Application you need to provide additional detail on your Datacake-Device. To set the configuration please move into the LoRaWAN settings on the corresponding device:
When you scroll down a little bit you get to the following section.
As mentioned in the screenshot please click on "Change" to open up the configuration for Downlink Configuration. This will bring up the following dialog:
In this Dialog you need to fill in the 4 textboxes with Information that you find on the TheThingsStack Console.
TTI Dev-ID
This is the ID of your Device in your TTI Application. You find it here:
TTI Server URL
This is the URL of your TTI Instance as available to the public.
For public TTNv3: eu1.cloud.thethings.network
Example: datacake.eu1.cloud.thethings.industries (Datacake TTI URL)
TTI Application IDThis is the ID of your Application on TTI:
TTI Api Key
Create TTI API Key
To create a new API Key on TTI head over to the "API keys" page using the left sidebar:
Now click on "Add API Key"
The following dialog will appear:
Set a custom name (like "datacake-api-key")
And set corresponding rights to allow queuing up downlinks
Create the API Key by clicking on "Create API key"
After you created your API Key you will see the above notification
Please copy your key to your clipboard as it will only be shown once!
Paste this key into the device settings on Datacake
Final Settings
When you are done copying the dialog show look something like this:
Update and Save
Please don't forget to press the Update button when done setting the new Downlink Settings:
Copy your Payload Decoder to here.
The data sent using the AT command is uploaded to the DATACAKE platform.
💡 If you utilize the decoder on TTN, only minor adjustments are required on Datacake, eliminating the need for a complete decoder.Ⅵ. Coding
To utilize the LoRaWAN network, to upload data to TTN and Datacake, we need to collect:
1. TTN
Preparing Compile environment
While the Arduino IDE can be used to compile and manage code, I highly recommend using VSCode and its extension: PlatformIO, especially as the Seeed XIAO S3 is now compatible with PlatformIO.
Once your coding environment is set up, you're ready to begin.
AT Commands functions
RUN
The Impact of Technology on GardeningFuture PlansConclusionBy adding sections specifically for TTN and Datacake, you can detail the process of using these platforms and their impact on your projec
Comments
Please log in or sign up to comment.