Skip to main content
All CollectionsConnect your Devices
Connect Seeed Studio's SenseCAP S2120 8-in-1 weather station to Ubidots[TTN LNS]
Connect Seeed Studio's SenseCAP S2120 8-in-1 weather station to Ubidots[TTN LNS]

This articles describes how to connect the SenseCAP S2120 8-in-1 weather station to Ubidots.

Sergio M avatar
Written by Sergio M
Updated over 2 months ago
image 2168.png

Requirements:

1. Configure the SenseCap S2120

  • Install the SenseCAP mobile application by searching “SenseCAP Mate” on your device’s application store or by scanning the following QR code

  • If you don’t have an account already, create one by following the steps on the App

image 2169.png
  • Install the battery to the device. You can find out how to do it by following this official documentation. After doing so, the red LED will be steady

image 2170.png
  • Turn on your cellphone’s Bluetooth and launch the “SenseCAP Mate” App

  • Your device will be automatically detected

  • Select “S2120 Weather Station” among the different options

  • Tap on the “Setup” button

  • You might be prompted for a password. The default one is 000000

  • If your device is not listed, click the “Scan” button to search for it

  • Once detected, tap on your device

  • Tap to the Settings tab

Component 50.png
  • Edit the following settings according to your needs/regulations

    • Platform: The Things Network

    • Frequency Plan: AUS915

    • Uplink Interval (optional): 5

  • Keep in mind if you are located on Europe you should select EU_863.

  • if you are located on India, you should choose IN_865

  • In the following link you can find out more about each country allowed band and it's regulations

  • This guide was developed in a country where the US_902_915 band is the allowed, but remember to change these settings according to your region.

  • Copy the following values (do not modify any). We'll use them later:

    • Device EUI

    • APP EUI

    • APP Key

  • Click on “Send”

2. Register the SenseCap S2120 on TTN LNS

  • Please follow step #2 of the following guide. Once done, you can proceed to the next section of the current guide. Then you can return to this guide's next section.

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

image 2173.png
  • Leave the “Ubidots device type” on its default option or change according to your needs

  • On “Ubidots Token” select "Default Token"

  • Click on the arrow icon to go to the next step

image 2174.png
  • Give the plugin a name and a description

  • Click the check icon

image 2175.png
  • 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

  • Scroll down to the “Decoding Function” section and paste the following code on the text field:

async function formatPayload(args){
console.log(args);

var messages = args["uplink_message"]["decoded_payload"]["messages"];
var ubidotsPayload = {};
var varLabelMap =
{
"4097":"air-temperature",
"4098":"air-humidity",
"4099":"light-intensity",
"4190":"uv-index",
"4105":"wind-speed",
"4104":"wind-direction",
"4113":"rainfall-hourly",
"4101":"barometric-pressure",

};

ubidotsPayload["port"] = args["port"]
ubidotsPayload['SNR'] = args['hotspots'][0]['snr']
ubidotsPayload['RSSI'] = args['hotspots'][0]['rssi']
ubidotsPayload['Frame Counter'] = args['fcnt']

messages.forEach(msg => {
msg.forEach(innerList=>{
if (innerList.hasOwnProperty("measurementId")) {
ubidotsPayload[varLabelMap[innerList.measurementId]] = innerList["measurementValue"];
}
if(innerList.hasOwnProperty("Battery(%)")){
ubidotsPayload["battery"] = innerList["Battery(%)"];
}
})
});

return ubidotsPayload;
}



module.exports = { formatPayload };

The following GIF will serve as a guide:

4. Connect the Ubidots Pluging to TTN

  • Please follow the steps given in this guide’s fourth section: “Connect the Ubidots Pluging to TTN”

  • Once done, you can come back to this guide and go further the next section

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”

<a href="https://downloads.intercomcdn.com/i/o/639388176/f3fd0073bbcadcd53358a3b9/b3481912-f713-41b8-913d-692c421cb57d?expires=1731942000&amp;signature=7277bfe102ef960e9a196519ae50c11f36c564b57b015004dd4c4d677cf838fa&amp;req=ciMuFcF2nIZZFb4X1HO4gSGqkhvUGfFP08wpbT%2FrSKDjfznwmJ2Ys4RdZFym%0A" target="_blank" rel="nofollow noopener noreferrer">https://downloads.intercomcdn.com/i/o/639388176/f3fd0073bbcadcd53358a3b9/b3481912-f713-41b8-913d-692c421cb57d</a>
  • Delete all the code there and paste Seeed Studio's official decoder for this specific 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.

Did this answer your question?