Adafruit IO

In order to use Adafruit IO online service, a "Generic MQTT server" library is required. The sequence of steps to onboard with Adafruit IO is outlined below.

Prerequisites:

  • ESP8266 NodeMCU or ESP32 DevKitC boards
  • Adafruit IO account

Onboarding sequence

  • Run mos tool and install Mongoose OS.
  • Open init.js and enter this code:

    load('api_config.js');
    load('api_gpio.js');
    load('api_mqtt.js');
    load('api_sys.js');
    
    GPIO.set_button_handler(0, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200, function() {
      let topic = Cfg.get('mqtt.user') + '/feeds/ram';
      let message = JSON.stringify(Sys.free_ram());
      let ok = MQTT.pub(topic, message, 1);
      print('Published:', ok ? 'yes' : 'no', 'topic:', topic, 'message:', message);
    }, null);
    
  • Open the configuration tab. Enable MQTT, set server / user / password, click save:

  • Switch to the expert mode, set debug topics and disable rpc.mqtt, click save:

  • In the Adafruit MQTT, create "ram" feed:

  • Click on "flash" button on your device, that will publish to that feed:

    Published: yes topic: lsm/feeds/ram message: 37656 
    Published: yes topic: lsm/feeds/ram message: 37656 
    Published: yes topic: lsm/feeds/ram message: 37656
    
  • See Graph on Adafruit dash updated: