MQTT client for IBM Bluemix

Dependencies:   HTS221 LIS3MDL LPS22HB LSM303AGR LSM6DSL MQTT VL53L0X

You are viewing an older revision! See the latest version

Configure

How to configure the project

These steps are necessary in order to compile the project for the first time.

Install the ST-LINK/V2 driver before connecting the SensorNode board to your PC the first time.

1. Download the latest ST-LINK/V2 driver

2. Extract the archive and run either dpinst_amd64.exe or dpinst_x86.exe depending on whether you are on a 64-bit machine or 32-bit machine. Follow the displayed instructions.

3. You should now have successfully installed the ST-LINK/V2 driver

Create a developer mbed account

1. This example sends data to the Quickstart page of Bluemix. It is required go to the Quickstart page.

/media/uploads/rspelta/quickstart.jpg

2. Insert the word quickstart and mark the IBM's terms. Then click on ok button.

/media/uploads/rspelta/quickstart2.jpg

Now the Bluemix is waiting data from a device.

Configure the project before to compile it

1. From the root of the project open mbed_app.json file and substitute all the text with this one:

copy & paste

{
    "config": {
        "network-interface":{
            "help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
            "value": "MESH_LOWPAN_ND"
        },
        "mesh_radio_type": {
        	"help": "options are ATMEL, MCR20, SPIRIT1, EFR32, SENSOR_NODE_SPIRIT1",
        	"value": "SENSOR_NODE_SPIRIT1"
        }
    },
    "macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\"",
			   "SPIRIT1_SPI_MOSI=PG_11",
				"SPIRIT1_SPI_MISO=PG_10",
				"SPIRIT1_SPI_SCLK=PG_9",
				"SPIRIT1_DEV_IRQ=PC_2",
				"SPIRIT1_DEV_CS=PG_12",
				"SPIRIT1_DEV_SDN=NC",
				"MQTT_URL_BROKER=\"fdff::b8ac:7cbd\"",
				"MQTT_CLIENT_ID=\"d:quickstart:sensor:quickstart\"",
				"MQTT_USERNAME=\"\"",
				"MQTT_PASSWORD=\"\"",
				"MQTT_TOPIC=\"iot-2/evt/status/fmt/json\"",
				"MQTT_SENSOR_ID=\"001\""],
    "target_overrides": {
        "*": {
        	"target.features_add": ["NANOSTACK", "NANOSTACK_FULL", "COMMON_PAL"],
            "platform.stdio-baud-rate": 9600,
            "platform.stdio-convert-newlines": true,
            "mbed-mesh-api.6lowpan-nd-channel-page": 2,
            "mbed-mesh-api.6lowpan-nd-channel": 1,
			"mbed-mesh-api.heap-size": 32300,
            "mbed-trace.enable": 0,
            "mbed-mesh-api.6lowpan-nd-security-mode": "PSK",
            "spirit1.mac-address": "{0x01, 002, 0x03, 0x04, 0x05, 0x01, 0x02, 0x03}"
        },
        "NUCLEO_F401RE": {
            "wifi-tx": "PA_11",
            "wifi-rx": "PA_12"
        },
        "NUCLEO_F411RE": {
            "wifi-tx": "PA_11",
            "wifi-rx": "PA_12"
        },
        "UBLOX_EVK_ODIN_W2": {
        "target.device_has_remove": ["EMAC"]
        }
    }
}

Now you are ready to compile the project.

Border Router

This client needs a Border Router board. Border router is a network gateway between a wireless 6LoWPAN mesh network (with nodes like the Sensor Node) and a backhaul network. It controls and relays traffic between the two networks. In this demo, a 6LoWPAN border router is connected to another router in the backhaul network over Ethernet which in turn forwards traffic to/from the internet. We have used the NUCLEO_F429ZI board with the SPIRIT module X-NUCLEO-IDS01A4.

https://github.com/architech-boards/SensorNode-documentation/raw/mbed-os-5.6/source/_static/network.jpg

Here the links to the boards:

You have to modify the boards in order to use them in this demo:

  • On the X-NUCLEO-IDS01A4:
    • Unmount resistor R4
    • Mount resistor R7
  • On the NUCLEO_F429ZI:
    • Open solder bridge SB121
    • Close solder bridge SB122

If you don't want to build the firmware of the border router you can download it here

If you want to build it by yourself please visit the github page of nanostack-border-router

NAT64

IBM Bluemix accepts devices connected via IPv4. The Sensor Node uses IPv6, so it is essential to use a NAT64 server in order to translate the IPv6 packets to IPv4 packets. We let disponible for you a virtual machine with NAT64 enabled. All you have to do is configure from the network settings window of the virutal machine, the second network card as bridged to the ethernet driver and the first one to the WIFI driver. Once it will run, connect with an ethernet cable your PC to the Border Router. All the network traffic will flow from the ethernet to the your wifi connected to the internet.

/media/uploads/rspelta/network.jpg

Now you are ready to run the example. Please read this page


All wikipages