Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb626e6

Browse files
committed
examples/FirebaseStream: display bitcoin price
1 parente6bde19 commitbb626e6

File tree

1 file changed

+40
-5
lines changed

1 file changed

+40
-5
lines changed

‎examples/FirebaseStream_ESP8266/FirebaseStream_ESP8266.ino

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,43 @@
1414
// limitations under the License.
1515
//
1616

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 display it on a i2c OLED screen.
19+
20+
//
21+
// Copyright 2015 Google Inc.
22+
//
23+
// Licensed under the Apache License, Version 2.0 (the "License");
24+
// you may not use this file except in compliance with the License.
25+
// You may obtain a copy of the License at
26+
//
27+
// http://www.apache.org/licenses/LICENSE-2.0
28+
//
29+
// Unless required by applicable law or agreed to in writing, software
30+
// distributed under the License is distributed on an "AS IS" BASIS,
31+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32+
// See the License for the specific language governing permissions and
33+
// limitations under the License.
34+
//
35+
36+
// FirebaseStream_ESP8266 is a sample that stream bitcoin price from a
37+
// public Firebase and optionally display them on a OLED i2c screen.
1938

2039
#include<Firebase.h>
40+
#include<Adafruit_GFX.h>
41+
#include<Adafruit_SSD1306.h>
2142

22-
Firebase fbase = Firebase("example.firebaseio.com");
43+
#defineOLED_RESET10
44+
Adafruit_SSD1306display(OLED_RESET);
45+
46+
Firebase fbase = Firebase("publicdata-cryptocurrency.firebaseio.com");
2347

2448
voidsetup() {
2549
Serial.begin(9600);
2650

51+
display.begin(SSD1306_SWITCHCAPVCC,0x3C);// initialize with the I2C addr 0x3C (for the 128x32)
52+
display.display();
53+
2754
// connect to wifi.
2855
WiFi.begin("SSID","PASSWORD");
2956
Serial.print("connecting");
@@ -35,7 +62,7 @@ void setup() {
3562
Serial.print("connected:");
3663
Serial.println(WiFi.localIP());
3764

38-
fbase.stream("/chat");
65+
fbase.stream("/bitcoin");
3966
}
4067

4168

@@ -49,9 +76,17 @@ void loop() {
4976
auto type = fbase.read(event);
5077
Serial.print("event:");
5178
Serial.println(type);
52-
if (type != Firebase::Event::UNKNOWN) {
79+
if (type != Firebase::Event::UNKNOWN) {
5380
Serial.print("data:");
5481
Serial.println(event);
82+
83+
// TODO(proppy): parse JSON object.
84+
display.clearDisplay();
85+
display.setTextSize(1);
86+
display.setTextColor(WHITE);
87+
display.setCursor(0,0);
88+
display.println(event);
89+
display.display();
5590
}
5691
}
5792
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp