CC3220SF LaunchPad is a low-cost IoT development board designed by Texas Instruments. It has buttons, LEDs, onboard Bosch BMA222 accelerometer and onboard TI TMP006 temperature sensor. This tutorial provides the easiest way to start IoT development with CC3220, Mongoose OS and Google IoT Core, and covers the following:
mos
tool on your computerIn this tutorial, we'll send a message to Google IoT Core on a button press.
mos
Web UI, open the
init.js
fileload('api_config.js');
load('api_gpio.js');
load('api_timer.js');
load('api_mqtt.js');
let topic = '/devices/' + Cfg.get('device.id') + '/state';
let pin = Cfg.get('pins.button');
GPIO.set_mode(pin, GPIO.MODE_INPUT);
GPIO.set_pull(pin, GPIO.PULL_DOWN);
GPIO.set_button_handler(pin, GPIO.PULL_DOWN, GPIO.INT_EDGE_NEG, 200, function() {
let msg = JSON.stringify({ time: Timer.now() });
let ok = MQTT.pub(topic, msg, 1);
print(ok, msg);
}, null);
mos put fs/init.js
command, then
mos call Sys.Reboot
.
Wait until device reboots.
iot-registry
registry, click on your device, and then on "Configuration and state history"
tab
In this tutorial, we'll implement remote LED control using Google IoT core config object.
mos
Web UI, open the
init.js
fileload('api_config.js');
load('api_gpio.js');
load('api_mqtt.js');
let topic = '/devices/' + Cfg.get('device.id') + '/config';
let led = Cfg.get('pins.led');
GPIO.set_mode(led, GPIO.MODE_OUTPUT);
MQTT.sub(topic, function(conn, topic, msg) {
print('Topic:', topic, 'message:', msg);
let obj = JSON.parse(msg) || { on: false };
GPIO.write(led, obj.on ? 1 : 0);
}, null);
iot-registry
registry, click on your device, and then on "Configuration and state history"
tab
{"on": true}
, click "Send to Device"