Turtle v.s. Wireless Control Car — Mobile Controlled Mini Car
This is how I controlled a wireless mini car with my mobile phone movements.
This was done in April as a mini-trial project to test IoT capability and learn some basic skills. The video below is the end result!
After the video, there are explanations.
Undoubtfully, this gave me some confidence in doing projects like this.
2 months has passed. My friends Joleen and Wei Kok had come up with many creative and interesting IoT projects, such as colorful water/coke/beer dispenser for Hari Raya.
The detail is here.
Here is how the mini car control project was done.
At the beginning of the project, I was very lost and a bit worried. There were a few reasons. Firstly, I didn’t have much time. There were only 3 hours for me to do it. Secondly, the default code was written in LUO. I didn’t know anything about it. Well, I might probably be able to read it. But if you ask me to convert it into Arduino Sketch, I think perhaps I need another half a year. In addition, was the hardware okay? If any of the parts broke, it was going to be a headache to find out where was the defected part. And lastly, how about Bluemix? How could I link it with Bluemix?
With the accompany and encouragement from my friends, I started from reading this blog, http://www.rudiswiki.de/wiki9/WiFiCar-NodeMCU. This is a super technical blog. Well, no choice. With a not-so-technical mind, I read at least 10 times and finally I got an idea about what it was. Never mind, I told myself, I would learn it as I do it.
Step 1. Get the car assembled.
This was the chip we used in this project. It is ESP8266 Wifi Module. Wei Kok helped me to place it on top of a motor shield. It was easier to attach wires in this way.
After that, place it on the mini car and link the wires properly. There was a funny thing here. Due to some misconnection of wires, when the mini car first moved, one wheel is moving forward, the other wheel is moving backward. Two wheels were not going in the same direction. LOL. Well, perhaps only at this time, you would know whether the wires were correctly connected or not. Thanks to Wei Kok, the Mechanical Engineer, who assembles the car for me, including motors, wheels, etc. Except the wheel direction, the rest worked perfectly! It saved me a lot of time and energy.
Step 2. Understand the logic
I borrowed this photo from http://www.rudiswiki.de/wiki9/WiFiCar-NodeMCU again because I thought this was the best illustration diagram. The logic is to use the acceleration sensor embedded in the phone and convert the acceleration date into motor drive value. The motor then moves according to the motor drive value. At the same time, the acceleration data were captured and displayed on the website.
The enhancement I had done is to display the acceleration data in a real-time chart using Bluemix, instead of numerical data. Later I will explain how this was achieved.
Step 3. Upload the Code
Here is the code used in this project. Fortunately, it works in my case. Hope it works for you as well. I got this from here and modified it.
After you upload the code, using the method taught in my previous blogs, The Ultimate Solution for ESP8266 WiFi Arduino with Bluemix – Part 2/2 to connect the Wifi Module to your network.
Upon successful connection, you will receive the following message on the Serial Monitor.
Where to see the acceleration data? You just need to get the IP address and view it in the browser.
It is such a life-changing moment. The moment the car wheel moves, my Mr.Turtle friend greeted mini car.
Step 4. Set up the Bluemix chart
IBM employee from Switzerland had contributed a great article on how to Turn your Mobile Phone into an IoT device. Basically, what you need are
A Bluemix Account,
Download and install the Cloud Foundry Command Line Interface,
Phone.
Below is the architect. (The diagram is taken from IBM employee’s article.)
Because this step was covered in his article, I won’t repeat it on my blog. It requires a certain level of technical knowledge.
Some challenges I met here were
1. Cloud Foundry Command Line Interface. This was my first time using it. A bit unfamiliar. Fortunately, I made it at once.
2. Process messages in a Node-RED flow. You just need to follow the steps in the article. Don’t miss any steps. All of them are important. Similarly, this is my first time edit Node-RED flow, too.
3. Create a Bluemix app. Over here, you need to be patient. Because it took a long time for Bluemix to stage an app. Really a long time.
However, your effort won’t get wasted.
You just need to be patient and follow the step. The result was GREAT! You will be able to view the photo acceleration motion in different types of chart. (The diagram is taken from IBM employee’s article.)
Step 5. Design the Car Cover
Up to this step, I was able to control the mini car’s movement by tipping my phone up/down/left/right. And my phone’s movements was displayed in a chart.
Well, I thought the car looks a bit ugly. So I started decorating it. There was some plastic paper. I cut them off and made a cover.
After I made it cover, the car look like a bus. Then I decided to make it a bus. So I found some stickers and made it Bus Annie.
The tagline of Bus Annie is Share Innovation. The stickers are from redHat.
Done! Again, I felt so happy!
You can do it, too!