In our latest project named DIY your ReSpeaker Adapter(Voice Control), we introduced how to control adapter using your voice, but it can only control switch-signal appliances, such as table lamp fan and so on.
This time I’ll show you how to use your voice to control some complex household appliances like smart TV and air conditioner using the new thing ReSpeaker, which can allow you to interact with the world using your voice. In this case, we need to use Infrared remote controller to control them. Fortunately, the ReSpeaker has a coprocessor ATmega 32U4 which makes it compatible with Arduino Leonardo, So I use the Arduino side to learn IR Command code as well as send the IR Commands to control the complex appliances.
Step 1: What Do We Need
- ReSpeaker Grove Extension Board
- Grove – Infrared Emitter
- Grove - Infrared Receiver
- Speaker (8Ω 0.5W)
- Micro SD Card(larger than 4GB)
- M3*10 Pillars —— 4 PCS
- M3*20 Pillars —— 4 PCS
- M3*35 Pillars —— 4 PCS
- M3*12 Screws —— 8 PCS
- M2*10 Pillars —— 3 PCS
- M2*8 Swcews —— 3 PCS
- M2 Nuts —— 3 PCS
- WoodPaperScrew driver
Step 2: Wiring
Now, we should connect the Grove Modules to the Grove Extension Board for ReSpeaker.
And connect the speaker to the ReSpeaker.
Step 3: Setup the ReSpeaker
The software work of the social artifact consists of 2 parts, the code running on Arduino side and the python script running on the MT7688 side. The communication between the two chips are UART and SPI.
Connect ReSpeaker to your PC using micro USB cable, if your computer can’t recognize it as a USB device, you can download the driver from here.
Now, using your favourite SSH Tools connect to ReSpeaker.
Baud rate: 57600
Terminal App: For windows, putty is recommend. For Linux/Mac, use screen /dev/xxx 57600
Connect MT7688 to the Internet
Modify the configure file to change MT7688 into station mode and connect to the internet.
Change the configure file as below shows.
Change the ssid and key to your own on the red box as the picture shows.
Option disabled ‘0’ option ssid‘your ssid’
option key‘your key’
Then reboot your ReSpeaker.
To have a try ping a website to ensure your ReSpeaker have connected the internet well.
Step 4: Upload the Arduino Code
1. Download demo code at GitHub.
2. Click “Download zip” button on right side of webpage to download all codes.
3. Decompress the downloaded zip files to“C:\Users\Administrator\Documents\Arduino\” and remove “-master” in decompressed file name.
4. Launch Arduino IDE.
5. Click Sketch>Add file to add irLearning.ino file from“C:\Users\Administrator\Documents\Arduino\IRLearning_ReSpeaker\Arduino_IRLearning\irLearning\”
6. Click Tools -> Board and select “Arduino Leonardo” and chose the right port, as shown in the picture below.
7. Press CTRL +U to upload codes to your board. Wait a while, there will be saying “Done uploading”.
8. Congratulations, you have already completed the whole of the work.
Step 5: Download the Code
Insert the micro SD card to the ReSpeaker SD slot. Now, we should download the code from Github to your micro SD card.
root@mylinkit:/# cd /Media/SD-P1 root@mylinkit:/tmp/run/mountd/mmcblk0p1#
When navigating to /Media/SD-P1, the system will mount the SD card to /tmp/run/mountd/mmcblk0p1 automaticlly. And then execute the following commands.
Step 6: Change the Code
After download the code, you can use vi editor to change the code, in this project, we use Microsoft cognitive services, You can get the API Key from here.
And then, change the BING_KEY to your own.
Step 7: Setup the Startup Script
Navigate to /tmp/run/mountd/mmcblk0p1 by execute following commands:
root@mylinkit:/# cd /Media/SD-P1
Then create a file named autorun
And add the following code.
#!/bin/shamixer sset Capture 90% cd /tmp/run/mountd/mmcblk0p1/IRLearning_ReSpeaker/IRLearning
python demo.py &> /dev/console &
At last, reboot your ReSpeaker.
Step 8: Laser Cutting
Download the file and laser cut it.
Here's we use 3mm wood and coated paper.
Step 9: Fixed ReSpeaker on Wood
Here we can use M2*10 pillars and M2 nuts Fixed ReSpeaker, *then use M2*12 fixed it to the wood.
Step 10: Fixed the Speaker on Wood
Here fixed speaker and paper on wood by two M3*10 pillars, Note this, Only use 2 pillars to fixed it now. then connect speaker and ReSpeaker.
Step 11: Fixed Grove – Infrared Emitter and Grove - Infrared Receiver
- Here we need make the cables through the hole, then use M2 screws and M2 nuts fixed grove - infrared emitter and grove - infrared receiver on wood.(Image 1-2)
- Then put the PCB on ReSpeaker and fixed the M3*35 pillars on wood.(Image 3-4).
- Fixed the wood by M3*20 pillars.(Image 5)
Step 12: Fixed the Paper
Remember the holes we only used two~ Now at other holes we can fixed on paper and wood. then we can use double-sided adhesive to fixed the paper to wood.
Step 13: Drawing on Paper
Only white paper too boring, so here I draw some of my favorite things to make this remote controler more interesting~
Step 14: The Result
Now, you can ask the ReSpeaker to learn your IR commands.
Me: “Start learning IR command”
ReSpeaker: “Okay, start learning”
And now you can send IR command to Grove - IR Receiver using appliance ir remote controller. Then you can say.
Me: “Stop learning”
ReSpeaker: “Okay, stop learning”
Then you can ask ReSpeaker to control the appliance that you let it learn to.
ReSpeaker : “Hi”
Me: “Control the air conditioner”
ReSpeaker: “Okay, send IR command ”
And you’ll find the air conditioner will change according to the IR command.
Make. Invent. Do.
This project is made as an Open Source Project. It's a starting point. Let your creativity go wild with the mechanical, electrical and software design. Make the demo your own. Decorate it. Improve the work. No matter what, write a recipe about it.
To share and progress together.