firebase - realtime backend for mobile app and iot
TRANSCRIPT
![Page 1: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/1.jpg)
Game DevFest 2015Jakarta Oct 17 2015 | Surabaya Oct 18 2015
FirebaseRealtime backend for mobile app and IoT
Andri Yadiandri_yadi | a at dycode dot com
httpandriyadime | googlecom+AndriYadi
CEO of
Been coding in awesome languagesFrameworks for 18 years
QBasic Pascal c C++ Java PHP Bash C Visual Basic HTML JavaScript Python Objective-C Swift
NET QtQML Java MEEESE Android SDK iOS SDK Nodejs Arduino
Who am I around Firebase
How dare I am talking herehellip
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 2: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/2.jpg)
Andri Yadiandri_yadi | a at dycode dot com
httpandriyadime | googlecom+AndriYadi
CEO of
Been coding in awesome languagesFrameworks for 18 years
QBasic Pascal c C++ Java PHP Bash C Visual Basic HTML JavaScript Python Objective-C Swift
NET QtQML Java MEEESE Android SDK iOS SDK Nodejs Arduino
Who am I around Firebase
How dare I am talking herehellip
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 3: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/3.jpg)
CEO of
Been coding in awesome languagesFrameworks for 18 years
QBasic Pascal c C++ Java PHP Bash C Visual Basic HTML JavaScript Python Objective-C Swift
NET QtQML Java MEEESE Android SDK iOS SDK Nodejs Arduino
Who am I around Firebase
How dare I am talking herehellip
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 4: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/4.jpg)
Been coding in awesome languagesFrameworks for 18 years
QBasic Pascal c C++ Java PHP Bash C Visual Basic HTML JavaScript Python Objective-C Swift
NET QtQML Java MEEESE Android SDK iOS SDK Nodejs Arduino
Who am I around Firebase
How dare I am talking herehellip
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 5: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/5.jpg)
Who am I around Firebase
How dare I am talking herehellip
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 6: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/6.jpg)
Irsquom the user of firebase long before Firebase has order amp Limit feature
Irsquove been using it since Jan 2014
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 7: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/7.jpg)
Disclaimer
30 minutes wonrsquot be enough to show how cool Firebase is
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 8: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/8.jpg)
What is Firebase
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 9: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/9.jpg)
Letrsquos see a Real-World demo
Rather than theoritise about it
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 10: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/10.jpg)
Take a photo with DevFest2015
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 11: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/11.jpg)
Shared photo will be automatically shown here httpstoryjepretinJepretgdgdevfest2015
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 12: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/12.jpg)
Firebase delivers that photo object to browser in realtime
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 13: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/13.jpg)
Jepret Cloud Jepret Allegra Jepret Story
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 14: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/14.jpg)
Firebase Firebase
Nodejs + MongoDBDeployed on Microsoft Azure
Architecture
Firebase
Realtime Gallery Allegra Machine Jepret Story app
Jepret Cloud
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 15: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/15.jpg)
More about Jeprethttpjepretin
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 16: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/16.jpg)
Letrsquos see another demo
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 17: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/17.jpg)
Typical Firebase Demo
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 18: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/18.jpg)
Letrsquos Try something different
todayhellip
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 19: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/19.jpg)
Letrsquos Get Physical
todayhellip
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 20: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/20.jpg)
Letrsquos light up the LED
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 21: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/21.jpg)
My Setup
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 22: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/22.jpg)
Circuit
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 23: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/23.jpg)
Code
var wpi = require(wiring-pi) wpisetup(gpio)
var ledPin = 26 26 is GPIO pin to LED
wpipinMode(ledPin wpiOUTPUT)
Turn offon the LED directly var ledValue = 1 0 to switch off wpidigitalWrite(ledPin ledValue)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 24: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/24.jpg)
Letrsquos light up the LED via browser
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 25: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/25.jpg)
Architecture
Raspberry Pi 2 Web app
HTTP(LAN)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 26: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/26.jpg)
Light up the LED via Firebase
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 27: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/27.jpg)
Architecture
Raspberry Pi 2Web app
Internet
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 28: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/28.jpg)
Firebase data
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 29: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/29.jpg)
The trick
Raspberry Pi 2
Firebase
ifstate==truewrite1ifstate==falsewrite0
wpidigitalWrite(LED_PIN1)
Firebase
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 30: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/30.jpg)
Codefunction setState(state) ledValue = +state convert truefalse to appropriate integer wpidigitalWrite(ledPin ledValue)
var deviceId = smartlamp1 var myFirebaseRef = new Firebase(ldquohttps[YOUR_FIREBASE]firebaseiocomdevicesrdquo) var deviceRef = myFirebaseRefchild(deviceId)
var myDevParamsRef = deviceRefchild(parameters)myDevParamsRefon(child_changed function(snapshot) consolelog(snapshotkey()) consolelog(snapshotval()) if (snapshotkey() == state) setState(snapshotval()) )
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 31: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/31.jpg)
Now we can turn on the Led from Marshellipor from anywhere connected to internet
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 32: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/32.jpg)
Let there be a lightUsing the same principle now we can turn onoff an AC light bulb
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 33: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/33.jpg)
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
AC solid state switch
To RPi2 GPIO 5
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 34: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/34.jpg)
My Setup
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 35: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/35.jpg)
Let there be a light from App
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 36: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/36.jpg)
Architecture
Raspberry Pi 2Web app Mobile app
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 37: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/37.jpg)
Sending Telemetry
what abouthellip
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 38: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/38.jpg)
Complete Circuit
1 2 3 4
A
B
C
D
4321
D
C
B
A Title
Number RevisionSizeA4
Date 7-Oct-2015 Sheet ofFile DDYCODELayout PCBDemoddb Drawn By
Q1TRIAC
U1
OPTOTRIAC_1
R2
1K
R1
470
LAMP
AC PLUG
GPIO
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 39: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/39.jpg)
Architecture
Raspberry Pi 2 Mobile app
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 40: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/40.jpg)
Bonus AutomationTurn on light bulb automatically using a LDR
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 41: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/41.jpg)
httpsgithubcomandriyadiFireSmartLamp
All code is here
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 42: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/42.jpg)
as Summaryhellip
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 43: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/43.jpg)
WELL DOCUMENTED
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 44: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/44.jpg)
Education
httpedudycodecoid | edudycodecom
a bit of adshellip
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 45: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/45.jpg)
We contributeEducation
100+ seminars workshops trainings delivered
Delivered to 20+ communities organisations
campuses
Next could be yourshellip Just drop us a message
httpedudycodecoid | edudycodecom
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 46: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/46.jpg)
We teach
+ + [Obj-C]
+
Education
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 47: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/47.jpg)
Opening soonhellipEducation
+
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 48: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/48.jpg)
httpsgithubcomandriyadiFireSmartLamp
Again all code is here
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks
![Page 49: Firebase - realtime backend for mobile app and IoT](https://reader031.vdocument.in/reader031/viewer/2022022414/5876063f1a28ab4a508b6a07/html5/thumbnails/49.jpg)
DyCode wwwdycodecom
office at dycode dot com | dycode
Thanks