A few JavaScript examples that integrate a Firebase with the physical world.
(I guess this would make this an IoT / Internet of Things example.)
These examples probably work with other boards, but they were written with two things you probably have lying around somewhere. Go dig them up and blow the dust off of them.
- Raspberry pi
- Arduino Uno
- Some basic parts (that come with the Arduino Uno starter kit)
- Push button
- LED
- Potentiometer
- 16x2 LCD
- Firebase - realtime platform; the Internet part of this example
- Johnny Five - open source JavaScript Arduino programming framework
This project contains three tiny examples, each in their own JavaScript file:
Press a button and see an LED turn on. It's the cliché Hello World of electronics, except synchronized in real time with Firebase. If you run it on many devices at once, the LED comes on when anyone presses the button.
Turn a potentiometer and see a number change on an LCD. You can also see the number update in your Firebase dashbaord.
Display the current Bitcoin price on an LCD. This uses the Firebase cryptocurrency open data set.
-
Wire up your components to match the sample you'd like to run. You can use the picture above as a guide, but it's probably easier to read the pin assignments in the code comments.
-
Install the
StandardFirmata
sketch to your Arduino per the Johnny Five documentation. -
Install node.js, Johnny Five and Firebase's node.js client onto your Raspberry Pi.
-
If you're running
button-led.js
orpotentiometer-lcd.js
, create a new Firebase to store/synchronize your state. ReplaceYOUR_FIREBASE
in the code with the subdomain for your Firebase. -
Copy the JavaScript code on to your Raspberry Pi.
-
Run it:
$ node bitcoin-price-lcd.js