Pack Thethings - Zolertia/Resources GitHub Wiki
Zolertia Thethings over MQTT
What do I need?
To build the application you will need:
- At least one Zolertia RE-Mote
- An Orion Router or make DIY 6lbr Firefly Ehternet Gateway
- DHT22, temperature and humidity sensor
- TSL256x Light sensor
Clone Zolertia pack repository if you don't have it already Zolertia contiki
Now we need program the binary files on Orion Router for connectivity to internet over 6lbr and create a 6LoWPAN network.
To program a device using any of this image(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 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 enable it on router.
Such that:
Submit and reset Orion Router
Hardware connection
The RE-Mote uses a 5 and 3 pins connectors, the DHT22 can be connected on ADC1, and Ligth sensor should be connectec on digital port (5 pins).
Thethings application
We are going to use two Things-tokens: One to publish data and the other to subscribe to commands and configuration changes.
The "data" token should be written in DEFAULT_CONF_AUTH_TOKEN.
The "command" token should be written in DEFAULT_CONF_AUTH_USER.
This token will include it in the header of the platform thingsio.h
#define DEFAULT_CONF_AUTH_TOKEN ""
#define DEFAULT_CONF_AUTH_USER ""
#define DEFAULT_TOPIC_STR "v2/things/"
#define DEFAULT_TOPIC_LONG DEFAULT_TOPIC_STR DEFAULT_CONF_AUTH_USER
Verify in Makefile that:
# Platform options: relayr, thingsio, bluemix, ubidots
MQTT_PLATFORM ?= thingsio
# Sensor options: fridge, coldchain, agriculture, watering, remote, coinbox,
# flowerpot, smartcities, ubidots_demo
MQTT_SENSORS ?= coldchain
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 ./cloud/thingsio.c
CC ./device/coldchain.c
CC ../../../../../cpu/cc2538/cc2538.lds
CC ../../../../../cpu/cc2538/./startup-gcc.c
CC mqtt-client.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:B2:3F
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: 0x73403e73)
rm mqtt-client.co obj_zoul/startup-gcc.o
When the RE-Mote is connected with Router on Sensor
tab the device is listed:
Thethings Dashboard
Once connected RE-Mote with Orion, Thethings.io automaticatly create a variables and Dashboad
Other information
Diferents communication Protocols:
Diferents open source Operative Systems :