Voice Controlling Led Using odinub

Hello everyone, in this blog we are going to understand the voice controlled led using Odinub with ADAFRUIT IO and IFTTT. To do this project you have to understand INTERFACING OF ADAFRUIT IO AND IFTTT
So let’s get started,

first of all we want Adafruit IO library installed in our board.


Step1: to install Adafruit IO make sure you are connected to internet In Odinub. If not then follow the below step.


Ifup wlan0


Is you are getting any error to connect the wifi then visit the link here.


Step 2: Now, we are going to install Adafruit IO libray In Odinub board.
For that open the Odinub terminal and fire the below command.


pip install adafruit-io


After firing this command you will get the below output which is shown in given image.

 

 

After installing Adafruit IO library it’s time for hardware part. We are using led here to control it by Google Assistant. Here we only need to connect odinub with led nothing other than that.


Hardware Requirement:
Odinub     
Odinub Converter
LED
Resistor
Breadboard
Jumper wire


Pin connection:

GPIO 21 Anode of  Led(long leg)
GND PIN  Cathode of  Led(short leg)

 

 

Now we are going to connect the hardware for that you will need above component.
Connect LED Anode(A/long leg) to GPIO 21 and Led Cathode(C/short leg) to gnd pin of  odinub.


Step 3: After hardware connection we have to make the code which is work with “project name”. for that we have to make a directory using below command


mkdir <directoryname>


now to go that directory.


cd <directoryname>


Step 4: Now we have write the code in the editor you can use any of your favourite editor. here I am using Nano as editor. Don’t worry I am attaching the code below so can take as reference.


Sudo nano <filename.py>


Now we have to save the file using ctrl+x y enter

 

Code Explanation:


We are doing code in python langauage.now we have to import packages in python code to do voice controlling with Adarufruit-io using google assisatance. 

nubio is for accessing  Odinub gpio, time is libray which we are using to give delay.

import nubio
import time
from Adafruit_IO import Client,Feed,Data


We are using gpio 21 as output so we have to declare it in code. We are writing below line to make it output


nubio.pinMode(21,"OUTPUT")


For software part we need our adaruit io account username and AIO KEY. To get username and AIO KEY of your adafruit io account goto your adafruit io dashboard in your light1 feed. At the right top corner you see AIO KEY click on that. You can get your username and AIO KEY from there.

 

 

aio=Client('YOUR USERNAME','YOUR  AIO KEY') 


To receive value(on/off) from Adafruit IO we have write below line,


        value=aio.receive('light').value
        print(value)


We are giving condition using if else to light on led when we say “turn led on”  and light off led when we say “turn led off”. When we say “turn led on” it will get value ‘1’ and value ‘0’ when we say “turn led off”. We are using while condition to continuously run our program.

        if( value=='1'):
                nubio.digitalWrite(21,"HIGH")
                print("high")
        else:
                nubio.digitalWrite(21,"LOW")
                print("low")

 

Step 5: Now we have to run the voice control.py file using below command.


Python<your_filename.py>

in my case my file name is voice_ control
Python voice_control.py


To stop running program press ctrl+z.


Developers are always welcomed to share their ideas and projects! Do let us know below if you find this helpful. Thank you.
 

Code :
Code Title :
Code Language :
python
0 Commenting Overall Comment