-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add owner field to AdafruitIO_Feed * remove spurious setup methods * clean up some compiler warnings * Fixing string comparison compile warnings add strcmp to property assign. * add example of feed writing * adding feed writing example, bump lib version up
- Loading branch information
Showing
15 changed files
with
358 additions
and
63 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
examples/adafruitio_20_shared_feed_write/adafruitio_20_shared_feed_write.ino
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// Adafruit IO Shared Feeds Write Example | ||
// desc: Example of writing a button value to a shared feed. | ||
// | ||
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-feeds/sharing-a-feed | ||
// | ||
// Adafruit invests time and resources providing this open source code. | ||
// Please support Adafruit and open source hardware by purchasing | ||
// products from Adafruit! | ||
// | ||
// Written by Brent Rubell for Adafruit Industries | ||
// Copyright (c) 2018 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 BUTTON_PIN 5 | ||
|
||
// the Adafruit IO username of whomever owns the feed | ||
#define FEED_OWNER "AIO_FEED_OWNER" | ||
|
||
// set up a shared feed between you and the FEED_OWNER | ||
// make sure you have both read AND write access to this feed | ||
AdafruitIO_Feed *sharedFeed = io.feed("FEED-NAME", FEED_OWNER); | ||
|
||
// button state | ||
bool current = false; | ||
bool last = false; | ||
|
||
void setup() { | ||
|
||
// set button pin as an input | ||
pinMode(BUTTON_PIN, INPUT); | ||
|
||
// start the serial connection | ||
Serial.begin(115200); | ||
|
||
// wait for serial monitor to open | ||
while(! Serial); | ||
|
||
// connect to io.adafruit.com | ||
Serial.print("Connecting to Adafruit IO"); | ||
io.connect(); | ||
|
||
// wait for a connection | ||
while(io.status() < AIO_CONNECTED) { | ||
Serial.print("."); | ||
delay(500); | ||
} | ||
|
||
// we are connected | ||
Serial.println(); | ||
Serial.println(io.statusText()); | ||
|
||
} | ||
|
||
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(); | ||
|
||
// grab the current state of the button. | ||
// we have to flip the logic because we are | ||
// using a pullup resistor. | ||
if(digitalRead(BUTTON_PIN) == LOW) | ||
current = true; | ||
else | ||
current = false; | ||
|
||
// return if the value hasn't changed | ||
if(current == last) | ||
return; | ||
|
||
// save the current state to the 'sharedFeed' feed on adafruit io | ||
Serial.print("sending button -> "); | ||
Serial.println(current); | ||
sharedFeed->save(current); | ||
|
||
// store last button state | ||
last = current; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/************************ Adafruit IO Config *******************************/ | ||
|
||
// visit io.adafruit.com if you need to create an account, | ||
// or if you need your Adafruit IO key. | ||
#define IO_USERNAME "your_username" | ||
#define IO_KEY "your_key" | ||
|
||
/******************************* WIFI **************************************/ | ||
|
||
// the AdafruitIO_WiFi client will work with the following boards: | ||
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471 | ||
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821 | ||
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405 | ||
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010 | ||
// - Feather WICED -> https://www.adafruit.com/products/3056 | ||
|
||
#define WIFI_SSID "your_ssid" | ||
#define WIFI_PASS "your_pass" | ||
|
||
// 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); | ||
|
||
|
||
/******************************* FONA **************************************/ | ||
|
||
// the AdafruitIO_FONA client will work with the following boards: | ||
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027 | ||
|
||
// uncomment the following two lines for 32u4 FONA, | ||
// and comment out the AdafruitIO_WiFi client in the WIFI section | ||
// #include "AdafruitIO_FONA.h" | ||
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY); | ||
|
||
|
||
/**************************** ETHERNET ************************************/ | ||
|
||
// the AdafruitIO_Ethernet client will work with the following boards: | ||
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201 | ||
|
||
// uncomment the following two lines for ethernet, | ||
// and comment out the AdafruitIO_WiFi client in the WIFI section | ||
// #include "AdafruitIO_Ethernet.h" | ||
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY); |
78 changes: 78 additions & 0 deletions
78
examples/adafruitio_21_feed_read/adafruitio_21_feed_read.ino
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Adafruit IO Feed Reading | ||
// Tutorial Link: https://learn.adafruit.com/adafruit-io-basics-feeds/sharing-a-feed | ||
// | ||
// Adafruit invests time and resources providing this open source code. | ||
// Please support Adafruit and open source hardware by purchasing | ||
// products from Adafruit! | ||
// | ||
// Written by Brent Rubell for Adafruit Industries | ||
// Copyright (c) 2018 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 *******************************/ | ||
|
||
// the Adafruit IO username of whomever owns the feed | ||
#define FEED_OWNER "AIO_FEED_OWNER" | ||
|
||
// set up the `sharedFeed` | ||
AdafruitIO_Feed *sharedFeed = io.feed("FEED-NAME", FEED_OWNER); | ||
|
||
void setup() { | ||
|
||
// start the serial connection | ||
Serial.begin(115200); | ||
|
||
// wait for serial monitor to open | ||
while(! Serial); | ||
|
||
// connect to io.adafruit.com | ||
Serial.print("Connecting to Adafruit IO"); | ||
io.connect(); | ||
|
||
// set up a message handler for the 'sharedFeed' feed. | ||
// the handleMessage function (defined below) | ||
// will be called whenever a message is | ||
// received from adafruit io. | ||
sharedFeed->onMessage(handleMessage); | ||
|
||
// wait for a connection | ||
while(io.status() < AIO_CONNECTED) { | ||
Serial.print("."); | ||
delay(500); | ||
} | ||
|
||
// we are connected | ||
Serial.println(); | ||
Serial.println(io.statusText()); | ||
sharedFeed->get(); | ||
|
||
} | ||
|
||
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(); | ||
|
||
} | ||
|
||
// this function is called whenever an 'sharedFeed' feed message | ||
// is received from Adafruit IO. it was attached to | ||
// the 'digital' feed in the setup() function above. | ||
void handleMessage(AdafruitIO_Data *data) { | ||
|
||
Serial.print("received <- "); | ||
Serial.println(data->toInt()); | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/************************ Adafruit IO Config *******************************/ | ||
|
||
// visit io.adafruit.com if you need to create an account, | ||
// or if you need your Adafruit IO key. | ||
#define IO_USERNAME "your_username" | ||
#define IO_KEY "your_key" | ||
|
||
/******************************* WIFI **************************************/ | ||
|
||
// the AdafruitIO_WiFi client will work with the following boards: | ||
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471 | ||
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821 | ||
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405 | ||
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010 | ||
// - Feather WICED -> https://www.adafruit.com/products/3056 | ||
|
||
#define WIFI_SSID "your_ssid" | ||
#define WIFI_PASS "your_pass" | ||
|
||
// 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); | ||
|
||
|
||
/******************************* FONA **************************************/ | ||
|
||
// the AdafruitIO_FONA client will work with the following boards: | ||
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027 | ||
|
||
// uncomment the following two lines for 32u4 FONA, | ||
// and comment out the AdafruitIO_WiFi client in the WIFI section | ||
// #include "AdafruitIO_FONA.h" | ||
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY); | ||
|
||
|
||
/**************************** ETHERNET ************************************/ | ||
|
||
// the AdafruitIO_Ethernet client will work with the following boards: | ||
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201 | ||
|
||
// uncomment the following two lines for ethernet, | ||
// and comment out the AdafruitIO_WiFi client in the WIFI section | ||
// #include "AdafruitIO_Ethernet.h" | ||
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=Adafruit IO Arduino | ||
version=2.7.9 | ||
version=2.7.10 | ||
author=Adafruit | ||
maintainer=Adafruit <[email protected]> | ||
sentence=Arduino library to access Adafruit IO. | ||
|
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
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
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
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
Oops, something went wrong.