14
14
// limitations under the License.
15
15
//
16
16
17
- // FirebaseStream_ESP8266 is a sample that stream on a firebase child
18
- // node .
17
+ // FirebaseStream_ESP8266 is a sample that stream bitcoin price from a
18
+ // public Firebase and optionally display them on a OLED i2c screen .
19
19
20
20
#include < Firebase.h>
21
+ #include < Adafruit_GFX.h>
22
+ #include < Adafruit_SSD1306.h>
21
23
22
- Firebase fbase = Firebase(" example.firebaseio.com" );
24
+ #define OLED_RESET 10
25
+ Adafruit_SSD1306 display (OLED_RESET);
26
+
27
+ Firebase fbase = Firebase(" publicdata-cryptocurrency.firebaseio.com" );
23
28
24
29
void setup () {
25
30
Serial.begin (9600 );
26
31
32
+ display.begin (SSD1306_SWITCHCAPVCC, 0x3C ); // initialize with the I2C addr 0x3C (for the 128x32)
33
+ display.display ();
34
+
27
35
// connect to wifi.
28
36
WiFi.begin (" SSID" , " PASSWORD" );
29
37
Serial.print (" connecting" );
@@ -35,7 +43,7 @@ void setup() {
35
43
Serial.print (" connected: " );
36
44
Serial.println (WiFi.localIP ());
37
45
38
- fbase.stream (" /chat " );
46
+ fbase.stream (" /bitcoin " );
39
47
}
40
48
41
49
@@ -52,6 +60,14 @@ void loop() {
52
60
if (type != Firebase::Event::UNKNOWN) {
53
61
Serial.print (" data: " );
54
62
Serial.println (event);
63
+
64
+ // TODO(proppy): parse JSON object.
65
+ display.clearDisplay ();
66
+ display.setTextSize (1 );
67
+ display.setTextColor (WHITE);
68
+ display.setCursor (0 ,0 );
69
+ display.println (event);
70
+ display.display ();
55
71
}
56
72
}
57
73
}
0 commit comments