Project in progress
Home Monitoring And Alerts For The Blind

Home Monitoring And Alerts For The Blind © CC BY-NC-SA

This project is for the assistance of blind and hard of seeing enabling them to find their way with alerts and voice directions.

  • 3,318 views
  • 0 comments
  • 19 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
M3 4 5 set drill tap w g 1  43270 1521058825 llaxvkoksp
OpenBuilds Drill Taps

Apps and online services

About this project

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

http://www.putty.org

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.

Code

Python CodePython
Copy Paste this into a python script explanation on previous screen
#****************gpio_control.py****************

from flask import Flask
from flask_ask import Ask, statement, convert_errors
import RPi.GPIO as GPIO
import logging

GPIO.setmode(GPIO.BCM)
app = Flask(__name__)
ask = Ask(app, '/')
logging.getLogger("flask_ask").setLevel(logging.DEBUG)

@ask.intent('GPIOControlIntent', mapping={'status': 'status','pin':'pin'})
def gpio_control(status,pin):
    try:
         pinNum = int(pin)
    except Exception as e:
         return statment ('Pin Number Not Valid.')
    GPIO.setup(pinNum, GPIO.OUT)
    if status in ['on','high' ]:   GPIO.output(pinNum, GPIO.HIGH)
    if status in ['on',  'low']:   GPIO.output(pinNum, GPIO.LOW)
    return statement ('turning pin {}  {}'.format(pin, status))
    GPIOControlIntentstate=GPIO.input(14)
    if  (state == True):
      GPIO.setup(14, GPIO.OUT)
      GPIO.output(14,GPIO.HIGH)
      return statement('InPut One Already On')
##+++++++++++++++++++++++++++++++++++++++++++++++++++
      GPIO.setup(15, GPIO.IN)
      state=GPIO.input(15)
      if  (state == True):
         GPIO.setup(15, GPIO.OUT)
         GPIO.output(15,GPIO.HIGH)
         return statement('InPut Two Already On')
      else:
        GPIO.setup(15, GPIO.OUT)
        GPIO.output(15, GPIO.HIGH)
        return statement('InPut Two {}'.format(status))

    if status in['off', 'low']:
      GPIO.setup(15, GPIO.IN)
      state=GPIO.input(15)
      print('status of input',state)
      if (state == False):
        GPIO.setup(15, GPIO.OUT)
        GPIO.output(15,GPIO.LOW)
        return statement('InPut Two Already Off')
      else:
        GPIO.setup(15, GPIO.OUT)
        GPIO.output(15, GPIO.LOW)
        return statement('InPut Two {}'.format(status))
##++++++++++++++++++++++++++++++++++++++++++++++
      GPIO.setup(18, GPIO.IN)
      state=GPIO.input(18)
      if  (state == True):
         GPIO.setup(18, GPIO.OUT)
         GPIO.output(18,GPIO.HIGH)
         return statement('InPut Three Already On')
      else:
        GPIO.setup(18, GPIO.OUT)
        GPIO.output(18, GPIO.HIGH)
        return statement('InPut Three {}'.format(status))

    if status in['off', 'low']:
      GPIO.setup(18, GPIO.IN)
      state=GPIO.input(18)
      print('status of input',state)
      if (state == False):
        GPIO.setup(18, GPIO.OUT)
        GPIO.output(18,GPIO.LOW)
        return statement('InPut Three Already Off')
      else:
        GPIO.setup(18, GPIO.OUT)
        GPIO.output(18, GPIO.LOW)
        return statement('InPut Three {}'.format(status))
##++++++++++++++++++++++++++++++++++++++++++++++++

      GPIO.setup(23, GPIO.IN)
      state=GPIO.input(23)
      if  (state == True):
         GPIO.setup(23, GPIO.OUT)
         GPIO.output(23,GPIO.HIGH)
         return statement('InPut Four Already On')
      else:
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23, GPIO.HIGH)
        return statement('InPut Four {}'.format(status))

    if status in['off', 'low']:
      GPIO.setup(23, GPIO.IN)
      state=GPIO.input(23)
      print('status of input',state)
      if (state == False):
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23,GPIO.LOW)
        return statement('InPut Four Already Off')
      else:
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23, GPIO.LOW)
        return statement('InPut Four {}'.format(status))

