IoT plays a vital role in modern agriculture by enabling precise monitoring of crops, soil, and environmental conditions. This guide walks through the process of building a device that combines LoRaWAN® and cellular connectivity with three types of sensors: light, environmental, and soil. The project serves as a practical template for creating ready-to-deploy agricultural monitoring solutions.
The system collects real-time data from all three sensors and transmits it to the cloud using two widely adopted IoT communication protocols: LoRaWAN and NB-IoT/LTE Cat-1. This approach provides a solid foundation for developing applications that support smarter farming practices and data-driven decision-making.
Use Case
The purpose of this project is to illustrate a real-world scenario where it can be applied effectively. We will replicate the project developed in the Blues Wireless Accelerator, which provides a solution for transmitting soil variables and environmental conditions to the cloud, including alerts when values fall outside acceptable ranges.
We will reproduce the project as outlined in its official repository, beginning with the hardware configuration depicted in Figure 4.
Requirements
Necessary Hardware
- WisBlock Baseboard RAK19001
- WisBlock Core RAK4631
- Barometric Pressure sensor RAK1906
- Light Sensor Texas Instruments OPT3001
- Soil Moisture Sensor Atmel ATTINY441
- WisBlock Blues Carrier Module RAK13102
- LiPo Battery
- Blues Notecard (Select one according to your location)
- Blues Notecarrier A, B or F (Optional)
Gateway
- RAK7268V2 WisGate Edge Gateway for LoRaWAN (used in this guide)
Back-End Services
Hardware Connection
The hardware adopts a modular approach provided by WisBlock. The complete firmware is developed and available in the official RAKwireless GitHub repository, and the IoT data visualization platforms are cloud-ready. Additionally, we will replicate the project developed by Blues Wireless by using JSON data to access the information.
Connecting the WisBlock elements is straightforward:
Mount the core module onto the core slot, and attach RAK1906 and RAK1904 sensors to the sensor slots A and B. In this instance, you will use the RAK19001 motherboard, but here you can select another WisBlock baseboard.
The Blues Notecard can be connected via the WisBlock Blues Carrier Module, and also the RAK12023, which should then be plugged into the baseboard's IO slots.
Plug the soil moisture sensor into the RAK12023.
Finally, to prepare your product for deployment, you can use the WisBlock enclosure designed for this purpose.
Now that the devices are connected, you can begin programming.
The Notecard requires a peak current of 2 A to send data. The VDD pin of the WisBlock cannot provide this current, so it is recommended to use a battery or connect an additional USB cable to the Notecard during your project testing.
Blues Hardware Assembly
After completing the instructions outlined in the hardware configuration and uploading the code provided by Blues on GitHub to the notecard, the final assembly is shown in the image below:
Firmware Development
The code can be downloaded from our official GitHub repository. It was developed using Visual Studio Code and PlatformIO, which are two widely used tools for programming firmware.
In case the libraries are not available on PlatformIO, you can find them from the following sources:
If you need more information about how to configure and code your WisBlock setup with PlatformIO, check the following guide for Setting up WisBlock on PlatformIO.
Sending Data to the Cloud
LoRaWAN Communication
The process of communicating with end devices via LoRaWAN networks can be accomplished through a public network like Helium or by setting up your own network using a LoRaWAN gateway. In this instance, configure the second option. For this process, you will need:
This process is straightforward and can be completed in just a few minutes. For a step-by-step configuration guide, refer to the RAK7268V2 gateway documentation.
After the successful configuration and connection of the gateway to the TTN LNS, use the given payload decoder.
TTN Payload Decoder
async function formatPayload(args){
var ubidots_payload = {};
// Log received data for debugging purposes:
// console.log(JSON.stringify(args));
// Get RSSI and SNR variables using gateways data:
var gateways = args['uplink_message']['rx_metadata'];
for (const i in gateways) {
// Get gateway EUI and name
var gw = gateways[i];
var gw_eui = gw['gateway_ids']['eui'];
var gw_id = gw['gateway_ids']['gateway_id'];
// Build RSSI and SNR variables
ubidots_payload['rssi-' + gw_id] = {
"value": gw['rssi'],
"context": {
"channel_index": gw['channel_index'],
"channel_rssi": gw['channel_rssi'],
"gw_eui": gw_eui,
"gw_id": gw_id,
"uplink_token": gw['uplink_token']
}
}
ubidots_payload['snr-' + gw_id] = gw['snr'];
}
// Get Fcnt and Port variables:
ubidots_payload['f_cnt'] = args['uplink_message']['f_cnt'];
ubidots_payload['f_port'] = args['uplink_message']['f_port'];
// Get uplink's timestamp
ubidots_payload['timestamp'] = new Date(args['uplink_message']['received_at']).getTime();
// If you're already decoding in TTS using payload formatters,
// then uncomment the following line to use "uplink_message.decoded_payload".
// PROTIP: Make sure the incoming decoded payload is an Ubidots-compatible JSON (See https://ubidots.com/docs/hw/#sending-data)
// var decoded_payload = args['uplink_message']['decoded_payload'];
// By default, this plugin uses "uplink_message.frm_payload" and sends it to the decoding function "decodeUplink".
// For more vendor-specific decoders, check out https://github.com/TheThingsNetwork/lorawan-devices/tree/master/vendor
let bytes = Buffer.from(args['uplink_message']['frm_payload'], 'base64');
var decoded_payload = decodeUplink(bytes)['data'];
// Merge decoded payload into Ubidots payload
Object.assign(ubidots_payload, decoded_payload);
return ubidots_payload
}
function decodeUplink(bytes) {
// Decoder for the RAK1906 WisBlock Environmental Sensor (https://store.rakwireless.com/products/rak1906-bme680-environment-sensor)
var decoded = {};
if (bytes[0] == 1) {
// If received data is of Environment Monitoring type
decoded.air_humidity = (bytes[0] << 8 | (bytes[1])) / 100;
decoded.air_temperature = (bytes[2] << 8 | (bytes[3])) / 100;
decoded.air_pressure = (bytes[6] |(bytes[5] << 8) | (bytes[4] << 16)) / 100;
decoded.light_level = (bytes[9] |(bytes[8] << 8) | (bytes[7] << 16));
decoded.soil_moisture = (bytes[10] << 8 | (bytes[11]));
decoded.soil_temperature = (bytes[10] << 8 | (bytes[11])) / 10;
}
return {"data": decoded};
}
module.exports = { formatPayload };
Blues Communication
Create an account on the Notehub page and start a new project. For step-by-step instructions, refer to the Blues documentation.
Ubidots Notehub JSON
This JSON file is used when the transmitted data is sent via the Blues Wireless hardware.
{
"air_temperature": {"value": body.air_temperature},
"air_humidity": {"value": body.air_humidity},
"air_pressure": {"value": body.air_pressure},
"light_level": {"value": body.light_level},
"soil_moisture": {"value": body.soil_moisture},
"soil_temperature": {"value": body.soil_temperature}
}
Ubidots Connection
The Blues accelerator executes business logic exclusively through Notehub and Notecard. This design, while functional, limits scalability across other networks and reduces accessibility for non-expert users who require graphical data presentation.
Ubidots provides a solution by enabling alarms and signals that control maximum and minimum data ranges. These features allow for easier data adjustment and continuous monitoring for errors or out-of-range values. Additionally, Ubidots integrates notification options, such as SMS, email, and Telegram, to ensure prompt incident reporting.
Through a simple configuration process outlined in the Ubidots Events setup guide, two events can be established: one that triggers an alert when crop humidity falls below an acceptable threshold, and another when the ambient temperature dips beneath a defined level. In both cases, an email notification is sent to inform the user of the event.
After completing the Notehub and TTN integration using Ubidots’ official guides, your dashboard should look similar to Figure 6:
From there, data can be sent to Ubidots using LoRaWAN or NB-IoT/BLE/Cat-1.
Key Advantages of Using WisBlock
Production-Ready: Not just a prototype, this is a finished product ready for real-world use.
Modular Design: Easy and fast to set up thanks to WisBlock’s plug-and-play modular architecture.
Clean & Professional: Results in a polished and compact final product with minimal assembly.
Developer-Friendly Firmware: Compatible with Arduino and PlatformIO, no need for complex IDEs.
Multi-Network Communication: Supports LoRaWAN and cellular (NB-IoT, LTE-M, CAT-1) connectivity.
Quick Integration with Dashboards: Easily connected to IoT platforms, no advanced front-end/backend coding required.
Space-Efficient: Small form factor ideal for installations with limited space.
Stock Notice: Some components used in Blues' reference solution may no longer be available.
Summary
As presented in this tutorial, WisBlock is a modular hardware solution developed by RAKwireless that simplifies the development of industrial-grade IoT applications. When paired with Blues Wireless components, it enables rapid deployment without the need for a custom PCB design and offers some good features like:
Plug-and-Play Hardware: There's no need to design your PCBs. Just stack the modules and go.
Industrial Application Ready: Designed for reliable use in professional and commercial environments.
Prebuilt Firmware: Core functionality is already developed and ready for deployment, saving time and effort.
Developer-Friendly: Works seamlessly with platforms like Arduino and PlatformIO.
|
|
Harold Duarte Harold is an electronics engineer and senior technical content writer at RAKwireless. He is passionate about learning and developing new solutions for IoT, making it #IoTMadeEasy. |
Changelog
-
Version 1 - Greenhouse Monitoring with RAK WisBlock and Blues Notecard
- Author: Harold Duarte
- Reviewer: Karla Jimenez
- Date Published: 10/02/2025
Updated