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

Commit 061514a

Browse files
committed
updated all examples
1 parent 251e5a1 commit 061514a

File tree

4 files changed

+27
-35
lines changed

4 files changed

+27
-35
lines changed

examples/FirebaseDemo_ESP8266/FirebaseDemo_ESP8266.ino

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@
2828

2929
void setup() {
3030
Serial.begin(9600);
31-
if (password != "") {
32-
WiFi.begin(ssid.c_str(), password.c_str());
33-
} else {
34-
WiFi.begin(ssid.c_str());
35-
}
3631

32+
// connect to wifi.
33+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
3734
Serial.print("connecting");
3835
while (WiFi.status() != WL_CONNECTED) {
3936
Serial.print(".");
@@ -42,8 +39,7 @@ void setup() {
4239
Serial.println();
4340
Serial.print("connected: ");
4441
Serial.println(WiFi.localIP());
45-
46-
ConnectWifi(WIFI_SSID, WIFI_PASSWORD);
42+
4743
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
4844
}
4945

examples/FirebaseRoom_ESP8266/FirebaseRoom_ESP8266.ino

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include <ESP8266WiFi.h>
2121
#include <FirebaseArduino.h>
2222

23+
// Set these to run example.
24+
#define FIREBASE_HOST "example.firebaseio.com"
25+
#define FIREBASE_AUTH "token_or_secret"
26+
#define WIFI_SSID "SSID"
27+
#define WIFI_PASSWORD "PASSWORD"
28+
2329
const int grovePowerPin = 15;
2430
const int vibratorPin = 5;
2531
const int lightSensorPin = A0;
@@ -29,8 +35,6 @@ const int fanPin = 13;
2935

3036
void setup() {
3137
Serial.begin(9600);
32-
ConnectWifi(WIFI_SSID, WIFI_PASSWORD);
33-
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
3438

3539
pinMode(grovePowerPin, OUTPUT);
3640
digitalWrite(grovePowerPin, HIGH);
@@ -42,7 +46,7 @@ void setup() {
4246
pinMode(fanPin, OUTPUT);
4347

4448
// connect to wifi.
45-
WiFi.begin("SSID", "PASSWORD");
49+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
4650
Serial.print("connecting");
4751
while (WiFi.status() != WL_CONNECTED) {
4852
Serial.print(".");
@@ -52,7 +56,7 @@ void setup() {
5256
Serial.print("connected: ");
5357
Serial.println(WiFi.localIP());
5458

55-
Firebase.begin("example.firebaseio.com", "secret_or_token");
59+
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
5660
Firebase.set("pushbutton", 0);
5761
Firebase.set("sunlight", 0);
5862
Firebase.set("redlight", 0);

examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,18 @@
3636
#include <Firebase.h>
3737
#include <SerialTransceiver.h>
3838

39-
SoftwareSerial data_serial(5 /*RX*/, 4/*TX*/);
40-
firebase::modem::SerialTransceiver transceiver;
41-
4239
// Set these to run example.
4340
#define WIFI_SSID "SSID"
4441
#define WIFI_PASSWORD "PASSWORD"
4542

46-
void ConnectWifi(const String& ssid, const String& password = "") {
47-
if (password != "") {
48-
WiFi.begin(ssid.c_str(), password.c_str());
49-
} else {
50-
WiFi.begin(ssid.c_str());
51-
}
43+
SoftwareSerial data_serial(5 /*RX*/, 4/*TX*/);
44+
firebase::modem::SerialTransceiver transceiver;
5245

46+
void setup() {
47+
Serial.begin(9600);
48+
49+
// connect to wifi.
50+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
5351
Serial.print("connecting");
5452
while (WiFi.status() != WL_CONNECTED) {
5553
Serial.print(".");
@@ -58,11 +56,6 @@ void ConnectWifi(const String& ssid, const String& password = "") {
5856
Serial.println();
5957
Serial.print("connected: ");
6058
Serial.println(WiFi.localIP());
61-
}
62-
63-
void setup() {
64-
Serial.begin(9600);
65-
ConnectWifi(WIFI_SSID, WIFI_PASSWORD);
6659

6760
data_serial.begin(9600);
6861
while (!data_serial) {

examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@
2222
#include <Adafruit_GFX.h>
2323
#include <Adafruit_SSD1306.h>
2424

25+
// Set these to run example.
26+
#define WIFI_SSID "SSID"
27+
#define WIFI_PASSWORD "PASSWORD"
28+
2529
#define OLED_RESET 3
2630
Adafruit_SSD1306 display(OLED_RESET);
2731

2832
void setup() {
2933
Serial.begin(9600);
3034

35+
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
36+
display.display();
37+
38+
// connect to wifi.
39+
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
3140
Serial.print("connecting");
3241
while (WiFi.status() != WL_CONNECTED) {
3342
Serial.print(".");
@@ -36,16 +45,6 @@ void setup() {
3645
Serial.println();
3746
Serial.print("connected: ");
3847
Serial.println(WiFi.localIP());
39-
}
40-
41-
void setup() {
42-
Serial.begin(9600);
43-
ConnectWifi(WIFI_SSID, WIFI_PASSWORD);
44-
45-
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
46-
display.display();
47-
48-
stream = fbase.stream("/bitcoin/last");
4948

5049
Firebase.begin("publicdata-cryptocurrency.firebaseio.com");
5150
Firebase.stream("/bitcoin/last");

0 commit comments

Comments
 (0)