Pelion Device Management example over 15.4 Thread for Thunderboard Sense 2 board

Dependencies:   ICM20648 BMP280 Si1133 Si7210 AMS_CCS811_gas_sensor SI7021

This example is known to work great on the following platforms:

Follow the Quick-Start instructions: https://cloud.mbed.com/quick-start

Thunderboard Sense 2

Example functionality

This example showcases the following device functionality:

  • Read onboard sensors, and report them as Pelion LWM2M resources:
    • Barometric Pressure and Temperature (BMP280)
    • Relative Humidity and Temperature (Si7021)
    • Air quality - CO2 and tVOC (CCS811)
    • Light intensity and UV level (Si1133)
    • Hall effect and Temperature (Si7210)
    • Accelerometer and Gyroscope (ICM20648)
  • It also exposes the RGB LEDs for triggering flashes in a specific color
  • On user button click, increment Pelion LWM2M button resource.

/media/uploads/screamer/pelion_st_humidity_reading.png?v=2

15.4 Thread setup

This example program requires that a Thread Border Router is available. A Border Router is a network gateway between a wireless 6LoWPAN mesh network and a backhaul network. It controls and relays traffic between the two networks. In a typical setup, a 6LoWPAN border router is connected to another router in the backhaul network (over Ethernet or a serial line) which in turn forwards traffic to/from the internet or a private company LAN, for instance.

https://raw.githubusercontent.com/ARMmbed/nanostack-border-router/f8bf21aac12c9926afba252187e2adf2525bf1eb/images/br_role.png

Instructions how to set up a Thread Border Router

Use this example with Mbed CLI

1. Import the application into your desktop:

mbed import https://os.mbed.com/teams/SiliconLabs/code/pelion-example-tbsense2

cd pelion-example-tbsense2

2. Install the CLOUD_SDK_API_KEY

mbed config -G CLOUD_SDK_API_KEY <PELION_DM_API_KEY>

For instructions on how to generate your API key, please see the documentation.

3. Initialize firmware credentials (done once per repository). You can use the following command:

mbed dm init -d "<your company name in Pelion DM>" --model-name "<product model identifier>" -q --force

If above command do not work for your Mbed CLI, please consider upgrading Mbed CLI to version 1.8.x or above.

4. Compile and program:

mbed compile -t <toolchain> -m TB_SENSE_2

(supported toolchains : GCC_ARM / ARM / IAR)

5. You can connect on a virtual terminal/COM port to the platform using:

mbed sterm -b 115200

This should give you an output similar to:

[BOOT] Mbed Bootloader
[BOOT] ARM: 00000000000000000000
[BOOT] OEM: 00000000000000000000
[BOOT] Layout: 0 90AC
[BOOT] Active firmware integrity check:
[BOOT] SHA256: 615A11A7F03B1F048573E2CB51D8C9A5DD4E6F17A7F8E79C4B64E3241FF78974
[BOOT] Version: 1553594998
[BOOT] Slot 0 is empty
[BOOT] Active firmware up-to-date
[BOOT] Application's start address: 0x10400
[BOOT] Application's jump address: 0x10FBD
[BOOT] Application's stack address: 0x20040000
[BOOT] Forwarding to application...


Starting Simple Pelion Device Management Client example
You can hold the user button during boot to format the storage and change the device identity.
Connecting to the network using 802.15.4...
Connected to the network successfully. IP address: 2001:****:****:****:****:****:****:73bc
Initializing Pelion Device Management Client...
Si7021 Electronic Serial Number:                0         15b5ffff, firmware rev 20
Registered to Pelion Device Management. Endpoint Name: 0169b91a********************01a0
                                                                 
BMP280 temp:     32.750 C,   pressure: 1030.750 [mbar]            
Si7021 temp:     27.529 C,   humidity:   24.842 %                 
Si7210 temp:     34.484 C,   field:      -0.076 [mT]              
Si1133 light:  1258.574 lux, UV level:    0.031                       
CCS811 CO2:           0 ppm, VoC:             0 ppb                   
ICM20648 acc:    -0.093 x,  -0.057 y,     0.969 z [mg]            
ICM20648 gyro:   -1.503 x,   0.122 y,    -0.771 z [mdps]          
    
