diff --git a/examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino b/examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino index 64e7750a..13bb2174 100644 --- a/examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino +++ b/examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino @@ -14,16 +14,24 @@ // limitations under the License. // -// FirebaseStream_ESP8266 is a sample that stream on a firebase child -// node. +// FirebaseStream_ESP8266 is a sample that stream bitcoin price from a +// public Firebase and optionally display them on a OLED i2c screen. #include +#include +#include -Firebase fbase = Firebase("example.firebaseio.com"); +#define OLED_RESET 10 +Adafruit_SSD1306 display(OLED_RESET); + +Firebase fbase = Firebase("publicdata-cryptocurrency.firebaseio.com"); void setup() { Serial.begin(9600); + display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32) + display.display(); + // connect to wifi. WiFi.begin("SSID", "PASSWORD"); Serial.print("connecting"); @@ -35,7 +43,7 @@ void setup() { Serial.print("connected: "); Serial.println(WiFi.localIP()); - fbase.stream("/chat"); + fbase.stream("/bitcoin"); } @@ -52,6 +60,14 @@ void loop() { if (type != Firebase::Event::UNKNOWN) { Serial.print("data: "); Serial.println(event); + + // TODO(proppy): parse JSON object. + display.clearDisplay(); + display.setTextSize(1); + display.setTextColor(WHITE); + display.setCursor(0,0); + display.println(event); + display.display(); } } } \ No newline at end of file