All Collections
Connect your Devices
Connect UnaBeacon IoT sensors to Ubidots
Connect UnaBeacon IoT sensors to Ubidots

Learn how to connect the UnaBiz Geolocation and Motion Detector Sensor to Ubidots.

Santiago Pachon Robayo avatar
Written by Santiago Pachon Robayo
Updated over a week ago

The UnaBeacon is a small and simple battery-powered device that uses an accelerometer sensor to detect movement of assetws. Following this guide, you will be able to decode the data from the UnaBeacon to detect and count device movement.

The functionality of the UnaBeacon depends on its Mode configuration, it can be:

  • Timer Mode: Count device movement over a period of time.

  • Event Mode: Detect device movement.

Requirements

Table of contents

1. Understanding the data

Here’s how the data is being decoded according to the documentation to detect or count the device movement. It is important to keep in mind that the decoding depends on the mode in which the sensor is configured.

1.1. Timer mode data

The following payload structure is an example of the data being sent from Sigfox to Ubidots specifically for an UnaBeacon sensor configured for Timer Mode.

{
"device_id": "410902"
"data": "018b000b000a000b000a00b00a",
}

Sample data from Sigfox Sensor: 018b018b000b000a000b000a00b00a

  • 0x01 - Mode Byte #0

  • 0x8b - Interval Byte #1

  • 0x00 - Activity 1/10 Byte #2

  • 0x0b - Activity 2/10 Byte #3

  • 0x00 - Activity 3/10 Byte #4

  • 0x0a - Activity 4/10 Byte #5

  • 0x00 - Activity 5/10 Byte #6

  • 0x0b - Activity 6/10 Byte #7

  • 0x00 - Activity 7/10 Byte #8

  • 0x0a - Activity 8/10 Byte #9

  • 0x0b - Activity 9/10 Byte #10

  • 0x0a - Activity 10/10 Byte #11

Bytes in Total: 12

1.2. Event mode data

The following payload structure is an example of the data being sent from Sigfox to Ubidots specifically for an UnaMotion sensor configured for Event Mode.

{
"device_id": "410902"
"data": "0201",
}

Sample data from Sigfox Sensor: 0201

  • 0x02 - Mode Byte #0

  • 0x01 - State Byte #1

Bytes in Total: 2

NOTE: The state byte represents the object current status, It can be:

  • 0x00: Not moved

  • 0x01: Moved

2. Decoding function at Sigfox Plugin

Step 1: Go to the Sigfox plugin and open the Decoder option.

image.png

Step 2: Find the Decoding function Section. Here’s where we are going to start decoding the data coming from the UnaBeacon.

image.png

Step 3: Copy and paste the code below into the code editor replacing the decode_data() .

def decode_data(hex_array):
payload = {}
status = hex_array[0]
if status == 0 or status == 4:
voltage = (int(hex_array[1:3].hex(), 16))/1000
payload["voltage"] = voltage
elif status == 1:
payload["activity_count"] = int(hex_array[2:12].hex(), 16)
elif status == 2:
payload["state"] = int(hex_array[1:2].hex(), 16)
return payload

Save the code by clicking on the "SAVE & MAKE LIVE" button.


Other users also found helpful...

Did this answer your question?