Only 5 boxes in Dashboard?
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.

Only 5 boxes in Dashboard?

by pyremage on Mon Feb 01, 2016 1:09 pm

I have created a project that is using the CC3k, Seeedstudio 4 channel relay board v1, and an UNO. I have interfaced it with the AIO service. I can toggle any of the four relays from the Dashboard and they will react about 80% of the time - which is up from the 40% or so I was getting at first. Because of the unpredictability of the switching, I want to introduce feedback so I will KNOW if the relay is active or not; so I am publishing back whether or not a line is active.
My problems are:
1. AIO is not reading the publication correctly and posting to the gauge. AIO is seeing the data stream coming in but is not acting on it. (The incoming data is either a 0 or 1.)
2. I have created 4 switch toggles and a single gauge in the dashboard, but can not add any more gauges to show the condition of the other three relays, AIO simply does not react when I press the CREATE button. I have tried in Firefox and IE11 to no avail.

I am posting the code below, though I really don't think the problem is there...

Thanks for your consideration!

Code: Select all | TOGGLE FULL SIZE
  Adafruit MQTT Library CC3000 Example

  Designed specifically to work with the Adafruit WiFi products:
  ----> https://www.adafruit.com/products/1469

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
#include <Adafruit_SleepyDog.h>
#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "utility/debug.h"
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_CC3000.h"

/*************************** CC3000 Pins ***********************************/

#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5  // VBAT & CS can be any digital pins.
#define ADAFRUIT_CC3000_CS    10
// Use hardware SPI for the remaining pins
// On an UNO, SCK = 13, MISO = 12, and MOSI = 11

/************************* WiFi Access Point *********************************/

#define WLAN_SSID       "PyresWiFi_C"  // can't be longer than 32 characters!
#define WLAN_PASS       "Not4YourEyeZ"
                                       //         WLAN_SEC_WPA or WLAN_SEC_WPA2

/************************* Adafruit.io Setup *********************************/

#define AIO_SERVER      "io.adafruit.com"
#define AIO_SERVERPORT  1883
#define AIO_USERNAME    "pyremage"
#define AIO_KEY         "mykeyinsertedhere...nopeeking!"

/************ Global State (you don't need to change this!) ******************/

// Setup the main CC3000 class, just like a normal CC3000 sketch.
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT);

// Store the MQTT server, username, and password in flash memory.
// This is required for using the Adafruit MQTT library.

// Setup the CC3000 MQTT class by passing in the CC3000 class and MQTT server and login details.

// You don't need to change anything below this line!
#define halt(s) { Serial.println(F( s )); while(1);  }

// CC3000connect is a helper function that sets up the CC3000 and connects to
// the WiFi network. See the cc3000helper.cpp tab above for the source!
boolean CC3000connect(const char* wlan_ssid, const char* wlan_pass, uint8_t wlan_security);

/****************************** Feeds ***************************************/

// Setup a feed called 'relayin1' for publishing.
// Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname>
const char RELAYIN1_FEED[] PROGMEM = AIO_USERNAME "/feeds/relayin1";
Adafruit_MQTT_Publish relayin1 = Adafruit_MQTT_Publish(&mqtt, RELAYIN1_FEED);
const char RELAYIN2_FEED[] PROGMEM = AIO_USERNAME "/feeds/relayin2";
Adafruit_MQTT_Publish relayin2 = Adafruit_MQTT_Publish(&mqtt, RELAYIN2_FEED);
const char RELAYIN3_FEED[] PROGMEM = AIO_USERNAME "/feeds/relayin3";
Adafruit_MQTT_Publish relayin3 = Adafruit_MQTT_Publish(&mqtt, RELAYIN3_FEED);
const char RELAYIN4_FEED[] PROGMEM = AIO_USERNAME "/feeds/relayin4";
Adafruit_MQTT_Publish relayin4 = Adafruit_MQTT_Publish(&mqtt, RELAYIN4_FEED);

// Setup a feed called 'onoff' for subscribing to changes.
const char RELAY1_FEED[] PROGMEM = AIO_USERNAME "/feeds/relay1";
Adafruit_MQTT_Subscribe onoffbutton1 = Adafruit_MQTT_Subscribe(&mqtt, RELAY1_FEED);
const char RELAY2_FEED[] PROGMEM = AIO_USERNAME "/feeds/relay2";
Adafruit_MQTT_Subscribe onoffbutton2 = Adafruit_MQTT_Subscribe(&mqtt, RELAY2_FEED);
const char RELAY3_FEED[] PROGMEM = AIO_USERNAME "/feeds/relay3";
Adafruit_MQTT_Subscribe onoffbutton3 = Adafruit_MQTT_Subscribe(&mqtt, RELAY3_FEED);
const char RELAY4_FEED[] PROGMEM = AIO_USERNAME "/feeds/relay4";
Adafruit_MQTT_Subscribe onoffbutton4 = Adafruit_MQTT_Subscribe(&mqtt, RELAY4_FEED);

