Difference between revisions of "Broken Buttons"

From LVL1
Jump to navigation Jump to search
(Created page with "Problem: People don't email broken@lvl1.org every time something breaks. Why?: My guess, no quick access to email/computer to email the group. Solution: Deploy a number of Ama...")
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
Problem: People don't email broken@lvl1.org every time something breaks.
+
= What's going on here? =
Why?: My guess, no quick access to email/computer to email the group.
+
 
Solution: Deploy a number of Amazon Dash Buttons around equipment. If something breaks or we're out of stock of something, instruct patrons to press the corresponding button.
+
*Problem: People don't email broken@lvl1.org every time something breaks.
 +
*Why?: My guess, no quick access to email/computer to email the group.
 +
*Solution: Deploy a number of Amazon Dash Buttons around equipment. If something breaks or we're out of stock of something, instruct patrons to press the corresponding button.
 +
 
 +
= Setup =
 +
As of January 11, 2016:
 +
 
 +
=== Hardware ===
 +
* Raspberry Pi B+
 +
* 4GB+ SD Card
 +
* Dash Button
 +
* Monitor & Keyboard
 +
=== Steps ===
 +
* Step 1: Download Raspbian Jessie Lite
 +
** https://www.raspberrypi.org/downloads/raspbian/
 +
* Step 2: Install image to SD card using Win32DiskImager
 +
* Step 3: Insert SD card to Raspberry Pi, connect monitor & keyboard, boot Raspberry Pi
 +
* Step 4: Configure wifi
 +
** https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
 +
** Save wifi settings to wpa_supplicant.conf
 +
** Restart wlan0
 +
*** <pre>sudo ifdown wlan0</pre>
 +
*** <pre>sudo ifup wlan0</pre>
 +
* Step 5: Update & Upgrade
 +
** <pre>sudo apt-get update</pre>
 +
** <pre>sudo apt-get upgrade</pre>
 +
* Step 6: Install Node 4.0.0
 +
** http://blog.wia.io/installing-node-js-v4-0-0-on-a-raspberry-pi/
 +
* Step 7: Install git and libpcap-dev
 +
** <pre>sudo apt-get install git libpcap-dev</pre>
 +
* Step 8: Create directory ~/dash and cd there
 +
** <pre>mkdir ~/dash</pre>
 +
** <pre>cd ~/dash</pre>
 +
* Step 9: Install nodemailer (version 0.7.1, 1.0.0 (default) is broken at time of writing)
 +
** <pre>npm install nodemailer@0.7.1</pre>
 +
* Step 10: Install dash button library
 +
** https://github.com/hortinstein/node-dash-button
 +
* Step 11: Run node-dash-button's findbutton app
 +
** <pre>cd ~/dash/node_modules/node-dash-button</pre>
 +
** <pre>sudo node bin/findbutton</pre>
 +
* Step 12: Configure Amazon Dash Button
 +
** Follow the instructions given to you in the box BUT STOP BEFORE YOU SELECT A PRODUCT TO ORDER (hit the back button on your phone, exit the app, etc)
 +
* Step 13: Press the Amazon Dash button once, watch raspberry pi terminal for the button's MAC address
 +
* Step 14: Create application
 +
** <pre>nano dash.js</pre>
 +
** Enter this code:
 +
<pre>
 +
var dashbutton = require('node-dash-button');
 +
var nodemailer = require('nodemailer');
 +
 
 +
var smtpTransport = nodemailer.createTransport("SMTP",{
 +
  service: "Gmail",
 +
  auth: {
 +
      user: "your@gmail.com",
 +
      pass: "yourpassword"
 +
  }
 +
});
 +
 
 +
var dashTest = dashbutton("a0:02:dc:d2:f5:67");
 +
dashTest.on("detected", function(){
 +
        console.log("Found button");
 +
        smtpTransport.sendMail({
 +
                from: "your@gmail.com", // sender address
 +
                to: "some_other@email.com", // comma separated list of receivers
 +
                subject: "Something is Broken! - This is a test.", // Subject line
 +
                text: "Something is broken!"
 +
        }, function(error, response){
 +
                if(error){
 +
                        console.log(error);
 +
                }else{
 +
                        console.log("Message sent: " + response.message);
 +
                }
 +
        });
 +
});
 +
</pre>
 +
*Step 15: Run application
 +
** <pre>sudo node dash.js</pre>

Latest revision as of 12:19, 11 January 2016

What's going on here?

  • Problem: People don't email broken@lvl1.org every time something breaks.
  • Why?: My guess, no quick access to email/computer to email the group.
  • Solution: Deploy a number of Amazon Dash Buttons around equipment. If something breaks or we're out of stock of something, instruct patrons to press the corresponding button.

Setup

As of January 11, 2016:

Hardware

  • Raspberry Pi B+
  • 4GB+ SD Card
  • Dash Button
  • Monitor & Keyboard

Steps

  • Step 1: Download Raspbian Jessie Lite
  • Step 2: Install image to SD card using Win32DiskImager
  • Step 3: Insert SD card to Raspberry Pi, connect monitor & keyboard, boot Raspberry Pi
  • Step 4: Configure wifi
  • Step 5: Update & Upgrade
    • sudo apt-get update
    • sudo apt-get upgrade
  • Step 6: Install Node 4.0.0
  • Step 7: Install git and libpcap-dev
    • sudo apt-get install git libpcap-dev
  • Step 8: Create directory ~/dash and cd there
    • mkdir ~/dash
    • cd ~/dash
  • Step 9: Install nodemailer (version 0.7.1, 1.0.0 (default) is broken at time of writing)
    • npm install nodemailer@0.7.1
  • Step 10: Install dash button library
  • Step 11: Run node-dash-button's findbutton app
    • cd ~/dash/node_modules/node-dash-button
    • sudo node bin/findbutton
  • Step 12: Configure Amazon Dash Button
    • Follow the instructions given to you in the box BUT STOP BEFORE YOU SELECT A PRODUCT TO ORDER (hit the back button on your phone, exit the app, etc)
  • Step 13: Press the Amazon Dash button once, watch raspberry pi terminal for the button's MAC address
  • Step 14: Create application
    • nano dash.js
    • Enter this code:
var dashbutton = require('node-dash-button');
var nodemailer = require('nodemailer');

var smtpTransport = nodemailer.createTransport("SMTP",{
   service: "Gmail",
   auth: {
       user: "your@gmail.com",
       pass: "yourpassword"
   }
});

var dashTest = dashbutton("a0:02:dc:d2:f5:67");
dashTest.on("detected", function(){
        console.log("Found button");
        smtpTransport.sendMail({
                from: "your@gmail.com", // sender address
                to: "some_other@email.com", // comma separated list of receivers
                subject: "Something is Broken! - This is a test.", // Subject line
                text: "Something is broken!"
        }, function(error, response){
                if(error){
                        console.log(error);
                }else{
                        console.log("Message sent: " + response.message);
                }
        });
});
  • Step 15: Run application
    • sudo node dash.js