Introduction: Raspberry Pi Voice Recoginition Home Automation
Home Automation or Domotics is a happening field, earlier big names like CRESTRON, AMX, LEGRAND BITICHINO etc were popular solution providers. Of late a number of companies have entered the fray, now Apple, Samsung & LG too are seriously into home automation.
I began building my home automation system for my personal use eight years ago, right from inception the idea was "CUSTOMISING THE USER CONVENIENCE", My earlier system was based on a embedded chip from Tibbo, Essentially this chip/module EM1206 is used as an embedded micro web server, Ethernet to Xbee converter (SOE Serial to Ethernet).
The essence of the system is a retrofit solution, requiring no specialized wiring and can be tucked right behind the modular switch panel. I had built a AMR application based on Xbee (Maxstream) now acquired by Digi, for a client 10 years ago and was the inspiration to use the same technology again. I used both Series 1 & Series 2 modules in the home automation modules.
My Home Automation system covers...
1) Lighting controls
b) Dimming (Leading & Trailing Edge, 0-10V analog & PWM)
c) Mood lighting (RGB lights with additive color mixing & sync with Music)
2) Fan Speed control
3) Curtain/Drape controls
4) IR Blaster for...
a) AC control
b) TV control
c) Set Top Box Control
d) Home theater control
1) DVD/Blue Ray
3) Amp/AV Tuner
In This Instructable I am using a Raspberry Pi 2 as a Gateway, a serial server. This project can be broken down into 5 major
1) Loading the Raspbian OS to the SD card (5 Minutes)
2) Configuring the Ser2net on Raspberry Pi to connect to Xbee Pro S1 (5 Minutes)
3) Setting up the Raspberry Pi & Xbee S1 Pro (5 Minutes)
4) Developing the Hardware for Home Automation
5) Developing the App for Home Automation control. ( 1 Hour)
Step 1: Loading the Raspbian Image on the SD Card
What you will need...
1) A Raspberry Pi ( I am using a Pi-2)
2) A Monitor + HDMI to DVI Cable
3) USB Keyboard & Mouse
4) A 16 GB Class 10 SD card from Sandisk
5) SD card Reader (Don't have one on my Mac Book Pro)
6) A Laptop or Computer to download and burn the Raspbian image to SD card
The first step is to download the image from...
The next step is to flash the SD card with the downloaded Raspbian image, for this I use an App for MAC OS, "The Apple Pi Baker", you may download it from...
Step 2: Configuring the Raspberry Pi & Installing the Ser2net
Summary of what we will be doing...
1) Configuring the Raspberry Pi's Host Name
2) Configuring the Raspberry Pi with a Static Ip
3) Installing Ser2net
4) Configuring the Ser2net
Configuring the Raspberry Pi
Raspi-Config, the details of this are available here follow the link...
To log in to Raspberry Pi remotely, will need the IP of the Raspberry Pi. By default, the Raspberry Pi will be given an IP automatically by the router (called Dynamic IP and denoted by DHCP) upon connecting to a network. However, this can change whenever the Pi is removed from the network e.g. turn it off.
The third option in Raspi-config is...
ENABLE BOOT TO DESKTOP OR SCRATCH
You can change what happens when your Pi boots. Use this option to change your boot preference to command line, desktop, I prefer the desktop and have selected this option. You will have to reboot after you finish making the settings.
At command prompt type "sudo reboot"
This will cause the system to reboot.
Configuring Raspberry Pi with a Static IP
It will make repeated access to the Raspberry Pi via SSH much simpler, as will always know that the Raspberry Pi has the same address.
First, we need to list the network interface we currently have available:
Open a terminal session and type...
The line . . . .
iface eth0 inet dhcp
Implies that we're currently getting out IP address via DHCP, meaning it's being dynamically registered by the router. This is what we want to change!
Fist of all we need to grab some information from our router and Pi. There's a couple of command we need to run to get this info. Have a pen and paper handy! . .
Type the following in a terminal window...
This reveals your router information, the bit you want is after eth0 (the ethernet connection). . . .
eth0 Link encap:Ethernet HWaddr b8:27:eb:65:52:48
inet addr:10.0.1.125 Bcast:10.0.1.255 Mask:255.255.255.0
Write down the following information. . .(Below are my settings, please write down your settings)
Type the following....
sudo nano /etc/network/interfaces
Simply change the line that reads:
iface eth0 inet dhcp to iface eth0 inet static Then directly below this line enter the following.
inet addr – 10.0.1.125 (Pi's Current IP Address)
Bcast – 10.0.1.255 (The Broadcast IP Range)
Mask – 255.255.255.0 (Subnet Mask Address)
To clarify what each part means. . . .
address – The address you want to give your Pi, this can be any IP in the network range, but it's usually advisable to go higher rather than lower, or you could end up logging different devices to the same IP! I've selected 10.0.1.125, as we're already registered to that address (denoted by 'inet addr'), but this can be any IP address from the range 10.0.1.2 to 10.0.1.255.
netmask – The 'Mask' address we wrote down earlier. network – The router IP address, this is the 'Destination' Address was found earlier. You can also grab this off your router, it will say on the side somewhere.
broadcast – The 'Bcast' address we wrote down earlier. gateway – This is the 'Gateway' address we found earlier.
Tutorial how to set Raspberry Pi to a fixed IP.…
Installing Ser2net on Raspberry Pi...
Ser2net is a server, which accepts tenet/TCPIP connections from the network interface, routes all incoming characters to the serial port. All data received on the serial port is routed back to the connected TCPIP/telnet session.
Better to get the latest version of the Ser2net software, the procedure is as follows…
Open a terminal window and type
Next extract it with the following command
sudo tar -xzvf ser2net-2.10.tar.gz
and finally install it using the commands…
sudo make install
Once the Ser2Net is installed unnecessary
stuff (leftover files) is deleted with
sudo make clean
Time to edit the ser2net.conf file
Type the following in the terminal
sudo nano /etc/ser2net.conf
Scroll to the bottom most part of the file, here you will have to add the following lines…
BANNER:banner:\r\nser2net port \p device \d [\s] (Debian GNU/Linux)\r\n\r\n
8080:raw600:/dev/ttyAMA0:9600 8DATABITS NONE 1STOPBIT banner
Save the file by Pressing ^X, selecting Yes and confirming the file name and location.
Now it is time to take control of the Raspberry Pi’s UART,by default all data during bootup is directed to the console, we can disable this by….
Modifying the cmdline.txt located in the boot folder.
In the console window type the following…
Sudo nano /boot/cmdline.txt
Orginally it has the following…
dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
This is edited and modified to…
dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
Save the file by pressing ^X, Yes and confirming the file name and location.
The serial console will still be available to shut it off, you will need to edit…
sudo nano /etc/inittab
comment out the following line:
2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
Save the file by pressing ^X, Yes and confirming the file name and location.
Finally type …
Step 3: Setting Up the Raspberry Pi & Xbee S1 Pro
What you will need...
1) A Raspberry Pi with the latest Raspbian image installed
2) 5V@ 2Amp Power supply to power the Raspberry PI
3) Monitor + HDMI to DVI cable
4) USB Keyboard & Mouse
5) Xbee TTL/232 Adapter board
6) Connecting cable 6 Pin relimate to 6 Pin Berg
7) Ethernet cable plugged into your router having an ip of 10.0.1.1
Make connections as illustrated in the schematic, take a note to cross the TX & RX wires between the Raspberry Pi & Xbee adapter board. The power for the Xbee TTL/232 adapter board is drawn from the Raspberry Pi 40 pin connector. The Pin 2,4,6,8,10 are utilized to make connections to the Xbee adapter board, pin 2 is a dummy. These pins start exactly from the opposite end of the Rightside USB connectors as you look into the Raspberry Pi with the Ethernet & USB sockets facing down.
Once all the connections are made, power up the Raspberry, the ser2net loads up at boot up automatically, any data sent from TCPIP socket running on 10.0.1.125:8080 is routed to the serial port that is connected to Xbee, likewise any data coming from Xbee is automatically routed to the TCPIP socket running on 10.0.1.125:8080.
Step 4: Home Automation Hardware...
All my home automation control cards are built on the ATMEL AVR microcontrollers, I have designed several cards for different control applications. Some cards accept addons, most cards have 8 ch 10 bit A to D available and the functionality of these cards can be extended for enhancing the user applications. For example hall effect current sensor may be added to each Switching channel to monitor the actual load. We are in the process of developing cards with multiple communication interface and should be launching them shortly...
They will support ...
1) Amped RF Bluetooth module BT24 (Xbee socket pluggable already supported on some)
2) Xbee 865/868Mhz, Series 1 & series 2 modules (Already Supported)
3) ESP2866 Wifi module.
Step 5: Developing the App for Voice Recognition Based Home Automation Control
Choosing a development tool...
I suggest B4A, Basic4Android; I have used this software tool to build several control applications. You can build native Android applications in no time. A similar tool B4I is also available for Apple IOS devices.
The current application is available on the Google App store. Here is the link to google Play store to download the Android VrXbeeHa App…
The idea was to build a Voice Recognition control app, have used the VR library from the B4A. This uses the Google’s speech recognition engine to recognize the spoken words and phrases., a TCPIP socket connected on port 8080, and a few buttons to select the address of the room to be controlled.
Up on opening the App, a TCPIP socket is opened and attempts connecting to the Raspberry Pi on 10.0.1.125:8080. Once connected appropriate dialogue is diaplayed.
A button is used to initiate the App’s VR recognition capability. The captured words/phrases are displayed in the text field, also the phrase/word is compared with programmed commands phrases, the appropriate control string is sent out of the TCPIP socket.
This is then received by the Raspberry Pi with the pre-defined static Ip, 10.0.1.125 running ser2net, the received TCPIP string is re routed to the UART connected to Xbee, and finally this control string is now sent to the specific device through Xbee.
The list of commands supported are as follows…
1. scene 1
2. scene 2
3. scene 3
4. scene 4
5. scene 5
6. scene 6
7. scene 7
8. scene 8
9. all off
10. L1 (Repeating the same Toggles Light1 On/Off)
11. L2 (Repeating the same Toggles Light1 On/Off)
12. L3 (Repeating the same Toggles Light1 On/Off)
13. L4 (Repeating the same Toggles Light1 On/Off)
14. fan speed 1
15. fan speed 2
16. fan speed 3
17. fan speed 4
18. fan stop
19. tv on
20. tv off
21. ac on
22. ac off
23. set top box on
24. set top box off
25. volume up
26. volume down
27. channel up
28. channel down
31. change source.
We have a be nice policy.
Please be positive and constructive.
Your connection diagram is not clear how to connect all components
Can't download your raspberry voice file