/*************************** Setup Relays ***********************************/
int Relay1Control = 6;    // Digital Arduino Pin used to control the Relay 1
int Relay2Control = 7;    // Digital Arduino Pin used to control the Relay 2
int Relay3Control = 8;    // Digital Arduino Pin used to control the Relay 3
int Relay4Control = 9;    // Digital Arduino Pin used to control the Relay 4

/*************************** Sketch Code ************************************/

void setup() {
    pinMode(Relay1Control, OUTPUT);
    pinMode(Relay2Control, OUTPUT);
    pinMode(Relay3Control, OUTPUT);
    pinMode(Relay4Control, OUTPUT);

  Serial.println(F("Pyre's Relay MQTT demo"));

  Serial.print(F("Free RAM: ")); Serial.println(getFreeRam(), DEC);

  // Initialise the CC3000 module
  Serial.print(F("\nInit the CC3000..."));
  if (!cc3000.begin())


  while (! CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Retrying WiFi"));

uint32_t x=0;

void loop() {
  // Make sure to reset watchdog every loop iteration!

  // Ensure the connection to the MQTT server is alive (this will make the first
  // connection and automatically reconnect when disconnected).  See the MQTT_connect
  // function definition further below.

  // this is our 'wait for incoming subscription packets' busy subloop
  Adafruit_MQTT_Subscribe *subscription;
  while ((subscription = mqtt.readSubscription(1000))) {
    if (subscription == &onoffbutton1) {
      char *value = (char *)onoffbutton1.lastread;
      Serial.print(F("Got: "));
      Serial.println((char *)onoffbutton1.lastread);
      int current = atoi(value);
      digitalWrite(Relay1Control, current == 1 ? HIGH : LOW);

    if (subscription == &onoffbutton2) {
      char *value = (char *)onoffbutton2.lastread;
      Serial.print(F("Got: "));
      Serial.println((char *)onoffbutton2.lastread);
      int current = atoi(value);
      digitalWrite(Relay2Control, current == 1 ? HIGH : LOW);
        if (subscription == &onoffbutton3) {
      char *value = (char *)onoffbutton3.lastread;
      Serial.print(F("Got: "));
      Serial.println((char *)onoffbutton3.lastread);
      int current = atoi(value);
      digitalWrite(Relay4Control, current == 1 ? HIGH : LOW);
        if (subscription == &onoffbutton4) {
      char *value = (char *)onoffbutton4.lastread;
      Serial.print(F("Got: "));
      Serial.println((char *)onoffbutton4.lastread);
      int current = atoi(value);
      digitalWrite(Relay3Control, current == 1 ? HIGH : LOW);
  // Now we can publish stuff!
  int digiread1 = digitalRead(6);
  Serial.print(F("\nSending Relay 1 val "));
  if (! relayin1.publish(x)) {
  } else {
  int digiread2 = digitalRead(7);
  Serial.print(F("\nSending Relay 2 val "));
  if (! relayin2.publish(x)) {
  } else {
    int digiread3 = digitalRead(9);
  Serial.print(F("\nSending Relay 3 val "));
  if (! relayin3.publish(x)) {
  } else {
    int digiread4 = digitalRead(8);
  Serial.print(F("\nSending Relay 4 val "));
  if (! relayin1.publish(x)) {
  } else {

  // ping the server to keep the mqtt connection alive
  // if(! mqtt.ping()) {
  // Serial.println(F("MQTT Ping failed."));
  // }

// Function to connect and reconnect as necessary to the MQTT server.
// Should be called in the loop function and it will take care if connecting.
void MQTT_connect() {
  int8_t ret;

  // Stop if already connected.
  if (mqtt.connected()) {

  Serial.print("Connecting to MQTT... ");

  while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected
       if (ret < 0)
            CC3000connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY);  // y0w, lets connect to wifi again
       Serial.println("Retrying MQTT connection in 5 seconds...");
       delay(5000);  // wait 5 seconds
  Serial.println("MQTT Connected!");

Posts: 18
Joined: Mon Aug 27, 2012 10:05 am

Re: Only 5 boxes in Dashboard?

by pyremage on Mon Feb 01, 2016 3:27 pm

As of 1300CST additional boxes were able to be added; following server downtime.

Feeds still do not show incoming data in gauges, though, the FEEDS page does show constant updates.

Posts: 18
Joined: Mon Aug 27, 2012 10:05 am

Re: Only 5 boxes in Dashboard?

by pyremage on Mon Feb 01, 2016 3:54 pm

It would seem that even though I appear to be sending a value of 1 to the AIO it is receiving it as a 0 and, thus, not showing any change in the gauge. I would think it should just show the value sent; how else is there to do it?

Posts: 18
Joined: Mon Aug 27, 2012 10:05 am

Please be positive and constructive with your questions and comments.