<<<<Previous Blog Next Blog>>>>
Audio & Visual Cue System for Anosmia (Smell Disorder) and Smart WheelChair - Ft. Amazon's Alexa
Week 8: Aug 21 - 27
The Smart Wheelchair has the following three sections: temperature monitoring, fall & collision detection, and home appliance control. These will be covered in a four-part blog series, the last part being the integration part. This blog is about the 'Home Appliance Control' section of the Smart Wheelchair and this is a continuation of phase I changes in Cue System for Anosmia and Smart WheelChair #8a - Home Appliance Control. For the collection of this project's blogs published so far, visit this link and for the detailed plan of the 'Smart WheelChair' visit this link. This week progress has been mainly on the Phase II of the 'Home Appliance Control' section which is the Alexa integration. Alexa will instruct the Arduino MKR1000 in terms of what home appliance it has to turn ON/ OFF. For the completed integrated code of the 'Temperature Monitoring' and 'Fall and Collision Detection' sections, visit this GitHub page.
Smart WheelChair [Part 3 of 4]
Temperature Monitoring | Fall & Collision Detection | Home Appliance Control | Integration
Introduction
The ‘Home Appliance Control’ section of the Smart Wheelchair will provide the ability to voice control the power to home appliances like TV, mobile chargers etc. Alexa will listen to the voice command, then process it and pass on the desired action to be taken, to the Arduino MKR1000. The main smell sensing unit will have the Arduino MKR1000 whereas the extra unit will have the Arduino UNO connected to the four channel relay module. The instruction will be communicated through Bluetooth between the master Arduino MKR1000 (main unit) and the slave Arduino UNO (extra unit). In correspondence with the instruction, the respective relay will be turned ON or OFF. For instance, if you command, Alexa, charge my phone, then the relay associated with the phone charger will turn ON and will start charging your phone.
The process goes like this when you instruct Alexa, the instructions are understood by Alexa and it calls out the respective applet in IFTTT. Then IFTTT triggers the respective action for the obtained input from Alexa. The action would be to pass a POST request to thinger.io with JSON body as below. This has the input variable 'state' passed to the Arduino MKR1000 through its API in thinger.io. Based on the state passed Arduino MKR1000 (master) communicates the corresponding relay to be turned ON/ OFF to the Arduino UNO (slave) connected to the Relay module. For instance, 1 - Turns the mobile charger ON and 2 - Turns OFF the mobile charger, 3 & 4 for the next relay ON & OFF and 5 & 6 for the third relay.
{ "in": { "state": 1 } }
For the list of hardware and software involved and the circuit diagram, visit this blog - Cue System for Anosmia and Smart WheelChair #8a - Home Appliance Control. For the explanation and idea about the complete hardware setup for this project, visit this blog - Cue System for Anosmia and Smart WheelChair #7 - Hardware Explained and Case
Code
The code for Phase - II (with Alexa) of the 'Home Appliance Control' section of the smart wheelchair is provided below. For GitHub repository page, Click here.
Master Bluetooth - Arudino MKR1000
/*Disabling the secure TLS/SSL connection*/ #define _DISABLE_TLS_ #include <WiFi101.h> #include <ThingerWifi101.h> #include "arduino_secrets.h" /*Declaring Variables*/ int relayState = 0; /*Create an account in thinger.io and replace username below with that username. Create a new device and replace deviceId, deviceCredential below with the one you had created.*/ ThingerWifi101 thing(SECRET_USERNAME, SECRET_DEVICEID, SECRET_DEVICECREDENTIAL); void setup() { pinMode(LED_BUILTIN, OUTPUT); /*Serial initialisation*/ Serial1.begin(38400); /*Replace the below accrodingly with your WiFi SSID and password*/ thing.add_wifi(SECRET_SSID, SECRET_PASS); /*The relay state is obtained as an input resource (integer/ number) from thinger.io*/ thing["Test"] << [](pson& in){ relayState = in["state"]; changeRelayState(); }; } void loop() { thing.handle(); } void changeRelayState(){ if(relayState == 1) { digitalWrite(LED_BUILTIN, HIGH); Serial1.print(1); } else if (relayState == 2){ digitalWrite(LED_BUILTIN, LOW); Serial1.print(2); } else if(relayState == 3) { digitalWrite(LED_BUILTIN, HIGH); Serial1.print(3); } else if (relayState == 4){ digitalWrite(LED_BUILTIN, LOW); Serial1.print(4); } else if(relayState == 5) { digitalWrite(LED_BUILTIN, HIGH); Serial1.print(5); } else if (relayState == 6){ digitalWrite(LED_BUILTIN, LOW); Serial1.print(6); } }
Slave Bluetooth - Arduino UNO
int Relay1 = 10; int Relay2 = 11; int Relay3 = 5; int Relay4 = 6; int serialData = 0; void setup() { // put your setup code here, to run once: pinMode(Relay1, OUTPUT); pinMode(Relay2, OUTPUT); pinMode(Relay3, OUTPUT); pinMode(Relay4, OUTPUT); Serial.begin(38400); digitalWrite(Relay1, HIGH); digitalWrite(Relay2, HIGH); digitalWrite(Relay3, HIGH); digitalWrite(Relay4, HIGH); } void loop() { // put your main code here, to run repeatedly: if(Serial.available()>0){ serialData = Serial.read(); Serial.println(serialData); if (serialData == 49){ digitalWrite(Relay1, LOW); } else if (serialData == 50){ digitalWrite(Relay1, HIGH); } else if (serialData == 51){ digitalWrite(Relay2, LOW); } else if (serialData == 52){ digitalWrite(Relay2, HIGH); } else if (serialData == 53){ digitalWrite(Relay3, LOW); } else if (serialData == 54){ digitalWrite(Relay3, HIGH); } else if (serialData == 55){ digitalWrite(Relay4, LOW); } else if (serialData == 56){ digitalWrite(Relay4, HIGH); } } }
Outcome
Below is the video showing a demo of the outcome for the phase II of the 'Home Appliance Control' section with Alexa integrated.
Have you got any suggestion or comment? Let me know in the comments section below.
Progress made so far,
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 60%
Top Comments