Header Ads

IOT with Firebase show Sensor Data to Android App

IOT is very hot topic when talking of current technology although it started long ago in 1999 by Kevin Ashton for the company P&G. Kevin cool name na? It reminds me of me ! he-he. Now back to IOT, so basic idea of IOT is to connect dumb things that are around us to a network to make things smart. We can’t make people around us smart but we can makes things smarter irony! You can say you are implementing IOT when you have some sort of (small) processor in your device that has interaction with environment human or animal , device can be multiple there is no limit to numbers here, when these devices are connected to internet of network of any sort that you are doing something with IOT.

Code Below Follows the video to help : 




Sole motive of IOT is to collect and transfer data from one end to another for clarity I would like to include terms like sensors, actuators, processors/controllers, storage. Now sensor is some device that will collect data it will require a local processor to process data or more importantly send data to some storage that will be firebase database in our case. The processor/controllers here will be Arduino NodeMCU, Sensor we are using here is Ultrasonic sensor and one more device LED that will work as are in-house testing device will share processor with ultrasonic sensor. Work of LED will be very simple glow or not glow our ultrasonic sensor will sense nearby object, we can use any sensor depending upon what we would like to monitor or work with here we will sense object and notify user.

Let's See the code for Getting Data from Sensor to Arduino and update it to firebase as Real-time Database:
#include <ESP8266WiFi.h> #include <FirebaseArduino.h>
// Set these to run example.
#define FIREBASE_HOST "esri-eea51.firebaseio.com"
#define FIREBASE_AUTH "qULRQbnuzJ3qkAdYunMasgcLlKtpXic1UQ1FxHvM"
#define WIFI_SSID "kavin"
#define WIFI_PASSWORD "1123581321"
const int trigPin = 15; //D4
const int echoPin = 12; //D3
long duration;int distance;
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(16, OUTPUT); //D0
pinMode(0, INPUT); //D3
// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.set("LED_STATUS", 0);
Firebase.setInt("distance", 0);
}
int n = 0;
void loop() {
/*
* For Utlrasonic sensor distance measurement
*/
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
Firebase.setInt("distance",distance);
delay(2000);
/*
* Led Control Home Automation
*/
n = Firebase.getInt("LED_STATUS");
// handle error
if (n==1) {
Serial.println("LED ON");
digitalWrite(16,HIGH);
return;
//delay(10);
}
else {
Serial.println("LED OFF");
digitalWrite(16,LOW);
}
}

Notifying user will require an interface through which user will get to know what our sensor has to tell us for this we will build an very simple Android app that we have built once for home automation. This app will let display the distance of the object to the sensor and can also be used to generate some kind of alert if it is required. The app will collect data from the firebase that is our cloud storage and this cloud storage is being updated on real time by our Arduino NodeMCU with the help of our Ultrasonic Sensor.

Android App Code:


Main Activity.java :
import android.os.Bundle; package com.example.root.fire_major_notification;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
public class MainActivity extends AppCompatActivity {
Button on;
Button off;
TextView distance;
DatabaseReference dref;
String status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
on = (Button) findViewById(R.id.on);
off = (Button) findViewById(R.id.off);
distance = (TextView) findViewById(R.id.textView3);
dref= FirebaseDatabase.getInstance().getReference();
dref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
status=dataSnapshot.child("distance").getValue().toString();
distance.setText(status);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
on.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("LED_STATUS");
myRef.setValue(1);
}
});
off.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("LED_STATUS");
myRef.setValue(0);
}
});
}
}


MainActivity.xml :
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.root.fire_major_notification">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

So, that's all for mapping your sensor data to Android app using firebase database and Arduino NodeMCU.

