Showing posts with label MQTT. Show all posts
Showing posts with label MQTT. Show all posts

Tuesday, April 24, 2018

How to setup Mosquitto on Raspberry Pi and make Contiki/Contiki-NG cc26xx-web-demo do mqtt publish to it.

The following steps show you how to setup Mosquitto on Raspberry Pi and make Contiki/Contiki-NG cc26xx-web-demo do mqtt publish to it.

1. Login to Raspberry Pi and do the following steps to install Mosquitto.
  • 1.1 Run "apt-get update" and "apt-get install mosquitto" to install Mosquitto server.
  • 2.2 Run "apt-get install mosquitto-clients" to install mosquitto_sub and mosquitto_pub.
2. Follow steps in How to configure 6lbr to make it can do ping6 to a CC26xx/CC13xx node from Raspberry Pi running 6lbr to setup 6lbr in bridge router mode.

3. Do "ifconfig" to get br0 IPv6 address. In my case, it's "bbbb::e786:9d85:9446:709".


4. Go to cc26xx-web-demo MQTT/IBM Cloud Config page and set "bbbb::e786:9d85:9446:709" as broker IP.


5. Open another ssh login to Raspberry pi and run "mosquitto_sub -h bbbb::e786:9d85:9446:709 -t iot-2/evt/status/fmt/json" to subscribe to ccx6xx-web-demo publish topic. You should be it receives cc26xx-web-demo published MQTT messages.


p.s. You can also use "mosquitto_pub -h bbbb::e786:9d85:9446:709 -p 1883 -t iot-2/evt/status/fmt/json -m "hello"" to test MQTT message publish from Raspberry Pi terminal.

6. The following steps show you how to toggle red led on LAUNCHXL-CC1310 or LAUNCHXL-CC2560 running cc26xx-web-demo.
  •  Use "test" as Org ID instead of "quickstart" and "123456" as Auth Token instead of empty.
  • Click "Submit" to make cc26xx-web-demo to reconnect to mqtt server.
  • Start a ssh login to raspberry pi. Use "mosquitto_pub -h bbbb::e786:9d85:9446:709 -m "1" -t iot-2/cmd/leds/fmt/json" to turn on red led, or "mosquitto_pub -h bbbb::e786:9d85:9446:709 -m "0" -t iot-2/cmd/leds/fmt/json" to turn off red led.



Tuesday, March 22, 2016

Running 6lbr on CC2538DK with ENC28J60 and make CC2650STK send sensor data to IBM MQTT quickstart service.

The following steps show how to run 6lbr on CC2538DK with ENC28J60 and make CC2650STK send sensor data to IBM MQTT quickstart service.

For CC2538DK and ENC28J60,

1. Connect CC2538DK with ENC28J60.

  • SCLK : CC2538 Port A2 (mapped to RF1.16 on P407 of SmartRF06EB)
  • MOSI : CC2538 Port A4 (mapped to RF1.18 on P407 of SmartRF06EB)
  • MISO : CC2538 Port A5 (mapped to RF1.20 on P407 of SmartRF06EB)
  • CS : CC2538 Port B5 (mapped to RF1.17 on P407 of SmartRF06EB)


2. Git 6lbr develop version from Github
 
 git clone https://github.com/cetic/6lbr
 git checkout develop

3. Build 6lbr for CC2538DK with ENC28J60

make TARGET=cc2538dk all

4. Use Flash Programmer 2 to download cetic_6lbr_router.bin (under \6lbr\examples\6lbr\bin_cc2538dk) to CC2538DK.


For CC2650STK,

1. Git Contiki from Github (refer to http://sunmaysky.blogspot.tw/search/label/Cygwin)

2. Add the following lines in project-conf.h of cc26xx-web-demo example to use nullRDC

#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC     nullrdc_driver

3. Build cc26xx-web-demo.bin for CC2650STK

make BOARD=sensortag/cc2650 cc26xx-web-demo.bin

4. Use Flash Programmer 2 to download cc26xx-web-demo.bin to CC2650STK


Enable NAT64 to make CC2650STK can report sensor data to IBM MQTT quickstart service.

1. Connect Ethernet cable to CC2538DK-ENC28J60 and power on to run 6lbr.

2. Use Firefox to open web page at [bbbb::100] and switch to Configuration page. Change channel to 25 and select all options under IP64: to on. Press Submit button to write configurations and restart 6lbr.



3. Turn on CC2650STK to make it join 6lbr. Click on the web link in sensor page.



4.In sensor web page, click "IBM Quickstart"


5. Sensor data from CC2650STK would show on IBM MQTT quickstart service.