Skip to content

Pack Ubidots

Javier Sanchez edited this page Mar 23, 2017 · 7 revisions

Zolertia Ubidots over MQTT

What do I need?

To build the application you will need:

Install the Zolertia toolchains and tools if you don't have it.

Clone Zolertia pack repository if you don't have it already Zolertia contiki, now update the repository using that: git submodule update --init and finally change to branch Zolertia-Packs:git checkout Zolertia-packs

Now we need to program the binary files on Orion Router for connectivity to the internet over 6lbr and create a 6LoWPAN network.

To program a device using any of this images (in this case we are using cetic_6lbr_router_eth_gw.bin):

/contiki/examples/zolertia/tutorial/99-apps/mqtt-node$ python ../../../../../tools/cc2538-bsl/cc2538-bsl.py -e -w -v -a 0x200000 Binaries/router/cetic_6lbr_router_eth_gw.bin 
Opening port /dev/ttyUSB0, baud 460800
Reading data from Binaries/router/cetic_6lbr_router_eth_gw.bin
Firmware file: Raw Binary
Connecting to target...
CC2538 PG2.0: 512KB Flash, 32KB SRAM, CCFG at 0x0027FFD4
Primary IEEE Address: 00:12:4B:00:06:16:0E:52
Erasing 524288 bytes starting at address 0x00200000
    Erase done
Writing 524288 bytes starting at address 0x00200000
Write 16 bytes at 0x0027FFF0F8
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0x57ee5c91)

Plug Ethernet cable and supply by PoE or USB.

Notice the Border Router also advertise a local IPv6 address (bbbb::/64 as default), being the default Border Router address the bbbb:100. We can use this address to also talk to the Border Router using IPv6.

Now open a browser and using http://[bbbb::100]

This is the 6lbr webservice showing the Border Router status and configuration options. We can manage and configure both the IPv4/IPv6 and 6LoWPAN networks, and also manage the wireless nodes in our 6LoWPAN network.

In Configuration tab we have all network parameters, both 802.15.4 and Eth network.

For this example the security is enabled on 6LoWPAN network and is necessary ennable it on router. Such that:

  • Link-layer security : Pre-shared Key
  • Link-layer security level: AES-CCM-128
  • Enable anti-replay workround: on

Submit and reset Orion Router


Hardware connection

The RE-Mote uses a 5 and 3 pins connectors, the Relay can be connected on ADC1, soil moisture should be connected on ADC3 because can be probide 5V on signal pin. Only it's possible connect one digital sensor and application recognice one of them.


Ubidots application

We have to get an account and get the token, then we will need to set 'Default token' as shown:

This token will include it in the header of the platform ubidots.h

#define DEFAULT_CONF_AUTH_TOKEN       ""  /* Not used */
#define DEFAULT_CONF_AUTH_USER        "pcJe4icxXXXXXXXXXXXXXXXXXXXXXX"

#define DEFAULT_ORG_CONF_ID           "zol:001"

Verify in Makefile that:

# Platform options: relayr, thingsio, bluemix, ubidots
MQTT_PLATFORM ?= ubidots

# Sensor options: fridge, coldchain, agriculture, watering, remote, coinbox, 
#                  flowerpot, smartcities, ubidots_demo
MQTT_SENSORS  ?= ubidots_demo

Next we need compile the application and program RE-Mote

Compile and program RE-Mote:

contiki/examples/zolertia/tutorial/99-apps/mqtt-node$ make clean && make TARGET=zoul BOARD=remote-revb mqtt-client.upload
using saved target 'zoul'
rm -f *~ *core core *.srec \
  *.lst *.map \
  *.cprg *.bin *.data contiki*.a *.firmware core-labels.S *.ihex *.ini \
  *.ce *.co
rm -rf *.zoul symbols.c symbols.h *.d *.elf *.hex
rm -rf obj_zoul
mkdir obj_zoul
  CC        ../../../../../cpu/cc2538/./ieee-addr.c
  CC        ../../../../../cpu/cc2538/cc2538.lds
  CC        ../../../../../cpu/cc2538/./startup-gcc.c
  CC        ../../../../../apps/mqtt/mqtt.c
  CC        ../../../../../platform/zoul/dev/adc-zoul.c
  ...
  ...
  ...
  CC        ./internals/mqtt-sensors.c
  CC        ./internals/mqtt-res.c
  CC        ./cloud/ubidots.c
  CC        ./device/ubidots_demo.c
  LD        mqtt-client.elf
arm-none-eabi-objcopy -O binary --gap-fill 0xff mqtt-client.elf mqtt-client.bin
Flashing /dev/ttyUSB0
Opening port /dev/ttyUSB0, baud 460800
Reading data from mqtt-client.bin
Firmware file: Raw Binary
Connecting to target...
CC2538 PG2.0: 512KB Flash, 32KB SRAM, CCFG at 0x0027FFD4
Primary IEEE Address: 00:12:4B:00:06:0D:B3:3C
Erasing 524288 bytes starting at address 0x00200000
    Erase done
Writing 516096 bytes starting at address 0x00202000
Write 8 bytes at 0x0027FFF8F00
    Write done                                
Verifying by comparing CRC32 calculations.
    Verified (match: 0x2fe9a913)
rm obj_zoul/ubidots.o obj_zoul/startup-gcc.o mqtt-client.co obj_zoul/ubidots_demo.o

When the RE-Mote is connected with Router on Sensor tab the device is listed:


Ubidots Dashboard

Once connected RE-Mote with Orion, Ubidots automaticatly create variables and Dashboad

Other information

Get Code

Quickstart Guide

MQTT client

Diferents communication Protocols:

Diferents open source Operative Systems :

Clone this wiki locally