IoT RC Car With Smart Lamp Remote or Gateway
by marciot in Circuits > Arduino
2029 Views, 3 Favorites, 0 Comments
IoT RC Car With Smart Lamp Remote or Gateway
For an unrelated project, I had been writing some Arduino code to talk to the MiLight smart lamps and lamp remotes that I have in my home.
After I succeeded in intercepting commands from the wireless remotes, I decided to make a little RC car to test out the code. It turns out the 2.4GHz remotes used in these lamps have a 360 touch ring for selecting hues and it works surprisingly well for steering a RC car!
Additionally, using the MiLight gateway or the ESP8266 MiLight hub, you can control the car from a smartphone or any Internet connected device!
The Origin of This Project
This project is based on a line of wireless smart bulbs that came to market a few years ago. They were initially sold as LimitlessLED, but have since been available under alternative names, such as EasyBulb or MiLight.
While these bulbs are often sold as being WiFi compatible, but they have no WiFi capabilities and instead rely on a gateway that takes commands sent via WiFi and translates them into a proprietary 2.4GHz wireless protocol. If you get a gateway, the bulbs can be controlled from a smartphone app, but if you don't, you can still control these lamps using standalone wireless remotes.
These bulbs and the remotes are proprietary, but there have been efforts to reverse engineer the protocols and to build open-source alternatives to the WiFi gateway. This allows for some interesting possibilities, such as using the remotes for your own Arduino projects, as demonstrated in this Instructable.
Getting the Right Remote
The MiLight bulbs and remotes were never meant to be open and thus there is no official documentation on the protocols. There have been several different generations of the bulbs and they are definitely not interchangeable.
This project makes use of the remote for one of the four types of bulbs that are available and knowing how to distinguish the types visually will help you buy the right remote. The four types are:
- RGB: These bulbs have controllable hue and brightness; the remote has a color wheel and three white toggle buttons.
- RGBW: These bulbs give you a choice between a hue and a single shade of white; the remote has a color wheel, a brightness slider, three yellow effects buttons, and four yellow group toggle buttons.
- CCT: These bulbs are white light only, but allow you to vary them from warm white to cool white; the remote has a black control ring and white push buttons.
- RGB+CCT: Bulbs can show colors and can vary from warm white to cool white; the remote is the most cluttered of the four and can be distinguished by a color temperature slider, some odd crescent shaped buttons and a blue light bar around the edges.
This project was made with the RGBW remote and will only work with that style of remote. If you want to try making this project yourself, be sure you get the right remote as they are definitely not interchangeable*
DISCLAIMER: *Also, I can't absolutely guarantee this project will work for you. It is possible the MiLight people may have changed the protocol used in the RGBW remote since I bought my own several years ago. As this would cause incompatibilities among their products, I suspect it is unlikely, but the risk is there.
Using With a WiFi Gateway and Smartphone
If you have a MiLight WiFi gateway, either an official one, or the DIY ESP8266 MiLight Hub, then you can also control the car using the MiLight smartphone app on a phone or tablet.
While the radio protocol used by MiLight bulbs is not WiFi compatible, the hub works as a bridge between a WiFi network and the MiLight network. The RC buggy behaves like a lamp would, so adding the bridge opens up the interesting possibility of control the RC buggy from a smartphone or from a PC via UDP packets.
Other Components
Three of the components came from the SparkFun Inventor's Kit v4.0, these include:
- Hobby Gearmotor - 140 RPM (Pair)
- Wheel - 65mm (Rubber Tire, Pair)
- Ultrasonic Distance Sensor - HC-SR04
The distance sensor is not used in my code, but I put it on my buggy because it looks kind of cool as faux headlights, plus I figured I might use it later to add some collision prevention capabilities.
The other components are:
- Ball Caster Omni-Directional Metal
- An Arduino Nano
- Arduino Nano radio shield RFM69/95 or NRF24L01+
- A L9110 motor driver from eBay
- Male to female jumper cables
You will also need a 4 AA battery holder and batteries. My pictures show a 3D printed battery holder, but you'll need to buy the spring terminals separately and it's probably not worth the effort!
You will also need a 3D printer to print the chassis (or you could fashion it out of wood, it's not too complicated).
A Word of Caution:
I used an inexpensive Arduino Nano clone and found that it got very hot when running the car for any significant amount of time. I suspect that this is because the 5V regulator on the inexpensive clone is under-rated and cannot deliver the current needed for the wireless radio. I measured that the Arduino and radio draw only 30mA, which is well within the specs for the voltage regulator on a genuine Arduino Nano. So if you avoid the clones, I suspect you won't have an issue (let me know in the comments if you find otherwise!).
Testing the Arduino and Remote
Before assembling the RC buggy, it is a good idea to check whether the remote can talk to the Arduino through the radio module.
Begin by stacking the Arduino Nano atop the RF shield. If the USB connector is facing left on the top side, the wireless PCB should be facing right on the bottom side.
Now, plug the Arduino Nano into your computer using a USB cable and upload the sketch I have included in the zip file. Open the serial monitor and push a button on the remote. The light should light up on the remote (if not, check the batteries).
If all goes well, you should see some messages in the terminal window each time you press a button. Run your finger around the color touch wheel and observe the changing values of "Hue". This is what will steer the vehicle!
Make sure this step works, as there is no point proceeding if it doesn't!
Downloads
Printing and Assembling the Chassis
I have included the STL files for the 3D printed parts. For the CAD files, you can look here. There are three parts, a left and right motor bracket and the chassis.
The left and right motor brackets can be attached to the motors using wood screws. Then, the motor brackets attach to the chassis using M3 nuts and bolts (or glue, if you prefer). The caster attaches to the front of the chassis using four screws and bolts.
Adding the Electronics
Bolt the stepper driver on the chassis and attach the wires from the motors to the screw in terminals on the driver. I used the following wiring:
- Left motor red: OB2
- Left motor black: OA2
- Right motor red: OB1
- Right motor black: OA1
Run power from the positive side of the batteries to the Vcc on the stepper driver PCB and Vin on the Arduino. Run the negative side of the batteries to the GND on the GND on the Arduino. You will need to solder up a Y cable to accomplish this.
Finally, complete the electronics by using jumper wires to connect the following pins on the Arduino to the stepper motor driver:
- Arduino pin 5 -> Stepper Driver IB1
- Arduino pin 6 -> Stepper Driver IB2
- Arduino pin A1 -> Stepper Driver IA1
- Arduino pin A2 -> Stepper Driver IA2
Testing the Robot
Now, push the buttons and see if the robot moves! If the motors seem reversed, you can either adjust the wiring on the robot, or you can simply edit the following lines in the Arduino sketch:
L9110 left (IB2,IA2);<br>L9110 right(IA1,IB1);
If the left and right motors need to be swapped, exchange the numbers in the parenthesis, as such:
L9110 left (IB1,IA1);<br>L9110 right(IA2,IB2);
To reverse only the direction of the left motor, swap the letters in the parenthesis for the left motor, as so:
L9110 left (IA2,IB2);<br>
To reverse the direction of the right motor, swap the letters in the parenthesis for the right motor, as so:
L9110 right(IB1,IA1);
That's all! Good luck and have fun!