Skip to content

Instantly share code, notes, and snippets.

@abachman
Created December 6, 2017 23:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abachman/beffec401b9ec958595e6ff915374de1 to your computer and use it in GitHub Desktop.
Save abachman/beffec401b9ec958595e6ff915374de1 to your computer and use it in GitHub Desktop.
// Adafruit IO Group Publish Test
//
// 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.
// this is the built-in LED on the Feather Huzzah (ESP8266)
#define ledPin 0
#include "config.h"
AdafruitIO_Group *group = io.group("example");
int counter_1=30;
int counter_2=60;
int counter_3=90;
void blip() {
for (int i=0; i<5; i++) {
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}
digitalWrite(ledPin, LOW);
}
void increment() {
counter_1++;
counter_2++;
counter_3++;
group->set("counter-1", counter_1);
group->set("counter-3", counter_3);
group->set("counter-2", counter_2);
group->save();
Serial.println("publish to abachman/groups/example");
blip();
}
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
blip();
Serial.println("Connecting to Adafruit IO");
io.connect();
while(io.mqttStatus() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
blip();
String now = String(millis());
}
void loop() {
io.run();
increment();
delay(15000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment