Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit e643dcb

Browse files
committed
Merge pull request #112 from proppy/room
examples: add room example
2 parents 67baaeb + a46ca74 commit e643dcb

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ script:
2929
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino
3030
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/Firebase_ESP8266_LEDs/Firebase_ESP8266_Neopixel/Firebase_ESP8266_Neopixel.ino
3131
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino
32+
- ${ARDUINO_ROOT}/arduino-builder -verbose -hardware ${ARDUINO_ROOT}/hardware/ -tools ${ARDUINO_ESP8266_ROOT}/tools/ -tools ${ARDUINO_ROOT}/tools-builder/ -fqbn esp8266com:esp8266:nodemcuv2 -libraries ${ARDUINO_HOME}/libraries/ -prefs build.flash_ld=${ARDUINO_ESP8266_ROOT}/tools/sdk/ld/eagle.flash.4m.ld -prefs build.flash_freq=40 -prefs build.flash_size=4M examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino
3233
- ( cd test && make check )
3334
- ( cd test/modem/ && make test )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// Copyright 2015 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
// FirebaseRoom_ESP8266 is a sample that demo using multiple sensors
18+
// and actuactor with the FirebaseArduino library.
19+
20+
#include <ESP8266WiFi.h>
21+
#include <FirebaseArduino.h>
22+
23+
void setup() {
24+
Serial.begin(9600);
25+
26+
// power grove connector
27+
pinMode(15, OUTPUT);
28+
digitalWrite(15, HIGH);
29+
30+
// pin 5 is connected to a vibrator motor.
31+
pinMode(5, OUTPUT);
32+
// pin A0 is connected to a light sensor.
33+
pinMode(A0, INPUT);
34+
// pin 12 is connected to a red LED.
35+
pinMode(12, OUTPUT);
36+
// pin 14 is connected to a push button.
37+
pinMode(14, INPUT);
38+
// pin 13 is connected to a fan.
39+
pinMode(13, OUTPUT);
40+
41+
// connect to wifi.
42+
WiFi.begin("SSID", "PASSWORD");
43+
Serial.print("connecting");
44+
while (WiFi.status() != WL_CONNECTED) {
45+
Serial.print(".");
46+
delay(500);
47+
}
48+
Serial.println();
49+
Serial.print("connected: ");
50+
Serial.println(WiFi.localIP());
51+
52+
Firebase.begin("example.firebaseio.com", "secret_or_token");
53+
}
54+
55+
int button = 0;
56+
float light = 0.0;
57+
58+
void loop() {
59+
digitalWrite(12, (int)Firebase.get("redlight"));
60+
digitalWrite(13, (int)Firebase.get("cooldown"));
61+
digitalWrite(5, (int)Firebase.get("brrr"));
62+
int newButton = digitalRead(14);
63+
if (newButton != button) {
64+
button = newButton;
65+
Firebase.set("pushbutton", button);
66+
}
67+
float newLight = analogRead(A0);
68+
if (abs(newLight - light) > 100) {
69+
light = newLight;
70+
Firebase.set("sunlight", light);
71+
}
72+
}

0 commit comments

Comments
 (0)