WiFi RC Rat
That plush rat is so nice! What if we could control it from the phone? :D
Choosing the Electronic Parts
To control it from the phone, we need:
- Bluetooth or WiFi module,
- microcontroller,
- 2 H bridges
- 2 motors
- battery
- Android phone or tablet
- RoboRemoFree app
Choosing the WiFi Module
I chose the HUZZAH ESP8266 because:
- it has NodeMCU firmware and can run lua scripts, so we don't need an additional microcontroller
- it has at least 4 free GPIOs
- it can be powered from 3.5 to 16V
Uploading Init.lua to ESP8266
The "init.lua" file contains the script that receives commands from WiFi and controls 4 GPIO pins that will be connected to H bridges. This file must be written to the ESP with filename "init.lua" so it will run at power on.
There are several ways to upload a file to ESP.
Here is how I do it (on Ubuntu Linux)
- Connect ESP to USB using an USB to Serial adapter (like FTDI)
- open CuteCom
- select device /dev/ttyUSB0 and baudrate 9600
- select LF line end and char delay 100ms
- click open device
- send some enters to make sure it is connected ok (it should answer with ">")
- open "luapaste.lua" with gedit and select all and copy
- paste in CuteCom and press enter and wait..............
- send the text "luapaste.lua"
- paste again the luapaste code
- now the ESP has "luapaste.lua" file, so next time you don't have to repeat these steps.
- close CuteCom
- open moserial Terminal
- select LF end
- click port setup and select select device /dev/ttyUSB0 and baudrate 9600 and uncheck handshakes
- click connect
- send some enters to make sure it is connected ok (it should answer with ">")
- send dofile("luapaste.lua")
- send the text init.lua
- paste the code from "init.lua" file
- send node.restart()
- it should answer something with "ESP8266 RC rat 1.0 powered by RoboRemo"
- close moserial Terminal
- disconnect the ESP
Installing the RoboRemo Interface
Here is how to install the interface:
- install RoboRemoFree from Google Play
- copy the "rc rat.interface" file to the "roboremo" folder on the SD card
- open RoboRemoFree and choose menu -> interface -> import, and select the interface file
Downloads
Choosing the H Bridges, Motors and Wheels
The H bridges, motors and wheels should be small, so they can fit under the rat. Of course you can buy a dual H bridge, but it is much more fun to build it with SOT23 transistors (enjoy the videos). Building motors is not so easy, so I bought 2 Micro Metal Gearmotors (with gear ratio 30:1). I used 2 rubber stoppers as wheels.
Downloads
Connecting the Motors and Testing the H Bridges
Dual H bridge is alive and kicking :D
Fixing All Together With Hotglue, Tape and Plastic Fasteners
Fixing all the electronics under the rat, and making some tests. The image shows how to connect the HUZZAH ESP to H Bridge. It is all powered by a LiPo cell. The foolproof diode is not the best solution, because it lowers the voltage to the ESP too (which already has one diode)
The Rat in Action
Enjoy :)