Skip to content

Commit 3a05cfc

Browse files
authored
add io home series sketch #1 (#65)
add io home series sketch #1 bump the library version for a new master release add sketch dependencies for travis build
1 parent 203cf51 commit 3a05cfc

File tree

8 files changed

+206
-2
lines changed

8 files changed

+206
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before_install:
1515
- source <(curl -SLs https://raw.githubusercontent.com/adafruit/travis-ci-arduino/master/install.sh)
1616

1717
install:
18-
- arduino --install-library "Adafruit IO Arduino","Adafruit MQTT Library","ArduinoHttpClient","Adafruit Unified Sensor","Adafruit NeoPixel","DHT sensor library"
18+
- arduino --install-library "Adafruit IO Arduino","Adafruit MQTT Library","ArduinoHttpClient","Adafruit Unified Sensor","Adafruit NeoPixel","DHT sensor library", "Adafruit BME280 Library", "Adafruit SGP30 Sensor"
1919

2020
script:
2121
# build ESP8266 target
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/************************ Adafruit IO Config *******************************/
2+
3+
// visit io.adafruit.com if you need to create an account,
4+
// or if you need your Adafruit IO key.
5+
#define IO_USERNAME "your_username"
6+
#define IO_KEY "your_key"
7+
8+
/******************************* WIFI **************************************/
9+
10+
// the AdafruitIO_WiFi client will work with the following boards:
11+
// - HUZZAH ESP8266 Breakout -> https://www.adafruit.com/products/2471
12+
// - Feather HUZZAH ESP8266 -> https://www.adafruit.com/products/2821
13+
// - Feather HUZZAH ESP32 -> https://www.adafruit.com/product/3405
14+
// - Feather M0 WiFi -> https://www.adafruit.com/products/3010
15+
// - Feather WICED -> https://www.adafruit.com/products/3056
16+
17+
#define WIFI_SSID "your_ssid"
18+
#define WIFI_PASS "your_pass"
19+
20+
// comment out the following two lines if you are using fona or ethernet
21+
#include "AdafruitIO_WiFi.h"
22+
AdafruitIO_WiFi io(IO_USERNAME, IO_KEY, WIFI_SSID, WIFI_PASS);
23+
24+
25+
/******************************* FONA **************************************/
26+
27+
// the AdafruitIO_FONA client will work with the following boards:
28+
// - Feather 32u4 FONA -> https://www.adafruit.com/product/3027
29+
30+
// uncomment the following two lines for 32u4 FONA,
31+
// and comment out the AdafruitIO_WiFi client in the WIFI section
32+
// #include "AdafruitIO_FONA.h"
33+
// AdafruitIO_FONA io(IO_USERNAME, IO_KEY);
34+
35+
36+
/**************************** ETHERNET ************************************/
37+
38+
// the AdafruitIO_Ethernet client will work with the following boards:
39+
// - Ethernet FeatherWing -> https://www.adafruit.com/products/3201
40+
41+
// uncomment the following two lines for ethernet,
42+
// and comment out the AdafruitIO_WiFi client in the WIFI section
43+
// #include "AdafruitIO_Ethernet.h"
44+
// AdafruitIO_Ethernet io(IO_USERNAME, IO_KEY);
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// Adafruit IO House: Lights and Temperature
2+
//
3+
// Learn Guide: https://learn.adafruit.com/adafruit-io-house-lights-and-temperature
4+
//
5+
// Adafruit invests time and resources providing this open source code.
6+
// Please support Adafruit and open source hardware by purchasing
7+
// products from Adafruit!
8+
//
9+
// Written by Brent Rubell for Adafruit Industries
10+
// Copyright (c) 2018 Adafruit Industries
11+
// Licensed under the MIT license.
12+
//
13+
// All text above must be included in any redistribution.
14+
15+
/************************** Configuration ***********************************/
16+
17+
// edit the config.h tab and enter your Adafruit IO credentials
18+
// and any additional configuration needed for WiFi, cellular,
19+
// or ethernet clients.
20+
#include "config.h"
21+
22+
// include the NeoPixel library
23+
#include "Adafruit_NeoPixel.h"
24+
25+
// include the si7021 library
26+
#include "Adafruit_Si7021.h"
27+
/************************ Example Starts Here *******************************/
28+
29+
// pin the NeoPixel strip is connected to
30+
#define STRIP_PIN 12
31+
// pin the NeoPixel Jewel is connected to
32+
#define JEWEL_PIN 2
33+
34+
// amount of neopixels on the NeoPixel strip
35+
#define STRIP_PIXEL_COUNT 34
36+
// amount of neopixels on the NeoPixel jewel
37+
#define JEWEL_PIXEL_COUNT 7
38+
39+
// type of neopixels used by the NeoPixel strip and jewel.
40+
#define PIXEL_TYPE NEO_GRB + NEO_KHZ800
41+
42+
// main loop() delay, in seconds
43+
#define TEMP_DELAY 7
44+
45+
// Temperature and Humidity: Si7021 Sensor
46+
int temperatureData;
47+
int humidityData;
48+
49+
// initalize neopixel strip
50+
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIP_PIXEL_COUNT, STRIP_PIN, PIXEL_TYPE);
51+
// initalize neopixel jewel
52+
Adafruit_NeoPixel jewel = Adafruit_NeoPixel(JEWEL_PIXEL_COUNT, JEWEL_PIN, PIXEL_TYPE);
53+
54+
// initalize the sensor object
55+
Adafruit_Si7021 sensor = Adafruit_Si7021();
56+
57+
// set up the Adafruit IO feeds
58+
AdafruitIO_Feed *indoorLights = io.feed("indoor-lights");
59+
AdafruitIO_Feed *outdoorLights = io.feed("outdoor-lights");
60+
AdafruitIO_Feed *humidity = io.feed("humidity");
61+
AdafruitIO_Feed *temperature = io.feed("temperature");
62+
63+
void setup() {
64+
65+
// start the serial connection
66+
Serial.begin(115200);
67+
68+
// wait for serial monitor to open
69+
while(! Serial);
70+
71+
// connect to io.adafruit.com
72+
Serial.print("Connecting to Adafruit IO");
73+
io.connect();
74+
75+
// subscribe to lighting feeds and register message handlers
76+
indoorLights->onMessage(indoorLightHandler);
77+
outdoorLights->onMessage(outdoorLightHandler);
78+
79+
80+
// wait for a connection
81+
while(io.status() < AIO_CONNECTED) {
82+
Serial.print(".");
83+
delay(500);
84+
}
85+
86+
// we are connected
87+
Serial.println();
88+
Serial.println(io.statusText());
89+
90+
// initalize the Si7021 sensor
91+
if (!sensor.begin()) {
92+
Serial.println("Did not find Si7021 sensor!");
93+
while (true);
94+
}
95+
Serial.println("Si7021 sensor set up!");
96+
97+
// initalize the neopixel strip and jewel.
98+
strip.begin();
99+
jewel.begin();
100+
101+
// set all neopixels on the strip and jewel to `off`.
102+
strip.show();
103+
jewel.show();
104+
}
105+
106+
void loop() {
107+
// io.run(); is required for all sketches.
108+
// it should always be present at the top of your loop
109+
// function. it keeps the client connected to
110+
// io.adafruit.com, and processes any incoming data.
111+
io.run();
112+
113+
temperatureData = sensor.readTemperature() * 1.8 + 32;
114+
humidityData = sensor.readHumidity();
115+
116+
117+
Serial.print("-> Sending Temperature to Adafruit IO: ");
118+
Serial.println(temperatureData);
119+
Serial.print("-> Sending Humidity to Adafruit IO: ");
120+
Serial.println(humidityData);
121+
122+
// send the state of the feed to adafruit io
123+
temperature->save(temperatureData);
124+
humidity->save(humidityData);
125+
126+
// delay the loop to avoid flooding Adafruit IO
127+
delay(1000*TEMP_DELAY);
128+
}
129+
130+
void indoorLightHandler(AdafruitIO_Data *data) {
131+
Serial.print("-> indoor light HEX: ");
132+
Serial.println(data->value());
133+
134+
long color = data->toNeoPixel();
135+
136+
// set the color of each NeoPixel in the jewel
137+
for(int i=0; i<JEWEL_PIXEL_COUNT; ++i) {
138+
jewel.setPixelColor(i, color);
139+
}
140+
// 'set' the neopixel jewel to the new color
141+
jewel.show();
142+
}
143+
144+
void outdoorLightHandler(AdafruitIO_Data *data) {
145+
Serial.print("-> outdoor light HEX: ");
146+
Serial.println(data->value());
147+
148+
long color = data->toNeoPixel();
149+
150+
// set the color of each NeoPixel in the strip
151+
for(int i=0; i<STRIP_PIXEL_COUNT; ++i) {
152+
strip.setPixelColor(i, color);
153+
}
154+
// 'set' the neopixel strip to the new color
155+
strip.show();
156+
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit IO Arduino
2-
version=2.7.16
2+
version=2.7.17
33
author=Adafruit
44
maintainer=Adafruit <adafruitio@adafruit.com>
55
sentence=Arduino library to access Adafruit IO.

0 commit comments

Comments
 (0)