Wednesday, July 31, 2019

Nick Buonuconti

Sadly, we heard about another member of the 72 dolphins team passing away. Nick Buoniconti goes to Valhalla to meet the football gods.

I have a Nick story of my own. It was a random encounter in the 90s. I was flying home with my-then fiancée from NY to Ft Lauderdale. My wife was a frequent flier and had tons of free upgrades, so she bumped us both to first class.

We're waiting for the boarding process to start when there's a stir by the desk. Nick was on that same flight. I hear everyone chatting with him. Then I hear someone say "no problem Mr Buonicoti, we're happy to move you to first class!"

And maybe a minute later I hear "mr kennedy please come to the podium." I know what this means. He's getting *my* seat.

And of course they tell me that they can't accommodate my request and will be refunding the upgrade to my wife's account.

Cue the Seinfeld moment where jerry is in first class, hanging out with a model and eating sundaes, while Elaine is in coach squeezed between two "bad passengers" with nothing to eat.

That was pretty much it.

I had wanted to interview him at one point for my dolphins podcast, but I wasn't able to work it out. I surely would have asked him about this...

....I guess now I can let the grudge go. (Haha)

It’s a hoax!

In honor of the 1969 moon landing, and the persistent (yet ludicrous) claims that it's a hoax, I decided to create my own conspiracy theory:

The 1972 Miami Dolphins perfect season is a hoax. It never happened. It's fake news!

I mean a guy with glasses comes on and miraculously leads his team?! A bunch of no name guys playing top-notch defense?! It's impossible!

The "season" was played out on a soundstage in California. Ed Sabol, Director of nfl films was brought in to make it look real! Those miraculous plays we see were to make it more compelling. And the blunder by Garo Yepremian in the super bowl was a joke inserted to make us really believe it.

Just look at the hilights. Why is there no actual game film?! Because it was faked!

—- now, see how stupid this sounds?

Saturday, June 15, 2019

It’s all about perspective


Stephenopolous interviews trump. Trump comes off exactly as he is.  See if you can guess which headline came from which source:

Stephonopolous filets trump
Trump calls stephonopolous a little wise guy

Isn’t it amusing how his base just doesn’t care what he says or does.  He is some kind of messiah. 

Thursday, June 6, 2019

Raspberry Pi garage door, part 2

In case I forgot to put it in the last post, here is how to setup the camera to take pictures at regular intervals.

Now on to setting up the webserver.  This was more painful than I thought it would be.  But, it finally worked.  I went to /var/www/html and did this:
npm init to use the node package manager (NPM) to setup a new node project. You can press enter to accept the default settings, but when you get to entry point type in webserver.js
Now, do this:
sudo apt-get update

sudo apt-get dist-upgrade

npm install socket.io --save

npm install express --save


npm install onoff
A quick note here - some of these were added as I tested various methods for making this work.  I am not 100% positive that all of them are needed, but it can't hurt to have some extra code installed that's unused.

There are two files you will need:


sudo nano /public/index.html
<!DOCTYPE html>
<html>
<body>
<!--<p><input type="checkbox" id="light"></p> -->
<input type="image" id="light" src="http://yoursever/opener.jpg">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js"></script> 
<script>
var socket = io(); //load socket.io-client and connect to the host that serves $
window.addEventListener("load", function(){ //when page loads
  var lightbox = document.getElementById("light");
  lightbox.addEventListener("click", function() {
    socket.emit("light", Number(this.checked)); //send button status to server
  });
});
socket.on('light', function (data) { //get button status from client
  document.getElementById("light").checked = data; //change checkbox accordin$
  socket.emit("light", data); //send push button status to back to server
});

</script>

<br><br>

<img src='yourserver/doorpic.jpg'>

</html>
</body>
</html>




And sudo nano webserver.js

var http = require('http').createServer(handler); //require http server
var fs = require('fs'); //require filesystem module
var io = require('socket.io')(http) //require socket.io module and pass the http server
var Gpio = require('onoff/').Gpio; //include onoff 
var sensor = new Gpio(17, 'out'); //use GPIO pin 17, to check reed sensor 
var pushButton = new Gpio(4, 'high'); //use GPIO pin 4 as input, set to 1/high (off)
var mycounter=0;

http.listen(8080); //listen to port 8080