Committer:
screamer
Date:
Wed Mar 27 19:05:42 2019 +0000
Revision:
7:c5ebecef1a84
Parent:
5:7d98bbf11e82
Remove unnecessary macros

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:3853978178c0 1 {
screamer 0:3853978178c0 2 "target_overrides": {
screamer 0:3853978178c0 3 "*": {
screamer 0:3853978178c0 4 "target.components_remove" : ["FLASHIAP"],
screamer 0:3853978178c0 5 "platform.stdio-baud-rate" : 115200,
screamer 0:3853978178c0 6 "platform.stdio-convert-newlines" : true,
screamer 0:3853978178c0 7 "mbed-trace.enable" : null,
screamer 0:3853978178c0 8 "nsapi.default-wifi-security" : "WPA_WPA2",
screamer 0:3853978178c0 9 "nsapi.default-wifi-ssid" : "\"SSID\"",
screamer 0:3853978178c0 10 "nsapi.default-wifi-password" : "\"Password\""
screamer 0:3853978178c0 11 },
screamer 0:3853978178c0 12 "TB_SENSE_12": {
screamer 0:3853978178c0 13 "target.components_add" : ["SPIF"],
screamer 0:3853978178c0 14 "spif-driver.SPI_MOSI" : "PK0",
screamer 0:3853978178c0 15 "spif-driver.SPI_MISO" : "PK2",
screamer 0:3853978178c0 16 "spif-driver.SPI_CLK" : "PF7",
screamer 0:3853978178c0 17 "spif-driver.SPI_CS" : "PK1",
screamer 0:3853978178c0 18 "spif-driver.SPI_FREQ" : 10000000,
screamer 0:3853978178c0 19 "target.network-default-interface-type" : "MESH",
screamer 0:3853978178c0 20 "mbed-mesh-api.thread-config-channel" : 22,
screamer 0:3853978178c0 21 "mbed-mesh-api.thread-config-panid" : "0x0700",
screamer 0:3853978178c0 22 "nsapi.default-mesh-type" : "THREAD",
screamer 0:3853978178c0 23 "nanostack.configuration" : "thread_router",
screamer 0:3853978178c0 24 "device-management.mcc_transport_mode" : 2,
screamer 0:3853978178c0 25 "mbed-client-pal.pal-dns-api-version" : 2,
screamer 0:3853978178c0 26 "nanostack-hal.event_loop_thread_stack_size": 8192,
screamer 0:3853978178c0 27 "mbed-client.event-loop-size" : 32768,
screamer 0:3853978178c0 28 "mbed-client.reconnection-count" : 6,
screamer 0:3853978178c0 29 "device-management.flash-start-address" : "0x0",
screamer 0:3853978178c0 30 "device-management.flash-size" : "(1024*1024)",
screamer 0:3853978178c0 31 "device-management.sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
screamer 0:3853978178c0 32 "device-management.sotp-section-1-size" : "(4*1024)",
screamer 0:3853978178c0 33 "device-management.sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
screamer 0:3853978178c0 34 "device-management.sotp-section-2-size" : "(4*1024)",
screamer 0:3853978178c0 35 "target.features_add" : ["BOOTLOADER"],
screamer 0:3853978178c0 36 "target.bootloader_img" : "bootloader/mbed-bootloader-TB_SENSE_12.bin",
screamer 0:3853978178c0 37 "target.restrict_size" : "0xC0000",
screamer 0:3853978178c0 38 "target.header_offset" : "0x10000",
screamer 0:3853978178c0 39 "target.app_offset" : "0x10400",
screamer 0:3853978178c0 40 "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
screamer 0:3853978178c0 41 "update-client.storage-address" : "(256*1024)",
screamer 0:3853978178c0 42 "update-client.storage-size" : "(768*1024)",
screamer 0:3853978178c0 43 "update-client.storage-locations" : "(1)",
screamer 0:3853978178c0 44 "button-pressed-state" : 0,
screamer 0:3853978178c0 45 "tests-fs-size" : "(256*1024)"
screamer 5:7d98bbf11e82 46 },
screamer 5:7d98bbf11e82 47 "TB_SENSE_12_LOWPAN": {
screamer 5:7d98bbf11e82 48 "target.components_add" : ["SPIF"],
screamer 5:7d98bbf11e82 49 "spif-driver.SPI_MOSI" : "PK0",
screamer 5:7d98bbf11e82 50 "spif-driver.SPI_MISO" : "PK2",
screamer 5:7d98bbf11e82 51 "spif-driver.SPI_CLK" : "PF7",
screamer 5:7d98bbf11e82 52 "spif-driver.SPI_CS" : "PK1",
screamer 5:7d98bbf11e82 53 "spif-driver.SPI_FREQ" : 10000000,
screamer 5:7d98bbf11e82 54 "target.network-default-interface-type" : "MESH",
screamer 5:7d98bbf11e82 55 "mbed-mesh-api.6lowpan-nd-channel" : 12,
screamer 5:7d98bbf11e82 56 "mbed-mesh-api.6lowpan-nd-panid-filter" : "0xFFFF",
screamer 5:7d98bbf11e82 57 "mbed-mesh-api.6lowpan-nd-security-mode" : "NONE",
screamer 5:7d98bbf11e82 58 "nsapi.default-mesh-type" : "LOWPAN",
screamer 5:7d98bbf11e82 59 "nanostack.configuration" : "lowpan_router",
screamer 5:7d98bbf11e82 60 "device-management.mcc_transport_mode" : 2,
screamer 5:7d98bbf11e82 61 "mbed-client-pal.pal-dns-api-version" : 2,
screamer 5:7d98bbf11e82 62 "nanostack-hal.event_loop_thread_stack_size": 8192,
screamer 5:7d98bbf11e82 63 "mbed-client.event-loop-size" : 32768,
screamer 5:7d98bbf11e82 64 "mbed-client.reconnection-count" : 6,
screamer 5:7d98bbf11e82 65 "device-management.flash-start-address" : "0x0",
screamer 5:7d98bbf11e82 66 "device-management.flash-size" : "(1024*1024)",
screamer 5:7d98bbf11e82 67 "device-management.sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
screamer 5:7d98bbf11e82 68 "device-management.sotp-section-1-size" : "(4*1024)",
screamer 5:7d98bbf11e82 69 "device-management.sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
screamer 5:7d98bbf11e82 70 "device-management.sotp-section-2-size" : "(4*1024)",
screamer 5:7d98bbf11e82 71 "target.features_add" : ["BOOTLOADER"],
screamer 5:7d98bbf11e82 72 "target.bootloader_img" : "bootloader/mbed-bootloader-TB_SENSE_12.bin",
screamer 5:7d98bbf11e82 73 "target.restrict_size" : "0xC0000",
screamer 5:7d98bbf11e82 74 "target.header_offset" : "0x10000",
screamer 5:7d98bbf11e82 75 "target.app_offset" : "0x10400",
screamer 5:7d98bbf11e82 76 "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 64*1024)",
screamer 5:7d98bbf11e82 77 "update-client.storage-address" : "(256*1024)",
screamer 5:7d98bbf11e82 78 "update-client.storage-size" : "(768*1024)",
screamer 5:7d98bbf11e82 79 "update-client.storage-locations" : "(1)",
screamer 5:7d98bbf11e82 80 "button-pressed-state" : 0,
screamer 5:7d98bbf11e82 81 "tests-fs-size" : "(256*1024)"
screamer 0:3853978178c0 82 }
screamer 0:3853978178c0 83 },
screamer 0:3853978178c0 84 "config": {
screamer 0:3853978178c0 85 "format-storage-layer-on-error": {
screamer 0:3853978178c0 86 "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
screamer 0:3853978178c0 87 "value": 1
screamer 0:3853978178c0 88 },
screamer 0:3853978178c0 89 "main-stack-size": {
screamer 0:3853978178c0 90 "value": 6000
screamer 0:3853978178c0 91 },
screamer 0:3853978178c0 92 "use-button": {
screamer 0:3853978178c0 93 "help": "Whether the target has a button",
screamer 0:3853978178c0 94 "macro_name": "USE_BUTTON",
screamer 0:3853978178c0 95 "value": true
screamer 0:3853978178c0 96 },
screamer 0:3853978178c0 97 "button-pressed-state": {
screamer 0:3853978178c0 98 "help": "Value of the button when pressed",
screamer 0:3853978178c0 99 "value": 1
screamer 0:3853978178c0 100 },
screamer 0:3853978178c0 101 "no_led": {
screamer 0:3853978178c0 102 "help": "This flag disables the heartbeat thread in tests. This is useful for platforms that don't have an LED or the LED is used for other functionality like LED on the SPI clockline etc",
screamer 0:3853978178c0 103 "value": null
screamer 0:3853978178c0 104 },
screamer 0:3853978178c0 105 "tests-fs-size": {
screamer 0:3853978178c0 106 "help": "Maximum size of the file system used for tests",
screamer 0:3853978178c0 107 "value": null
screamer 0:3853978178c0 108 }
screamer 0:3853978178c0 109 }
screamer 0:3853978178c0 110 }