This project is to help the Sighted Challenged to be able to navigate and be alerted to open doors, windows status of their home and surroundings. With the Walabot talking to the Raspberry Pi and the Amazon Alexa, that enables the hard of sight to be able to be even more aware of their surroundings.
This project is going to be a changing evolving animal as I go because I am trying to integrate many different technologies into one product. Integrating the Raspi with walabot is pretty straight forward as is the Alexa ..There are many tutorials on this.. The next step beyond this is the integration of Door and window sensors..
You can buy door and window sensors from Amazon but they run in the $100 to $200 range and don't integrate easily. I think we are going to Build our own wireless door and window sensors Using the Particle.. www.particle.io as we are already using Wifi as a transport medium anyway.. And the build cost per Device is in the $30 range.
The basic design topology is as follows the RaspberryPi0 and the Walabot communicate with the Alexa through a home network as shown in Picture 2:
Step 1.
Download and install the Walabot STK and follow the Setup Installation Instructions were going to be using a modified version of the following Code https://github.com/Walabot-Projects/Walabot-MeetingRoom
Step 2.
Start work on your Alexa App and get it talking to your Raspberry Pi
Step 3.
In getting the Raspberry Pi talking you need to install a few things, copy/paste the following in a terminal
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install python2.7-dev python-dev python-pip
sudo pip install Flask flask-ask
Step 4. Setup Ngrok
Visit https://ngrok.com/download and get the latest Linux ARM release as a ZIP , Unzip in your home directory.
sudo unzip /home/pi/ngrok-stable-liux-arm.zip
Run it with the following command
sudo ./ngrok http 5000
You will need what shows up next on the screen look for the https// I've used Italic on the necessary "https" line you will need this in your Alexa Setup ( next) the issue with ngrok is the https will change every time you restart it ..So you will have to change it on the Alexa app every time not hard but a pain..
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://743fd26c.ngrok.io -> localhost:5000
Forwarding https://743fd26c.ngrok.io -> localhost:5000
Connections ttl opn rt1 rt5 p50 p90
23 0 0.00 0.00 0.81 1.15
Further instructions coming soon ...:0)
Step 5
Setting up your Raspberry Pi to talk to Particle Devices
you are going to need a free account with Particle http://www.particle.io
then sign up for the ParticlePi Beta program
open up a command window and past this into it..
bash <( curl -sL https://particle.io/install-pi )
The installation Process will take a little while .
Why were installing this is because you can link your Door and Window sensors inputs directly to the Raspberry Pi and when an input on the Door goes low it will mirror the input and drive whatever input you set it up as low.
I am currently experimenting with An app that talks directly to the Particle from Alexa ..I am having technical difficulties at the moment stand by..
Ok.. here is a neat work around to experiment with the Alexa without going near the programming side of things for now.. All you need is an Alexa and a Raspberry Pi.
Step 6. Go to https://nodered.org/docs/getting-started/upgrading and do a re install of your Raspi Node Red using the following commands in a command window..I like to remote in using ssh with a program called putty
It is much easier to have a couple of laptops running different things, while working
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
Now once the install is done reboot and install the following packages in your node red using the manage pallet tab.
Search Particle and click install
Search Alexa and click install
To get the Node red to start up automatically on reboot copy paste this in. Then test it by sudo reboot ..Give it a few minutes the just open a Web window and type in the Pi- IP address like so http://10.0.0.13:1880 and node red should be running without using command line. Its very handy to have everything start automatically upon reboot..
sudo systemctl enable nodered.service
now comes the SUPER easy part
As you can see the Alexa Nodes are super easy Label them and then search for devices on your tablet with the Node-red Alexa App Enabled..They Will show up
I am using debug tabs to watch the outputs as they happen to make sure everything is talking properly
const char *message = "OnOff";
void setup() {
Particle.function("OnOff", Reset1);
pinMode(D0, OUTPUT);
}
void loop() {
}
int Reset1(String command) {
if(command =="on") {
digitalWrite(D0,HIGH);
Particle.publish("D0_State", "1",PRIVATE);
}
else if(command =="off") {
digitalWrite(D0,LOW);
Particle.publish("D0_State", "0",PRIVATE);
}
return 1 ;
}
The Particle Setup is just as easy
You can have as many as these as you want Different invocations and Functions to turn Coffee makers, Computers, Lighting ,Garage door openers, Front door Openers and Locks and Security Alarms ..Next were going to program in Some Particle Publish and Subscribe Code for the Particle PI
void setup() {
Particle.subscribe("D0_State", myHandler);
}
void loop() {
}
void myHandler(const char *event, const char *data)
{
if (strcmp(data,"1")==0) {
Particle.publish("Confirm_DO","HIGH");
}
else if (strcmp(data,"0")==0) {
Particle.publish("Confirm_DO","LOW");
}
else {
}
}
As the Particle is the Brains of our little operation the above sketch subscribes to the other particles publish ..Now they are linked..And now we can program the particle Pi to turn its own IO on and off in sync with the other particle. Special Code to Be posted soon
Now we have to write some code for Alexa and the Raspberry Pi
The Particle shield to house the Power, Switch mechanism and Particle .
For the Door and window contact’s we’re going to be using this
And can be purchased here
https://www.amazon.ca/Mbangde-Magnetic-Contact-Personal-Security/dp/B01M8JCGSO/ref=sr_1_1?ie=UTF8&qid=1514562108&sr=8-1&keywords=Window+contact
The power supply for the Wireless Door and window contacts can be a 9Volt
battery like This ..Note in order to use a 9 Volt Battery we will have to Program in a sleep function to the particle to only wake up and send the Status of the Input when it changes state and goes back to sleep till the next state change. That way it will last a very long time without being recharged. The final program for the Particle will reflect this.
The connectors are like this.
The Shield I designed is able to take up to 24 VDC so we are well within the power parameters.
There you have it a $30USD wireless door window sensor. Now if you have a 3D printer print out a stylish case and mount it above any door or window. Not only will you be able to sense whether door or window is open you can also sense room temperature as well with the onboard temperature sensor.
A Note about controlling devices like coffee makers , and High amperage devices. You do not want to control the Power Circuit .. You want to control the Control Circuit. The Diagram below will explain. the power circuit is a high amperage circuit Especially when it is in something like a coffee make +10Amps...The Control Circuit will only be running 1 amp which is what we need ..The relays I am using are good for 3 amps at 120 Volts AC which would be good for a lamp with an LED bulb.
Comments