A project log for Ventil-IoT-ion

Fighting moisture with the IoT

PeroPero 11/21/2017 at 22:450 Comments

Complete code so far:

// Adafruit IO Digital Output Example
// Tutorial Link:
// 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 *******************************/

// digital pin 5
#define LED_PIN 0
#define ventilator 5

// set up the 'digital' feed
AdafruitIO_Feed *digital = io.feed("xxxxx");
AdafruitIO_Feed *state = io.feed("yyyyy");

void setup() {

  // set led pin as a digital output
  pinMode(LED_PIN, OUTPUT);
  pinMode(ventilator, OUTPUT);

  // connect to

  // set up a message handler for the 'digital' 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) {
   digitalWrite(LED_PIN, LOW);  // toggle LED during connecting phase
   digitalWrite(LED_PIN, HIGH);

  // we are connected
   digitalWrite(LED_PIN, LOW);
   digitalWrite(LED_PIN, HIGH);

void loop() {

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


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

  // write the current state to the led
  digitalWrite(ventilator, data->toPinLevel());