$4 Smarthome with ESP8266 and Firebase. Works with IFTTT, HomeKit (Siri), has a web app
GPL-3.0 License
A SmartHome setup using Google Firebase and $4 modules. Can do a lot of awesome stuff.
Devices list | Main menu | RGB lamp control | Composing triggers |
---|---|---|---|
apt-get install mosquitto
~/.firenet-of-things/firebase-credentials.json
~/.firenet-of-things/config.js
with your config:{
id: 'smart-pi',
broker: 'mqtt://...',
firebase: 'https://....firebaseio.com'
};
web/config-firebase.js
cd device-bridge && npm install && npm run build && npm start
cd web && npm install && npm run build && firebase deploy
firebase open
This whole project started as a quest to build self-owned IOT cloud with minimal setup and enabling running as cheap as possible. There are plenty solutions on the market. Some of them looked like they can disappear any minute, some of them were not cheap. Amazon IOT was very tempting, but I couldn't run it for free and the cheapest modules had trouble connecting to their SSL servers (because of TLS 1.2)
All in all, I settled on Firebase, which is real-time cloud json database from Google. With Firebase you have Hosting, Google / Facebook / Github... authentication and authorization.
All this would not be possible without glorious ESP8266 chips. They are like Arduino with Wifi and they are running NodeMCU firmware which you program in lua script ( similar to JS ). I have started putting up a Plug&Play firmware called nodemcu-minion which requires no programming to setup.
In overall design I wanted to follow "microservices" approach while keeping it sane. Everything should scale nicely.
I use ESP8266 chips connected to RGB strip or relays.
Each chip listens to iot/things/id
topic on message broker and sends a heartbeat to iot/heartbeat
every second.
This is message broker for lightweight iot messaging protocol. Theoretically devices could connect to Firebase directly, but I wanted to limit data usage and MQTT was just easier. MQTT Broker is meant to keep communication in a single household. Whole setup can have more brokers, they are completely transparent.
This is the only element that stops the whole system from working, because this is the only piece that runs actual code. Device Gateway handles Firebase Queues and MQTT messages and it is a Node Script.
Firebase database is a heart of whole setup.
dispatch
tree is used as a task queuedevices
tree is used as a device shadow treespec
tree holds queue configuration details and user authorization rulestriggers
tree holds information about triggered task series.Firebase hosting hosts a web app Firebase Authentication is used for logging
Via smart configuration of Firebase access rules, triggers expose HTTPS endpoint that does not require login. Making a request:
curl -X POST -d '{"triggerName":...,"token":..}' https://<your-project>.firebaseio.com/dispatch.json
with a proper token will put a new task in dispatch
queue that will be picked up by device gateway general worker. Each trigger has its own token.
This feature is used for IFTTT integration
Firebase-React web app:
This project started as a PHP / Arduino setup built on top of raspberry pi. I moved the old version to a an master-old
branch.
These are some of the features of that version:
SmartPi is my setup of a SmartHome. Some features include: