<<<<Previous Blog     Next Blog>>>>

 

Audio & Visual Cue System for Anosmia (Smell Disorder) and Smart WheelChair - Ft. Amazon's Alexa

Week 10: Sep 4 - 10

     This week progress has been spent on exploring the gas sensors (MQ-2 & MQ-5) and getting things ready to machine learn smell for the 'Cue System for Anosmia' section of my project. There are two units: the main unit (which can be kept in the living room) with Arduino MKR1000, gas sensors (MQ-2 & MQ-5) and Bluetooth module which will act as the master & another extra unit (which can be kept in other rooms like Kitchen, Dining etc., ) with Arduino UNO, gas sensors (MQ-2 & MQ-5) and Bluetooth module which will act as the slave. The main unit will collect the voltage variation in correspondence with the smell, from the four gas sensors and feed it to the machine learning service which will decipher what the smell is! Based on the smell detected, if it falls into the dangerous smell category (smoke/ fire / poisonous gases) Arduino MKR1000 will trigger the relay (to turn OFF the appliance like an electric stove or turn ON the exhaust fan) connected to the Arduino UNO through Bluetooth. Alexa will help the person suffering from Anosmia by alerting about the potential danger. If it is a non-dangerous smell, then Alexa will again help in identifying it by giving an audio cue of the smell. Also, the person can have a visual cue of the smell in the mobile app.

 

 

Revision

 

     It is late but at least now I realized that the Bluetooth communication between master and slave can be one-way communication and the other way will be an acknowledgment. As per the initial plan, the gas sensor data from the extra unit to the main unit should be through Bluetooth. But I have now revised it (considering the time to complete) and made it as a transfer through wire/ connection through a wire. The gas sensors will be powered up by the extra unit and the analog values from the sensors will be transferred to the analog pins in Arduino MKR1000. Then, the Arduino MKR1000 will feed all four values to the IoT Platform. However, the relay control will still be through Bluetooth and there is no change in it. So for the extra unit to be placed in a separate room, you can just extend the wire between the main and extra unit.

 

     If I have had an extra Arduino MKR1000, I would have replaced it with the Arduino UNO in the extra unit. That way the communication to the 'thinger.io' platform would have been two gas sensor values from the main unit and two from the extra unit. Now all four will be from the main unit.

 

Data Transferred to Thinger.io

 

     The image below shows a graphical and textual representation of data from gas sensors connected to Arduino MKR1000, sent to thinger.io

 

     Below is the video which shows the real-time graphical and textual representation in thinger.io of data received from the gas sensors connected to Arduino MKR1000 and how they react to various gaseous smells. Later these data will be stored in an excel sheet in .csv format which will then be fed into a machine learning service.

 

 

Gas Sensors

 

     To know how a gas sensor works, check this link. The reasons why I chose MQ-2 and MQ-5 as the pair of gas sensors are,

    • They are useful for gas leakage detection in home and industry.
    • They are suitable for detecting Alcohol, which I will be using for the experimental purpose.
    • They have easily accessible pins in the breakout boards which can be connected to Arduino and other development boards with ease.

 

     Other than these two gas sensors, we have much more types of gas sensors. Find some of them by clicking here. I should mention here dougw's contribution to the discussion Is it possible to transmit and receive smell? (link to his comment - click here) which has been helpful to know about the link between chemicals and their smells (I thank him again for this). Find it below.

 

esters

 

Machine Learning

 

     Much of the machine learning part will be discussed in the next and final blog. I am planning to use the AWS machine learning service by Amazon. The input for this will be the data from gases sensors connected to Arduino MKR1000 fed to thinger.io IoT platform which will be compiled into a .csv file and fed into the service for machine learning. YouTube Video Reference - Link. The outcome is the identification of smell.

 

 

 

List of Hardware and Software Involved

 

     Below is the list of hardware and software involved in the making of the 'Smart WheelChair' system. Click on the names in order to be directed to the site where you can buy or access the resource.

 

     Hardware

 

     Software

 

Circuit Connection

 

     Below is the circuit connection diagram of the 'Cue System for Anosmia' part of my project. This comprises of the gas sensor pair (MQ-2 and MQ-5) and the Bluetooth modules (master-slave) connected to the Arduino MKR1000 and Arduino UNO. Apart from this, there are two DC fans connected at the front which will act as an inhaler and cooling system, as the gas sensor tend to heat up (they are designed to heat up and obtain corresponding voltage variation for the gas in the environment). These fan's power adapters are connected to the extension board which is in turn connected to the four channel relay module. All these are packed up in a case. For more information about the case / complete hardware of my project - visit this link - Cue System for Anosmia and Smart WheelChair #7 - Hardware Explained and Case

 

Master Bluetooth - Arudino MKR1000

 

     The LEDs are for the purpose of alerting and status.

 

Gas Sensor Main Unit

Slave Bluetooth - Arduino UNO - After Revision

 

     The Arduino MKR1000 belongs to the 'Main Smell Sensing Unit'. This has been placed here to show how it is connected through wire after the revision of the initial plan.

 

Slave Bluetooth - Arduino UNO - Before Revision

 

Gas Sensor Extra Unit

 

Code

 

     The code for the 'Cue System for Anosmia' part of my project is provided below. For GitHub repository page, Click here.

 

Master Bluetooth - Arudino MKR1000

 

