Simple example of sending AWS IoT Button events through AWS Lambda then on to Firebase.
Simple webpage using Firebase that will display button push events. There are three types (SINGLE
, DOUBLE
, and LONG
). Button events will automagically be added to the page thanks to Firebase’s child_added
event.
Sample Firebase security rules
{
"rules": {
".read": true,
"$uid": {
".write": "auth !== null && auth.uid === $uid"
}
}
}
AWS Lambda Node.js (4.3) script. This handles the payload from the AWS IoT Button and passes it along to Firebase.
To run it, you’ll need to create your own Firebase, and insert the base URL, along with generating a token so you can POST data to it.
Sample payload
{
"serialNumber": "G030JF059405K485",
"batteryVoltage": "1615mV",
"clickType": "SINGLE"
}
Lambda logs can be found in AWS Cloudwatch, too.
You can also run a normal Dash button (or the IoT Button) using node-dash-button. Once the button is configured (on your local network), you can run the bin/findbutton script to detect your button’s MAC address.
To run it, cd
into the node
directory and install the dependecies.
npm install
Then run the app (must use sudo
)
sudo node app.js
If eveything is confiured correctly you should see Button pressed! logged out in the Terminal.