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 implements the IP66 rated enclosure, suitable for outdoor use, high UV exposure, heavy rain, dusty conditions, etc.
Requirements
An Ubidots active account
An active account on The Things Network LNS
A SenseCap S2100 with 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 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:
Launch the SenseCap App on your mobile device.
Select S2100 Data Logger, then tap on Setup
Select your device by tapping on it:
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 settings according to your needs
Platform: The Things Network
Frequency Plan: US915
Uplink Interval (optional): 5
Copy the following values to be used for later (do not modify any):
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: set a meaningful name such as “sensecap-humidity-sensor” or something which you are familiar with.
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 inmediatly, 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 “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 icon to go to the next step
Give the plugin a name and a description
Click the Check icon
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 for further steps.
Scroll down to the “Decoding Function” section and paste the following code on 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 will serve 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”
Search for Ubidots webhook among the different partners:
Edit the following settings:
Webhook ID: set a meaningful name, it should be only lower case
Plugin ID: It is the last portion of your Ubidots plugin’s “HTTPs Endpoint URL” after the “/” E.g. 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 panel and click on “Payload formatters”
Click on “Uplink”
Set the “Formatter type” to “Custom Javascript Formatter”
Note: the following decoder is officially supported and mantained by Seeed Studio on their. You should copy the decoder from there in order to get the most updated version
Delete all the code there and paste Seeed Studio's official decoder for this device from their GitHub repository
Click “Save changes”
6. Visualize the Data on Ubidots
Head to your Ubidots Account, to the “Devices” section and you’ll be able to see a newly create device with the same name as you used for “End device ID”, at step #2.