/* This is the code for the 'Cue System for Anosmia' part of my project deisgned for the Element14 Community's 'Design for a Cause' design challenge, 
 *  sponsored by Arduino. In particular, this is for the main smell sensing unit with Bluetooth Master Arduino MKR1000.
 * 
 * Design Challenge Page - https://www.element14.com/community/community/design-challenges/designforacause/blog
 * 
 * Blog Link - https://www.element14.com/community/community/design-challenges/designforacause/blog/2018/08/03/cue-system-for-anosmia-and-smart-wheelchair-8-gas-sensors
 * 
 * Author : Dixon Selvan
 * Date   : September 09, 2018
 * Project: Cue system for Anosmia and Smart WheelChair
 * Website: 
 * 
 * Hardware components Required (Extra Unit)
 * ----------------------------------------
 * 1. Arduino MKR1000 board
 * 2. Gas Sensors (MQ-2 & MQ-5) pair - x2
 * 3. Bluetooth module
 * 4. ProtoShield/ Breadboard and Few Jumper wires
 * 5. 12V Power Adapter
 * 6. DC Fan
 * 
 * Connections
 * -----------
 * Arduino MKR1000  |   Bluetooth Module
 * ---------------------------------------------
 *      5V          |         +5V
 *      Gnd         |         Gnd
 *      RX          |         RX     
 *      TX          |         TX
 * Arduino MKR1000  |   Gas Sensors (MQ-2 & MQ-5)
 * ---------------------------------------------
 *      5V          |         VCC
 *      Gnd         |         Gnd
 *      -           |         D0     
 *      A0/A4/A5/A6 |         A0
 * Arduino MKR1000  |   LED (Green/ Red)
 * ---------------------------------------------
 *      D1          |   Positive of Green LED      
 *      D2          |   Positive of Red LED
 *      Gnd         |   Negative of both the LEDs
 *
 * Connecting Arduino MKR1000 with thinger.io, getting started guide - http://docs.thinger.io/arduino/
 */


/*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);
  pinMode(A0, INPUT);
  pinMode(A4, INPUT);
  pinMode(A5, INPUT);
  pinMode(A6, INPUT);
    
  /*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["Relay State"] << [](pson& in){
      relayState = in["state"];
      changeRelayState();
  };


  /*The gas sensor values are sent as an output resource to the thinger.io*/
  thing["MQ-5 (E)"] >> [](pson& out){
      out = analogRead(A0);
  };


  thing["MQ-2 (E)"] >> [](pson& out){
      out = analogRead(A6);
  };


  thing["MQ-5 (M)"] >> [](pson& out){
      out = analogRead(A4);
  };


  thing["MQ-2 (M)"] >> [](pson& out){
      out = analogRead(A5);
  };
}


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

 

/* This is the code for the 'Cue System for Anosmia' part of my project deisgned for the Element14 Community's 'Design for a Cause' design challenge, 
 *  sponsored by Arduino. In particular, this is for the extra smell sensing unit with Bluetooth Slave Arduino UNO.
 * 
 * Design Challenge Page - https://www.element14.com/community/community/design-challenges/designforacause/blog
 * 
 * Blog Link - https://www.element14.com/community/community/design-challenges/designforacause/blog/2018/08/03/cue-system-for-anosmia-and-smart-wheelchair-8-gas-sensors
 * 
 * Author : Dixon Selvan
 * Date   : September 09, 2018
 * Project: Cue system for Anosmia and Smart WheelChair
 * Website: 
 * 
 * Hardware components Required (Main Unit)
 * ----------------------------------------
 * 1. Arduino UNO board
 * 2. Gas Sensors (MQ-2 & MQ-5)
 * 3. Four Channel Relay Module
 * 4. Bluetooth module
 * 5. ProtoShield/ Breadboard and Few Jumper wires
 * 6. 12V Power Adapter
 * 7. DC Fan
 * 
 * Connections
 * -----------
 * Arduino UNO      |   Relay Module
 * ---------------------------------------------
 *      5V          |         VCC
 *      Gnd         |         Gnd
 *      IN1         |         D10     
 *      IN2         |         D11
 *      IN3         |         D5
 *      IN4         |         D6
 * Arduino UNO      |   Bluetooth Module
 * ---------------------------------------------
 *      5V          |         +5V
 *      Gnd         |         Gnd
 *      RX          |         RX     
 *      TX          |         TX
 * Arduino UNO      |   Gas Sensors(MQ-2/ MQ-5)
 * ---------------------------------------------
 *      5V          |         VCC
 *      Gnd         |         Gnd
 *      A0/ A1      |         A0     
 *      -           |         D0
 *      
 */


/*Declaration and initialisation of Variables*/
int mq2 = A0;
int mq5 = A1;
int Relay1 = 10;
int Relay2 = 11;
int Relay3 = 5;
int Relay4 = 6;
int serialData = 0;


void setup() {
  /*Assigning GPIO pin modes*/
  pinMode(mq2, INPUT); 
  pinMode(mq5, INPUT);
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  pinMode(Relay3, OUTPUT);
  pinMode(Relay4, OUTPUT);


  /*Starting the Serial Communication*/
  Serial.begin(38400);


  /*Setting the Relay Pin to LOW State*/
  digitalWrite(Relay1, HIGH);
  digitalWrite(Relay2, HIGH);
  digitalWrite(Relay3, HIGH);
  digitalWrite(Relay4, LOW);
}


void loop() {
  /*Send the Sensor values to Master/ Serial Port*/
  sendGasSensorValue();
  relayStateMonitor();
}


void sendGasSensorValue(){
  /*Send data from gas sensors as comma separated values to Arduino MKR1000 Serially (BT)*/
  Serial.print(analogRead(mq2));
  Serial.print(',');
  Serial.print(analogRead(mq5));
  Serial.print(',');
  Serial.println();
}


void relayStateMonitor (){
  /*Listen to the master Arduino MKR1000 and turn ON or OFF the respective relay*/
  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); 
     }
  } 
}

 

Have you got any suggestion or comment? Let me know in the comments section below.

Progress made so far,

|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 90%

 

<<<<Previous Blog     Next Blog>>>>