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:

  1. Connect the device to your computer with a micro-USB cable
  2. Follow installation instructions to install mos tool on your computer
  3. Follow the Quickstart guide and finish steps 1-7. That should leave you with the device connected to your WiFi network
  4. Follow the Google IoT Core configuration instructions
Troubleshooting: post on Mongoose OS forum or talk on Mongoose OS chat

In this tutorial, we'll send a message to Google IoT Core on a button press.

  1. From the mos Web UI, open the init.js file
  2. Copy/paste the following code:
    load('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);
  3. Run mos put fs/init.js command, then mos call Sys.Reboot . Wait until device reboots.
  4. Press on a push button to send a message.
  5. Open Google IoT Core console in another browser tab, go to the iot-registry registry, click on your device, and then on "Configuration and state history" tab
  6. Click refresh button, click on State, and choose Text representation.

In this tutorial, we'll implement remote LED control using Google IoT core config object.

  1. In the mos Web UI, open the init.js file
  2. Copy/paste the following code:
    load('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);
  3. Click the upload button. Wait until device reboots.
  4. Press on a push button to send a message.
  5. Open Google IoT Core console in another browser tab, go to the iot-registry registry, click on your device, and then on "Configuration and state history" tab
  6. Click on "Update Config" Button. Enter {"on": true}, click "Send to Device"
  7. Notice the log message from a device, and LED changing its color.
  8. Update the config several times, change "on" from true to false and back, see how device reacts.