18 comments:

  1. Access to computers and other control systems which might provide you with information about the way the world revolves around technology should be unlimited and total. All information should be free and accessible to all. Seeing how you are being monitored by most of these tech companies. And also needing cyber help in many areas of your day to day activities, we at INTEGRATEDHACKS have come come up with a team of highly motivated and dedicated hackers to help you get access to information you are being deprived of and also protect you when necessary. Our services include and are not limited to hacking of social media accounts,email accounts, tracking of phones hacking of bank cards and many more.
    Have you ever been hacked? Need to recover your stolen account, Want to monitor your kids,spouse or partner, Change your school results, track messages from an email or mobile number, secure your email accounts, phones, bank accounts and many more, INTEGRATEDHACKS is the one for you. Hundreds of our clients have their jobs done consistently and efficiently in no time. Our professional hackers for hire team is highly qualified and can hack anything or device you desire without giving the target any form of notification which makes us one of the best.
       Are you having doubts about your partner ? Worry no more. All your doubts would be cleared.


    ★ Contact Us today For Your Desired Hacking services via : integratedhacks@protonmail.com and experience cyber hacking like never before.

    ReplyDelete
    Replies
    1. I'm selling Western Union , Bank and Paypal Transfers all over the world.
      USA,UK,EU,Canada, Australia, Russia, Netherlands, China, Malaysia, France, Thailand, Ukraine. I'm getting much stuff through emails but also have a big experience in botnets etc. I've got 5 western union main computers data with the help of a strong botnet. Now I can change the info of a WU MTCN and can redirect any payment on any name. Simply I change the receiver name and country and payment goes to that person to whom i want to send. If anyone want to make big and instant money than contact me for deal. We do reliable work and give good service to all our clients. We make our clients for long time business. First we prove our work then make a deal.

      Info needed for WU Transfers / Money Gram:-

      1: First Name
      2: Last Name
      3: City
      4: Country

      Price List For WU Transfer / Money Gram / Paypal / Bank Transfer:

      $1500 Transfer = $150 Charges
      $2000 Transfer = $300
      $3500 Transfer = $450
      $4500 Transfer = $500
      $5500 Transfer = $600

      Terms & Conditions:

      A person can take transfer once in a week and maximum 2 times in a month.

      If anyone want to do regular business with me then you must have many bank accounts, Paypal, Money bookers and fake ids for western union because after 2 or 3 transfers in a week your Paypal and WU receiver details can be black listed or banned. So think before deal. Make big transactions and get a side and give other peoples chance or try to gather many fake accounts and work with me on regular basis.

      You can Contact us 24/7

      Email – Westernunionofficial.service@gmail.com

      ICQ – 728 446 133

      Delete
  2. I know a professional hacker named james who has worked for me this week. He offers very legitimate services such

    as clearing of bad records online without being traced back to you, He clone/hack mobile phones, hack Facebook

    account, instagram, WhatsApp, emails, Twitter, bank accounts, Skype, FIXES CREDIT REPORTs, track calls. He also

    help retrieve accounts that have been taking by hackers. His charges are affordable, reliable and 100% safe. For

    his job well done this is my own way to show appreciation, Contact him via address below...
    Email...hackintechnology@gmail. com
    Text no..+1(669) 225-2253

    ReplyDelete
  3. Hello there, i am on here for those interested in hack related services like phone taps to catch cheating spouse, email hacks, website hack, credit score repair, funding programs,clear criminal records , proof to help win court cases, DMV or any problem you feel no one can resolve. I met Andrew Alan a hacker who helped me with countless projects that came out succesfully and so i decided to vouch for his service and help increase his client base. If you feel you have anything disturbing you and you neeed someone discreet to help you out??? Contact icefoghackersorg@gmail.com or text +1-616-422-7025. I hope this helps you all on here.

    ReplyDelete
  4. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... odzyskiwanie danych z uszkodzonego telefonu

    ReplyDelete
  5. Hello all
    am looking few years that some guys comes into the market
    they called themselves hacker, carder or spammer they rip the
    peoples with different ways and it’s a badly impact to real hacker
    now situation is that peoples doesn’t believe that real hackers and carder scammer exists.
    Anyone want to make deal with me any type am available but first
    I‘ll show the proof that am real then make a deal like

    Available Services

    ..Wire Bank Transfer all over the world

    ..Western Union Transfer all over the world

    ..Credit Cards (USA, UK, AUS, CAN, NZ)

    ..School Grade upgrade / remove Records

    ..Spamming Tool

    ..keyloggers / rats

    ..Social Media recovery

    .. Teaching Hacking / spamming / carding (1/2 hours course)

    discount for re-seller

    Contact: 24/7

    fixitrogers@gmail.com

    ReplyDelete
  6. I'm selling Western Union , Bank and Paypal Transfers all over the world.
    USA,UK,EU,Canada, Australia, Russia, Netherlands, China, Malaysia, France, Thailand, Ukraine. I'm getting much stuff through emails but also have a big experience in botnets etc. I've got 5 western union main computers data with the help of a strong botnet. Now I can change the info of a WU MTCN and can redirect any payment on any name. Simply I change the receiver name and country and payment goes to that person to whom i want to send. If anyone want to make big and instant money than contact me for deal. We do reliable work and give good service to all our clients. We make our clients for long time business. First we prove our work then make a deal.

    Info needed for WU Transfers / Money Gram:-

    1: First Name
    2: Last Name
    3: City
    4: Country

    Price List For WU Transfer / Money Gram / Paypal / Bank Transfer:

    $1500 Transfer = $150 Charges
    $2000 Transfer = $300
    $3500 Transfer = $450
    $4500 Transfer = $500
    $5500 Transfer = $600

    Terms & Conditions:

    A person can take transfer once in a week and maximum 2 times in a month.

    If anyone want to do regular business with me then you must have many bank accounts, Paypal, Money bookers and fake ids for western union because after 2 or 3 transfers in a week your Paypal and WU receiver details can be black listed or banned. So think before deal. Make big transactions and get a side and give other peoples chance or try to gather many fake accounts and work with me on regular basis.

    You can Contact us 24/7

    Email – Westernunionofficial.service@gmail.com

    ICQ – 728 446 133

    ReplyDelete
  7. how can i add date and time new child added to the database ?
    i want show sensor data and as well as the date and time when updated the time and date. please respond quickly. Waiting for your positive respond.
    mail: e-labinnovations@gmail.com
    Whatsapp: +918089931063

    ReplyDelete
  8. Unfortunately these factors mean that, in most cases, recovery services are quite expensive. Technician training, hard drive inventories and special equipment all come with a cost.
    data recovery centre

    ReplyDelete
  9. Hire Hacker
    ❤ BUSINESS FOR
    SERIOUS BUYERS ONLY ❤

    ♣ BILLS PAY
    ♣ HOTEL BOOKING / AIR TICKET BOOKING
    ♣ BANK TRANSFER AVAILABLE
    ♣ WESTERN UNION TRANSFER AVAILABLE
    ♣ ATM / DUMPS / TRACKS
    ♣ CREDIT CARD / DEBIT CARD

    We Also provide You To Transfer Money From any Hacked Bank Logins With No ChargeBack.
    WE HAVE REPLACEMENT POLICY AND WE PROVE BEFORE ANY BUSINESS
    INBOX ME ASAP

    ICQ : 728612475
    Gmail : arturooboris@gmail.com

    ReplyDelete
  10. It seems to be more dangerous; everything happens before you could see anything.gerald winata gozali

    ReplyDelete
  11. Hello world
    We Only Make - The boss

    Reseller :- Hacking Tools & Hacking services, Also Teach Hacking Methods Via teem weaver or Anydesk,
    Each Method Take minimum 1 hour to learn with vedio Tutorial And Hacking Tools ,

    How to Make Money With Method & luck ,

    - Spamming & Tools ,
    - Carding & Tools ,
    - Virus with control panal and Spy bot files,
    - Virus With Builder And Crypter ,
    - Scanners with Bruters ,
    - Crypters with Doc Exploits ,pdf Exploits ,TExtfile Exploits ,
    - PHP Exploits with shell and mailer
    - OTP verications Bypass with Bulletproof Scam-page and Otp control
    - Company Ceo or cfo leads Any country
    - Rat virus with builder
    - Cookies Stealers and Builder
    - keyloger and builder
    - Credit card Scam-pages
    - Bank login Scam-pages
    - debit card topup scam page
    - donation scam-page
    - dhl login and tracking scam-page
    - fedax login and tracking scam-page
    - Shipping Tools

    Place & Ground
    learners you will pay cheap $ for demo Tools & Method

    Business grounds

    Credit card Low Interest Services,

    - Credit card with Fullz Information - Minimum Investment 150$ - With 50k Credit limit And balance
    - Debit Card Topup AS per Card limit - Minimum Investment 200$ - With 8000$ balance
    - Dating scam Fresh male female Logins - Minimum Investment 80$ - Dating Login upto 30
    - Tex refund Scam leads - Minimum Investment 200$ - Result upto 5000 in 10 days
    - payments and Bills - Minimum Investment 300$ - upto 7000$
    - Wester union Minimum Transfer 2000$ - Transfer Fess 400$
    -----------------

    ABOUT US :

    alberticeman0@gmail.com

    ReplyDelete
  12. Some truly wonderful work on behalf of the owner of this internet site , perfectly great articles . odzyskiwanie danych Warszawa

    ReplyDelete

  13. Do You Seek Funds To Pay Off Credits and Debts? { FIFOCapitals@gmail.com } Is Here To Put A Stop To Your Financial Problems. We Offer All Kinds Of Loan (Personal Loan, Commercial Loan, etc.) We Give Out Loan With An Interest Rate Of 2.%. Interested Applicants Should Contact Us Via Email: FIFOCapitals@gmail.com

    Please Fill the Application Form Below:
    - Complete Name:
    - Loan Amount Needed:
    - Loan Duration:
    - Purpose Of Loan:
    - City / Country:
    - Telephone:
    - How Did You Hear About Us:

    If You Are Interested To Get A Loan Then Kindly Write Us With The Loan Requirement. Please, Contact Us via email: FIFOCapitals@gmail.com,,,

    ReplyDelete
  14. YES thanks to hackintechnology@gmail.com he helped me to hack into my spouse facebook JUST NOW and i could spy on my spouse phone remotely this was after been scammed by other hackers you can hire him +16692252253 HAPPY NEW MONTH

    ReplyDelete


  15. I was searching for loan to sort out my bills& debts, then i saw comments about Blank ATM Credit Card that can be hacked to withdraw money from any ATM machines around you . I doubted thus but decided to give it a try by contacting {blankatm156@gmail.com} they responded with their guidelines on how the card works. I was assured that the card can withdraw $5,000 instant per day & was credited with $50,000 so i requested for one & paid the delivery fee to obtain the card, after 24 hours later, i was shock to see the UPS agent in my resident with a parcel{card} i signed and went back inside and confirmed the card work's after the agent left. This is no doubts because i have the card & has made used of the card. This hackers are USA based hackers set out to help people with financial freedom!! Contact these email if you wants to get rich with this Via: blankatm156@gmail.com

    ReplyDelete
  16. if you are having a low credit score or battling with negative listings,late payment history and repossessions on your credit report,i'll recommend to you this certain ethical hacker with the email address Q U A D H A C K E D at G M A I L dot C O M . very credible hackers who helped with my score under almost three weeks of approval, i was able to obtain a good credit rating for a mortgage loan to secure the purchase of my house. they helped me remove late payment history, and student loans history . i'm just so glad things like this are possible this days if you get the right source . reach out to him today for your credit repair service by sending an explanatory message to their e mail today.
    Q U A D H A C K E D @ G M A I L . CO M

    ReplyDelete

Powered by Blogger.