Disconnected from adafruit io.
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Disconnected from adafruit io.

by Caveageman on Wed Nov 18, 2020 12:24 pm

Hi i just wanted to ask for some help, i am trying to basically do the adafruit analog out tutorial but edited for my own purposes, i think i understand it and have done some projects with similar complexity but this time im struggling to even get the nodemcu v2 to connect to adafruit io.

it connects to my network and then just prints "Disconnected from Adafruit IO." as the status over and over again.

I have copied the username and key over from adafruit io directly there seems to be something fundamental i'm doing wrong.

Code: Select all | TOGGLE FULL SIZE
// Adafruit IO Analog Out Example
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-analog-output
// Adafruit invests time and resources providing this open source code.
// Please support Adafruit and open source hardware by purchasing
// products from Adafruit!
// Written by Todd Treece for Adafruit Industries
// Copyright (c) 2016 Adafruit Industries
// Licensed under the MIT license.
// All text above must be included in any redistribution.

/************************** Configuration ***********************************/

// edit the config.h tab and enter your Adafruit IO credentials
// and any additional configuration needed for WiFi, cellular,
// or ethernet clients.
#include "config.h"

/************************ Example Starts Here *******************************/

// this should correspond to a pin with PWM capability
#define PWMA 5

// set up the 'analog' feed
AdafruitIO_Feed *train = io.feed("train");

void setup() {

  // set up led pin as an analog output
  #if defined(ARDUINO_ARCH_ESP32)
    // ESP32 pinMode()
    ledcAttachPin(LED_PIN, 1);
    ledcSetup(1, 1200, 8);
    pinMode(PWMA, OUTPUT);

  // start the serial connection

  // wait for serial monitor to open
  while(! Serial);

  // connect to io.adafruit.com
  Serial.print("Connecting to Adafruit IO");

  // set up a message handler for the 'analog' feed.
  // the handleMessage function (defined below)
  // will be called whenever a message is
  // received from adafruit io.

  // wait for a connection
  while(io.status() < AIO_CONNECTED) {

  // we are connected


void loop() {

  // io.run(); is required for all sketches.
  // it should always be present at the top of your loop
  // function. it keeps the client connected to
  // io.adafruit.com, and processes any incoming data.


// this function is called whenever an 'analog' message
// is received from Adafruit IO. it was attached to
// the analog feed in the setup() function above.
void handleMessage(AdafruitIO_Data *data) {

  // convert the data to integer
  int reading = data->toInt();

  Serial.print("received <- ");

  // write the current 'reading' to the led
  #if defined(ARDUINO_ARCH_ESP32)
    ledcWrite(1, reading); // ESP32 analogWrite()
    analogWrite(PWMA, reading);


The config.h just contains my wifi and adafruit log in information.

The feed is labeled correctly as "train"

any help would be great, thank you

Posts: 1
Joined: Wed Nov 18, 2020 11:58 am

Re: Disconnected from adafruit io.

by brubell on Fri Nov 20, 2020 5:49 pm

Which NodeMCU are you using? Could you post a link to where you purchased it?

Do you ever see the board under Connections on http://io.adafruit.com/monitor?

Posts: 1417
Joined: Fri Jul 17, 2015 10:33 pm

Please be positive and constructive with your questions and comments.