function handler (req, res) { //create server
  fs.readFile(__dirname + '/public/index.html', function(err, data) { 
    if (err) {

      res.writeHead(404, {'Content-Type': 'text/html'}); //display 404 if needed
   return res.end("404 Not Found");
    } 
    res.writeHead(200, {'Content-Type': 'text/html'}); //write HTML
    res.write(data); //write data from index.html
       if (sensor.readSync()==0) { res.write ("<h2>Garage sensor sez: Open!</h2>")}
       if (sensor.readSync()==1) { res.write ("<h2>Garage sensor sez: Closed.</h2>")}

    return res.end();
  });
}
}

io.sockets.on('connection', function (socket) {// WebSocket Connection
socket.on('light', function(data) { //get light switch status from client
console.log("Engage! " + mycounter);

pushButton.writeSync(1);
pushButton.writeSync(0);
// Turn off after 3 seconds
setTimeout(_ => {
pushButton.writeSync(1);
}, 3000);
mycounter++;


});
});

process.on('SIGINT', function () { //on ctrl+c
  sensor.writeSync(0); // Turn LED off
  sensor.unexport(); // Unexport LED GPIO to free resources
  pushButton.unexport(); // Unexport Button GPIO to free resources
  process.exit(); //exit completely
});

Doorpic is the picture the camera takes
Opener is a picture of the opener that I want to display in the app.
--put both in the folder noted above

Run node webserver.js and you are ready to go!

Now all you have to do is point to the IP address of your Pi and with the port 8080 (ie, http://192.168.0.123:8080) and you should be good to go!


Thursday, May 30, 2019

Raspberry Pi Garage Door opener

I wanted to repurpose my raspberry pi to be a garage door opener.  I tried several different methods to make this work, but wasn’t happy with how it was coming out, so I came up with more-or-less my own easy custom solution that I wanted to share.

Of course, you have to start by setting up Raspian on the Pi.

Then, enable VNC, SSH, and the camera in the settings.

VNC makes it a heck of a lot easier to log in once you've put the pi in the garage.

There were three things I needed to add to my Pi:
A camera
A relay switch
and a reed switch


Next, there are 4 pieces of software to install:

1. Apache (will allow you to create a web page to control the pi from a phone)
https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md

2. Webcam (so you can look and see what state the garage door is in, as a visual check)
https://www.raspberrypi.org/documentation/usage/webcams/

3.Node.js (allows for the algorithms to be written in javascript, my language of choice)
https://www.instructables.com/id/Install-Nodejs-and-Npm-on-Raspberry-Pi/
This one is a little tricky!  You have to follow the directions to get the exact right copy of the file for your Pi.  The full listing of available zip files is here https://nodejs.org/dist/v10.16.0/

Note: You may also have to install sudo apt-get install npm and sudo npm install

4. OnOff (this is the javascript tool that allows you to check the GPIO pin conditions)
https://www.npmjs.com/package/onoff


And then comes the wiring.  Your Pi has 40 GPIO pins to control external devices.


In short, you are going to use Java to look at the pins and either turn them on and off, or to evaluate whether the circuit is complete.

First the relay.  I pinned it to GPIO4, Ground, and a 5V

Pi Pin .  Relay input
2            VCC
 6            GND
7             IN2

(Note: in a previous version of this post, I noted the ground as pin 4; the picture was correct. I made a typo)






Then, I created a javascript that looks like this:
'use strict';

const Gpio = require('../onoff').Gpio; // Gpio class
const led = new Gpio(4, 'out');       // Export GPIO4 as an output

led.writeSync(1);
led.writeSync(0);

// Turn off after 3 seconds
setTimeout(_ => {
led.writeSync(1);
  led.unexport();    // Unexport GPIO and free resources
}, 3000);

Save it, and call it whatever you want - by running node yourfilename.js you will cause the relay to turn on and then off again 3 seconds later.

On the relay end, you want to attach two wires, which will open a circuit when the relay comes on.  The other ends of the wire attach to the opener itself, in my case to the left most screws.  When the circuit opens, the connection is shorted and the door opens or closes.  




Cool right?


For the reed switch, I pinned it to GPIO17 and a 3.3v



Note: I connected the wires to longer wires so I could run it across my garage.  Doesn't matter which is which on this end.


Then, I created a javascript that looks like this:
'use strict';

const Gpio = require('../onoff').Gpio; // Gpio class
const led = new Gpio(17, 'out');       // Export GPIO17 as an output

console.log (led.readSync());
if (led.readSync()==0) { console.log ("open")};
if (led.readSync()==1) { console.log ("closed")};

Save it, and call it whatever you want - by running node yourfilename2.js you will to see if the reed switch is closed or not - closed would indicate the door is closed.

And that is 99% of the work.

Next up is the html so that it will look like you want it to, and allow for "remote control"