The SenseCAP S2100 Data Logger is a powerful edge device featuring a LoRa transceiver which allows sending data to your preferred network server supporting frequency plans such as 863MHz ~928MHz. The S2100 is able to communicate to any sensor via Modbus RTU RS485, as well as analog 4~20mA/0~10V, and also GPIO level/pulse sensors.
One of its most remarkable features is its capability to work in harsh environments, since it has an IP66 rated enclosure, suitable for outdoor use, high UV exposure, heavy rain, dusty conditions, and more.
Requirements
An active Ubidots account.
An active account on The Things Network LNS.
A SenseCap S2100 with at least one sensor already configured. Please visit the following links in order to do so:
A cellphone running either Android or iOS with Bluetooth.
1. Configure the SenseCap S2100
Install the SenseCAP mobile application by searching “SenseCAP Mate” on your device’s application store or by scanning the following QR code:
Turn on your cellphone’s Bluetooth and then set the SenseCap on Bluetooth pair mode by pressing and holding the config button for 3 seconds:
The following settings were adopted according to the allowed frequency for the region in which the device was configured. Visit the following link in order to get to know the regulations on your region
Tap on the “settings” tab and edit the following parameters according to your needs:
Platform: The Things Network
Frequency Plan: US915
Uplink Interval (optional): 5
Copy the following values to be used later (do not modify any of them):
Device EUI
APP EUI
APP Key
Click on “send”.
2. Register the SenseCap S2100 on TTN LNS
Login to your TTN console.
Select “go to applications”.
Create an application.
Click on “+ add end device”.
Click on “from The LoRaWAN device repository” and edit the following settings:
Brand: SenseCap
Model: Choose the one according to the device you are currently using, in this case, S2100.
Hardware version: Leave the default option.
Firmware version: Leave the default option.
Profile (region): US_902_928.
Scroll down to “enter registration data” and, there, edit the following settings:
Frequency plan: United States 902-928 MHz, FSB 2 (used by TTN)
End device ID: Enter a meaningful name such as “sensecap-humidity-sensor”.
Paste the previously saved DEV EUI, APP EUI, and APP Key on the corresponding fields.
Scroll down and click on “register end device”.
Pro TIP: If your device does not start to send data immediately, press and release the config button on your SenseCap.
3. Create the Ubidots plugin and decoder
Go to your Ubidots account on the “devices” tab and click on “plugins”
Create a new “The Things Stack” plugin.
Leave the “Ubidots device type” on its default option if you wish. However, you can set any name for your device type.
On “Ubidots token” select "default token" or the token that you wish to use for this plugin.
Click on the arrow button to go to the next step.
Click on the recently created plugin to navigate to its options.
Search for the “decoder” tab and copy the “HTTPs endpoint URL”. This will be needed later on.
Scroll down to the “decoding function” section and paste the following code in the text field:
async function formatPayload(args){
var messages = args["uplink_message"]["decoded_payload"]["messages"];
var ubidotsPayload = {};
var varLabelMap =
{
1:"measurement1",
2:"measurement2",
3:"measurement3",
4:"measurement4",
5:"measurement5",
6:"measurement6",
7:"measurement7",
8:"measurement8",
9:"measurement9",
10:"measurement10",
};
messages.forEach(msg => {
msg.forEach(innerList=>{
if (innerList.hasOwnProperty("measurementId")) {
ubidotsPayload[varLabelMap[innerList.measurementId]] = innerList["measurementValue"];
} else if (innerList.hasOwnProperty("Battery(%)")) {
let value = innerList["Battery(%)"];
let label = "Battery";
ubidotsPayload[label] = value;
}
})
});
return ubidotsPayload;
}
module.exports = { formatPayload };
The following GIF serves as a guide:
4. Connect the Ubidots pluging to TTN
Go to your TTN console.
Go to the application created on step 2 of this guide.
On the left side of the screen, look for “integrations” and click on it.
Click on “webhooks”.
Click on “+ add webhook”.
Edit the following settings:
Webhook ID: Give it a meaningful name, it should be only in lower case.
Plugin ID: It's the last portion of your Ubidots plugin’s “HTTPs endpoint URL” after the “/”. For example, if your endpoint’s URL is:
https://dataplugin.ubidots.com/api/web-hook/lN4s2dlb4IgPgpp4Xeoq02stXcE=
, then your plugin ID is “lN4s2dlb4IgPgpp4Xeoq02stXcE=”.Ubidots token: Your Ubidots token.
Scroll down to the “create Ubidots webhook” button and click on it.
5. Configure the Payload formatter
Go to the left pane and click on “payload formatters”.
Click on “uplink”.
Set the “formatter type” to “custom JavaScript formatter”.
Delete all the code there and paste Seeed Studio's official decoder for this device from their GitHub repository.
Note: The following decoder is officially supported and maintained by Seeed Studio. You should copy the decoder from there in order to get the most recent version.
Click on “save changes”.
6. Visualize the Data on Ubidots
Head to your Ubidots account and go to the “devices” section. You’ll be able to see a newly created device with the same name as you previously used for “end device ID” in step #2 of this guide.