The Ultimate Solution for ESP8266 WiFi Arduino with Bluemix – Part 2/2
I believe you have read The Ultimate Solution for ESP8266 WiFi Arduino with Bluemix – Part 1/2.
We ended that with Step 6. I am going to provide you the rest of the steps here.
There are a bit of codes here. Don’t worry. You just need to copy and paste into your Arduino. Read till the end, you will see something more than codes.
Before we proceed with ESP8266, let’s ask ourselves a question.
ESP8266 is the start of the IoT trend now. However, is ESP8266 IoT? Do I just do this solution for the sake of getting it connected with Bluemix?
Absolutely not! This is the start of the project Control Toy Car with Phone Motion, which I have mentioned in the beginning of The Ultimate Solution for ESP8266 WiFi Arduino with Bluemix – Part 1/2. However, we can expand the idea to a broader application by using the similar technologies. Here is where innovation comes in.
It is not about INVENTING a new stuff. It is APPLYING an existing stuff in a new area.
If we can control car with the phone motion, can we control car using our hand motion? If we can control car using our hand motion, can we control our computer using our hand motion?
I believe you have more ideas than me. Let’s go.
Step 7. Add MQTT PubSubClient library.
Download the source code from Github https://github.com/knolleary/pubsubclient/releases/tag/v2.3?cm_mc_uid=72738656162414597729665&cm_mc_sid_50200000=1460045906.
Go to Arduino. Click on Sketch – Include Library – Add .ZIP Library. Select you zip file then.
Step 8. Add ArduinoJson library. Download v5.0.7 (not old layout) from https://github.com/bblanchon/ArduinoJson/releases/tag/v5.0.7.
Use the same method above to add the zip library into Arduino.
Step 9. Download the compressed file below. Copy the code inside and paste the code into your Arduino.
ArduinoESP8266UltimateSolution
Customize this part with your WIFI information and the IoT Device credentials given by Bluemix previously.
This is the info from Bluemix.
Step 10. Use the USB cable to connect ESP8266 to your computer. There will be 2 blue flashes when it gets connected.
Step 11. Upload and Run the code.
Before you upload, check the port. If you see only 1 port, e.g., port 3. Something is wrong.
Click https://www.silabs.com/products/mcu/Pages/USBtoUARTBridgeVCPDrivers.aspx#windows to download VCP (5.3MB). Install it.
After that, go back to the Port. You will be able to see 2 ports. Select the other one.
If you see errors like this, stray ‘\302’.
This is due to non-English keyboard characters. What you can do can be pasting the code into a plain text file using English keyboard and pasting it back. Or contact me at 006584515850 to send you a error free copy of code.
Step 12. If it can run, open up the Serial Monitor.
If everything goes well, you will see something like this in the Monitor window.
Go back to see what’s going on in the Arduino.
You can see lots of red dots generated in the window at the bottom.
Then how about the Bluemix side? Perfect, you see the connection status showing up in Bluemix.
Congrats!!!
You’ve made it.
This is a small start but it means a lot.
As I mentioned in the beginning, we will try to connect the toy car to Bluemix via handphone. I will update it here whether we make it or not.
Now you believe me, you don’t have to write any code yet.
Write Calligraphy instead. :P. Click here to read Annie loves Calligraphy.
If you want to purchase any of the devices mentioned in this solution, contact Tan Wei Kok. Message me at 006584515850 for his contact.
If you have any code issue, contact Anthony Elder. Message me at 006584515850 for his contact.
If you have any questions about the steps or want to discuss about future showcase or demo in IoT, contact Annie at 006584515850.