All Projects → riggaroo → Android Things Electricity Monitor

riggaroo / Android Things Electricity Monitor

Licence: apache-2.0
Electricity Monitor using Android Things and Firebase Realtime Database

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Android Things Electricity Monitor

Laravel Firebase
A Laravel package for the Firebase PHP Admin SDK
Stars: ✭ 369 (+212.71%)
Mutual labels:  firebase, firebase-realtime-database
Whatsup
**Deprecated** Real time chat app written in Swift 4 using Firebase and OTP Authentication
Stars: ✭ 39 (-66.95%)
Mutual labels:  firebase, firebase-realtime-database
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (+331.36%)
Mutual labels:  firebase, firebase-realtime-database
Pring
Cloud Firestore model framework for iOS - Google
Stars: ✭ 260 (+120.34%)
Mutual labels:  firebase, firebase-realtime-database
The Road To React With Firebase
📓The Road to React with Firebase: Your journey to build business applications with React and Firebase.
Stars: ✭ 82 (-30.51%)
Mutual labels:  firebase, firebase-realtime-database
Firebase Js Sdk
Firebase Javascript SDK
Stars: ✭ 3,844 (+3157.63%)
Mutual labels:  firebase, firebase-realtime-database
Androidthings Drivers
Android Things open source peripheral drivers
Stars: ✭ 30 (-74.58%)
Mutual labels:  raspberry-pi, android-things
Firebase Esp32
ESP32 Firebase RTDB Arduino Library
Stars: ✭ 204 (+72.88%)
Mutual labels:  firebase, firebase-realtime-database
Gitmessenger
GitMessenger is github chat app built with socket.io , firebase, nodejs and bootstrap where developers can share code,images and much more 😊
Stars: ✭ 78 (-33.9%)
Mutual labels:  firebase, firebase-realtime-database
Firebaseapp
Google Apps Script binding for Firebase Realtime Database
Stars: ✭ 57 (-51.69%)
Mutual labels:  firebase, firebase-realtime-database
Angularfire Lite
⚡️ Lightweight library to use Firebase API 🔥 with Angular
Stars: ✭ 245 (+107.63%)
Mutual labels:  firebase, firebase-realtime-database
React Native Firebase Chat
React Native chat application using firebase.
Stars: ✭ 113 (-4.24%)
Mutual labels:  firebase, firebase-realtime-database
Firebase Esp8266
ESP8266 Firebase RTDB Arduino Library
Stars: ✭ 228 (+93.22%)
Mutual labels:  firebase, firebase-realtime-database
React Gatsby Firebase Authentication
🐣🔥Starter Project / Boilerplate for Authentication with Firebase and plain React in Gatsby.js
Stars: ✭ 356 (+201.69%)
Mutual labels:  firebase, firebase-realtime-database
Firebase Authentication Dotnet
C# library for Firebase Authentication
Stars: ✭ 222 (+88.14%)
Mutual labels:  firebase, firebase-realtime-database
Chatapp
Chat App with all functionality private chat, contacts, friends request, find friends,for profile settings image cropper functionality, settings, logout also send text, image and all type of files, delete your files for you and everyone , login with email and mobile number and real time database firebase and for notification purpose Node Js used.
Stars: ✭ 25 (-78.81%)
Mutual labels:  firebase, firebase-realtime-database
Rxfirebase
RxJava binding APIs for Firebase.
Stars: ✭ 143 (+21.19%)
Mutual labels:  firebase, firebase-realtime-database
Space
A real time chat app for developers built using React, Redux, Electron and Firebase
Stars: ✭ 161 (+36.44%)
Mutual labels:  firebase, firebase-realtime-database
Kotlin Firebase Group Chat
Group and OneonOne chat using firebase built in Kotlin similar to whatsapp.
Stars: ✭ 44 (-62.71%)
Mutual labels:  firebase, firebase-realtime-database
Simple Firebase Unity
Firebase Realtime-Database's REST API Wrapper for Unity in C#
Stars: ✭ 111 (-5.93%)
Mutual labels:  firebase, firebase-realtime-database

Electricity Monitor

For those who may not know, I live in South Africa, a country where we sometimes battle with electricity.
Hey we even have a multitude of apps that give out "load-shedding" schedules. See here and here.

While these apps serve a purpose, they are not so good when we have unplanned outages.

Which often leaves me asking myself the following questions:

  • Do I have power at home right now?
  • If not, how long has the power been out for?
  • Is it okay to eat the contents of my freezer?

Introducing "Electricity Monitor"...

phone image phone image

I decided to use a Raspberry Pi 3 running Android Things and Firebase Realtime Database to monitor the electricity in my house.

Mainly because Firebase has a VERY powerful tool for monitoring if a client is connected to your Realtime database or not. By leveraging the onDisconnect() method on the Firebase Realtime database, the server can automatically change some data (or log a time) when a client disconnects.

Setup Requirements

In order to get the app running yourself, you need to:

  1. Checkout this repository.

  2. Create a new Firebase Project here.

  3. Download the google-service.json file from the Firebase Console to both the app folder and the companion-app folder.

  4. Set the Realtime database rules to be read and write for everyone (Firebase Console -> Database -> Rules). (WARNING: This means there is NO security on our database – you should not have these rules in production)

     {
      "rules": {
          ".read": true,
          ".write": true
        }
     }
    
  5. Deploy the “app” module to the Raspberry Pi or equivalent Android Things device (you need to make sure you have setup your Pi with the Android Things OS).

  6. Deploy the “companion-app” module to your phone.

  7. If you have electricity, you will see a house with lights on and the accumulated time you have had power for. If you don’t have electricity, the Raspberry Pi will lose its power source and trigger the onDisconnect() callback on the Firebase server. This will then show up in our “companion-app” , it will display how long the electricity has been off for.

Push Notification setup using Firebase Cloud Functions

If you want to enable notifications for when your power goes off and on, you can follow the below guide. By leveraging Firebase Cloud Functions, we are able to easily send push notifications to any device with the companion-app installed to notify them when the power has been cut.

  1. Make sure you have NodeJS and NPM installed. You can follow the guide here to install it.

  2. Install Firebase CLI tools:

     npm install -g firebase-tools
    
  3. Initialize the required dependencies by navigating into the cloud-functions folder:

     cd cloud-functions
     npm install 
    
  4. Login with Firebase (this will prompt you to login via Browser):

     firebase login
    
  5. Run the following command to deploy the Firebase functions:

     firebase deploy --only functions
    
  6. You should then be able to see the functions appear in the Firebase Console as seen below:

firebase console

Now when your Android Things device disconnects from power/internet, you will receive a push notification to your devices running the companion app. As seen below:

push notification image

Yes I know...

  • There are easier ways to monitor your power at home
  • This is basically monitoring my Pi's connection to the internet and not power, which in most cases will be accurate enough for me as I am hardly without internet. (I guess this could be rebranded as - "Do I have Internet at home?")
  • Yes there is no security on the database right now, luckily its not controlling my power. (pull requests are welcome )
  • This should probably be moved into a background service so it can run in the background.
  • You might not understand the need for this app, which is okay, it is useful for me and hopefully fellow South Africans 😄

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].