##+++++++++++++++++++++++++++++++++++++++++++++++++

      GPIO.setup(24, GPIO.IN)
      state=GPIO.input(24)
      if  (state == True):
         GPIO.setup(24, GPIO.OUT)
         GPIO.output(24,GPIO.HIGH)
         return statement('InPut Five Already On')
      else:
        GPIO.setup(24, GPIO.OUT)
        GPIO.output(24, GPIO.HIGH)
        return statement('InPut Five {}'.format(status))

    if status in['off', 'low']:
      GPIO.setup(24, GPIO.IN)
      state=GPIO.input(24)
      print('status of input',state)
      if (state == False):
        GPIO.setup(24, GPIO.OUT)
        GPIO.output(24,GPIO.LOW)
        return statement('InPut Five Already Off')
      else:
        GPIO.setup(24, GPIO.OUT)
        GPIO.output(24, GPIO.LOW)
        return statement('InPut Five {}'.format(status))

##++++++++++++++++++++++++++++++++++++++++++++++++++++

      GPIO.setup(25, GPIO.IN)
      state=GPIO.input(25)
      if  (state == True):
         GPIO.setup(25, GPIO.OUT)
         GPIO.output(25,GPIO.HIGH)
         return statement('InPut Six Already On')
      else:
        GPIO.setup(25, GPIO.OUT)
        GPIO.output(25, GPIO.HIGH)
        return statement('InPut Six {}'.format(status))

    if status in['off', 'low']:
      GPIO.setup(25, GPIO.IN)
      state=GPIO.input(25)
      print('status of input',state)
      if (state == False):
        GPIO.setup(25, GPIO.OUT)
        GPIO.output(25,GPIO.LOW)
        return statement('InPut Six Already Off')
      else:
        GPIO.setup(25, GPIO.OUT)
        GPIO.output(25, GPIO.LOW)
        return statement('InPut Six {}'.format(status))


if __name__=='__main__':
 port = 5000
 app.run(host='0.0.0.0',port=port)



##+++++++++++++++++++++++++++++++++++++++++++++++++++++++

@ask.intent('LocationControlIntent', mapping={'status':'status', 'location':'location'})
def location_control(status,location):

   locationDict  = {
        'Bed_Light': 12,
        'kitchen_Light': 16,
        'Coffee_Maker': 18,
        'Front_Window': 22'
        'Side_Window': 32,
        'Bed_Window': 33,
   }
   targetPin =  locationDict[location]

   GPIO.setup(targetPin, GPIO.OUT)


   if status in ['on', 'high']:   GPIO.output(targetPin, GPIO.HIGH)
   if status in ['off', 'low']:   GPIO.output(targetPin, GPIO.LOW)

   return statment ('turning {} {}!'.format(location, status))

Comments

Similar projects you might like

Turn Walabot into a "Why-Not?" Bot for the Disabled/Elderly

Project in progress by Eric Olson

  • 1,867 views
  • 1 comment
  • 13 respects

Walaarm: Walabot-Powered Robotic Arm

Project in progress by Md. Khairul Alam

  • 4,827 views
  • 0 comments
  • 33 respects

Where's my stuff?? - Find your misplaced things with Alexa!

Project in progress by Team Crakers

  • 1,629 views
  • 0 comments
  • 6 respects

WalaBeer Tank

Project tutorial by Balázs Simon

  • 23,111 views
  • 4 comments
  • 159 respects

Sentinel Security

Project tutorial by Scott Mendenhall

  • 4,775 views
  • 0 comments
  • 31 respects

Helium Solar Monitoring Board with Relays

Project tutorial by Jade Perreault

  • 3,575 views
  • 2 comments
  • 18 respects
Add projectSign up / Login