Hi! my name is Daniel, as a foreword let me just mention that this project’s ultimate goal is to raise funds for a charity trip to Zambia I am participating this Fall to build houses for orphan kids. But let’s go to the fun stuff first!
What is S0lRider?
- Why Sol or Solar? ... well, this robot is charged by solar energy
- Why Rider? ... Rider as in Knight Rider’s TV show, yeah S0lRider can be controlled via voice commands from your (Pebble) smart watch in addition to an Android App… last but not least S0lRider has also red scanner lights :).
Still want to know more? great! Please check steps below for a listing of parts used to build S0lRider, diagrams, source code and lessons learned into building this robot.
… Now if you don’t mind me asking if you find this project inspiring, useful, just kind of cool please consider donating for my fund raising cause here.
Donations will go to Habitat for Humanity Great Britain which is the charity organization I am participating with in the house build. ANY amount no matter how small or big is wholeheartedly welcomed!
Alternatively tweeting about S0lrider or sharing it on Facebook is much appreciated.
Step 1: Parts Needed
I tried to chose as much as possible cheap parts and recycled some materials. Actually doing a quick calculation of the cost of the parts used in the robot itself (not counting the phone and Pebble watch or tools used to put it together) the cost would be in the range of $45-$55 depending on the chassis and battery option you choose. Please note that S0lRider can work with just the phone app, Pebble watch is used if you want to send voice commands like Michael Knight used to do ;)
- Esp8266-12 board. Chose this one for its price and also because it incorporates a voltage regulator chip on it.
- Chassis (2 motors, 2 wheels, 1 universal wheel). Note: I used this 4 wheels chassis to give the S0lRider more a car look and because of future improvements, however the pieces would fit in a smaller chassis like this 2 wheeled one.
- Dupont jumper wires (male to male, female to female). This can be seen an overkill because you can reuse and solder ordinary cables but I explain later why for building things for a first time or prototyping it may make sense to employ these easily attachable/detachable wires.
- Old power bank (now discontinued). Tried other power banks and they worked well, make sure they provide 1.5Amps or more.
- Android phone. Tested on Motorola Moto E (Android 4.4.4 kitkat) and Samsung Galaxy A3 (android 5.0.2 Lollipop)
- Small bread board Red led x 5
- Solar panel 12 volts 3w polysilicon solar cells
- Recycled laptop packaging for bumpers
- Diode, considered optional for this specific layout as the power bank should not emit current back on its own charging port to the solar panel.
- Spare microusb cable I cut in two parts
- Ubec voltage converter
- Voltage meter
- Switch: 6pin Dpdt 3 states On-off-on
- L293d chip
- Pebble Time: S0lRider can also work without it as the android app provides a joystick.
- Ferrero rocher recycled plastic case to hold switch firm to chassis
- Nylon Ties
Step 2: Tools & Programs Used
- USB to serial converter
- Computer to at least load program ESP module and potentially flash it if ESP module doesn't come with NodeMCU (windows, Linux or Mac would work).
- Wire cutter
- Soldering iron plus associated kit. Despite I used a breadboard to interconnect things some of the connections needed soldering (i.e. jumper wires to main switch)
- Glue gun
- Screw driver
- Stripping pliers
- Small wrench
- Insulating tape
- Android Studio: for coding the android app.
- ESPlorer: for coding the ESP module.
- esptool.py: to initially flash ESP board with NodeMCU firmware
- CloudPebble: yes you can code your Pebble app in the cloud! :)
Step 3: Connecting Components
I have tried to build a design in which part are easy to assemble and disassemble, assembling should be straight forward. The fritzing diagram provided will help you to clearly identify which part is connected to each of the pins and components.
Step 4: Installing the Various Binaries and Programs
Please see below links to download the various compiled components to install on your Android phone, Pebble watch and ESP8266 firmware and Lua app. Note you will need Pebble Watch App installed on your Android Phone.
- NodeMCU firmware file I used (check a tutorial here)
- S0lRider Lua programs (for ESP8266 module)
- Compiled Android app. You will need to allow installing self signed apps.
- Compiled Pebble Time (PBW) App
Alternatively if you want to make changes to the various apps I provide the source code too:
- Source code of Android app
- Source code of Pebble Time App
Step 5: Notes on Pebble App
Pebble puts at your disposal great tools and documentation to code your own applications, S0lRider’s Pebble app was actually built on the cloud on Pebble’s fantastic CloudPebble online IDE.
- It was the first time I used an online/cloud IDE and despite some minor glitches it worked very well. One of the glitches is that the debugging on physical watch option does not work well because of web browser’s web socket security restrictions.
- Still you can use the CloudPebble emulator that appears on the upper left corner after compiling an app; however some functions such as dictation or communication don’t work on the emulator.
- To overcome to this situation you would have to run the app you just compiled on your physical Pebble. The fastest way I found to do this is to have CloudPebble open on the smartphone where the official Pebble Watch application (not to confuse with S0lRider’s android App described below) is running and click on download PBW after compiling. After downloading and opening it will be automagically installed on your physical Pebble Watch.
- The middle button of Pebble Watch starts a dictation/voice session so that you can send commands to Pebble. The accepted commands are up, down, right, left. Up and down was used instead of “forward” and “backward” as the latter are longer words.
- Once the command is given you have to press the middle button again and it will be sent to S0lRider via the Android App. So it is first transferred to the Android app via Bluetooth and then from the Android App forwarded to the S0lRider car via WiFi.
- The car will hence start moving, to make it stop you have to press the down button of Pebble Watch.
- As you show on the video S0lRider will also “blink” its lights if you shake your Pebble Watch. In the future improvements sections it will be evaluated using the Pebble accelerometer to actually move the car too.
Step 6: Notes on the Android App
S0lRider’s Android App is coded in Java using AndroidStudio. AndroidStudio can seem a bit complex initially, mainly because of the various files that come to play when coding an Android app; however once you get used to them AndroidStudio becomes a great tool to develop Android Apps. Besides there is also abundant information and forums out there (StackExchange).
- As mentioned below in the credits the Android App joystick functionality was built based on the great joystick application example provided by AKexorcist. Several upgrades were added to AKexorcist joystick example support communicating with PebbleWatch to receive voice commands and accelerometer instructions and to forward these orders to the ESP8266 chip on S0lRider’s car.
- Pebble communication occurs over Bluetooth and Pebble Android libraries takes care of this. Communication with S0lRider car itself (the ESP8266 chip) occur over WiFi, over UDP to be more precise. Android Java TCP/IP libraries are used to handle this communication.
- The default option to connect S0lRider’s Android app with the car is to start a hotspot on your phone, this is an option existing in majority of Android phones today and it is trivial to do. An alternative is also provided if your phone didn’t support hotspot creation, see note 1 below.
- The ESP8266/LUA application has to have the correct ESSID configuration and password to be able to connect to your hotspot. Android phone’s have the required menus to define the ESSID of the hotspot you want to create and the associated password.
- Once S0lRider car has connected to the hotspot on your phone, the car must be obviously on, you will notice in your phone’s hotspot configuration that the car connected and its given IP address.
- Armed with this we just need to specify the car’s IP address on the S0lRider application as displayed on the picture below.
- Once the IP address is properly configured move the joystick by pressing the circle on your phone screen or pressing the light button.
Note 1: There is an alternative option if your android phone does not have the capability of hotspot/creating an access point. An alternative LUA/ESP8266 app is provided whereby the car starts an access point and you connect to it with your phone.
Note 2: Creating a hotspot on your phone is also needed so that when using Pebble you still have data access. Pebble dictation API requires your phone to be able to connect to the Internet, if you connect to an AP created by the car using the note 1 above your Android phone would try to connect to the internet via the car and fail to do so.
Step 7: Notes on Lua/ESP8266 Program
The program running in S0lRider’s car brain is an inexpensive yet powerful ESP8266 chip from ExpressIF. The chip is in this case was sold soldered into a development board that facilitates access to the various pins. The ESP8266 chips typically come with a default firmware that needs to be upgraded to NodeMCU firmware which support the LUA code used for S0lRider.
The process for upgrading the ESP8266 chip can be found on my other blog here.
Some quick notes regarding the three files provided:
- init.lua: executes after boot time, it contains an timer/delay and then launches either the default S0lRider car application or the alternative.
- s0lriderPebble.lua: S0lRider Lua program to run when using Pebble and want to send voice commands. Because the dictation API requires internet access if you would set the ESP module as an Access Point your phone would lose Internet access as Wi-Fi has priority over GSM/4G data networks. Therefore in this mode you need to set your android phone as hotspot for S0lRider to connect to it.
- s0lrider.lua: S0lRider Lua program when your phone doesn’t support creating a hotspot or you are not using use Pebble and hence you are not using Pebble dictation. The car/ESP8266 becomes a wireless access point you connect with your phone.
The code within s0lriderPebble.lua and s0lrider.lua basically starts up a UDP server. UDP (a best effort protocol) was found preferable over TCP as it has a faster response time, something desirable for a moving robot. Additionally the Lua code sends instructions via 4 pins to a L293D (dual H bridge) to control the two motors based on the UDP packets received from the Android App. Finally this Lua code also takes care of activating the red scanner lights.
Step 8: Other Cheaper Alternatives
One of options to obtain a cheaper version of the car could be using single batteries instead of a power bank. Therefore I am providing another design/build option for those ones that want to try, It adds a bit of complexity but it can help reduce costs.
It basically consist of using the following:
- 2 x Li-ion 3.7V 18650 Rechargeable Battery. I tested with these Canwelum batteries because they comes with a safety circuit. There are other brands and cheaper unbranded batteries but makes sure they come at least with protection circuit to avoid potential surprises.
- 2 x Li-ion battery charging circuit.
2 x battery holder to host the Li-ion batteries.
Reuse the 3 position switch described in sections above and remove the power bank.
Various internet sources don't recommend charging and using the batteries at the same time, for this reason we can use the 3 position switch to alternate between a charge and running state as described in this great Adafruit post.
Step 9: Credits & Acknowledgements
Shouts to the people below that helped me in this project:
- Credits to Akexorcist for making the source code of a basic joystick application I recycled.
- Thanks Joseph Vitolla for helping me with advise on solar panels and electric engineering.
- Julio Fernandez Gomez-Aleixandre from which I got inspired to add the red scanner lights to the car.
- Julian Ilett a sort of personal legend/idol in general electronics and gadgets reviews, check his YouTube channel out.
- Soundtrack song of the video is a rework of the original Knight Rider TV show produced by like2upload
- Last but not least wanted to acknowledge the We Care Solar. A truly inspiring organization that promotes safe motherhood in developing regions using solar electricity.