Created
January 8, 2018 21:16
-
-
Save abachman/c6b6c0c98666f28542939fa3f48131fb to your computer and use it in GitHub Desktop.
ATWINC1500 Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adafruit IO Publish Example | |
// | |
// 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 int will hold the current count for our sketch | |
int count = 0; | |
// set up the 'counter' feed | |
AdafruitIO_Feed *counter = io.feed("counter"); | |
AdafruitIO_Feed *messages = io.feed("messages"); | |
#define PIN 13 | |
void blip() { | |
for (int i=0; i<5; i++) { | |
digitalWrite(PIN, HIGH); | |
delay(100); | |
digitalWrite(PIN, LOW); | |
delay(100); | |
} | |
} | |
void setup() { | |
pinMode(PIN, OUTPUT); | |
// From guide at https://learn.adafruit.com/adafruit-feather-m0-wifi-atwinc1500/using-the-wifi-module | |
// Configure pins for Adafruit ATWINC1500 Feather | |
WiFi.setPins(8,7,4,2); | |
// start the serial connection | |
Serial.begin(115200); | |
// wait for serial monitor to open | |
// while(! Serial); | |
Serial.print("Connecting to Adafruit IO"); | |
// connect to io.adafruit.com | |
io.connect(); | |
// wait for a connection | |
while(io.status() < AIO_CONNECTED) { | |
Serial.print("."); | |
delay(500); | |
} | |
// we are connected | |
Serial.println(); | |
Serial.println(io.statusText()); | |
String now = String(millis()); | |
messages->save("ATWINC1500 connected after " + now); | |
} | |
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. | |
io.run(); | |
String val = String(millis()) + " ATWINC1500 " + String(count); | |
// save count to the 'counter' feed on Adafruit IO | |
Serial.println(val); | |
counter->save(val); | |
blip(); | |
// increment the count by 1 | |
count++; | |
// wait one second (1000 milliseconds == 1 second) | |
delay(60000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************* WIFI **************************************/ | |
#define WIFI_SSID "xxx" | |
#define WIFI_PASS "xxx" | |
/************************* Adafruit.io Setup *********************************/ | |
#define IO_USERNAME "xxx" | |
#define IO_KEY "xxx" | |
// comment out the following two lines if you are using fona or ethernet | |
#include "AdafruitIO_WiFi.h" | |
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment