Smartphone Controlled Wheel Robot

ESPresso Lite V2.0 is a Wi-Fi development board which uses ESP8266 chipset as the main micro-controller and supports the Arduino environment. With this board, user can start building systems that can transfer data wirelessly through internet. In this tutorial, we want to share the method to control dc geared motor rotation in order to produce basic movement of wheeled robot using MQTT Websockets Panel. The command will be entered on this panel to move the robot in desired direction. For the demonstration, a differential wheeled technique with two driven wheels and one castor wheel is used. The mobile robot movement is based on two separately driven wheels placed on either side of the robot body. It is done by varying the relative rate of rotation of its wheels and hence does not require an additional steering motion.

Assemble the Hardware

1. We will use Dual Channel 10A DC Motor Driver to drive two DC geared motor. OLED display will be used to facilitate configuring Espresso Lite V2.0 to have internet access.
2. Referring to the following figure, do the wiring to connect all the hardware. Power will be supplied to the circuit after all the wiring is done.

3. Connect left motor to M1A and M1B port and right motor to M2A and M2B port.
4. Connect the battery to the MDD10A. Make sure the battery is connected with correct polarity. It is important to check and double-check any wiring before adding any power source to your project.
5. To check the movement of the left motor and right motor,
Press button M1B and M2B, the motor should rotate forward.
Press button M1A and M2A, the motor should rotate backward.
If the motor move in opposite direction, just change the polarity of the wire motor on MDD10A.
6. After all of the connection is completed, build a simple robot using this two DC Geared Motor, MDD10A and Espresso Lite V2.0 based on your creativity.

Communication Setup

1. Espresso Lite V2.0 board configuration to have Internet access in AP mode.
a) To switch between the modes, press the button of GPIO13 for a few second until the Espresso Lite v2.0 restart.
b) When the board is in ‘AP mode’, the LED will produce an intermittent burst of short blinks. OLED display will show the board information.

c) The Espresso Lite v2.0 now became as an access point, so connect to the access point.

d) Open Internet browser and insert the IP address 192.168.4.1

e) A box will appear, choose one of the Wifi network and press Submit.
f) When the Oled screen show “connected”, that mean the network is successfully connected with the board.

2. Creating Cloud Account.
a) ESPert provides a free cloud service account with selected features for anyone who wants to build their own IoT applications.
b) Go to http://espert.io and register to create account.
c) Try login to website to make sure user account is activated.

3. MQTT Broker.
a) MQTT (message queue telemetry transport) handles the transfer of data from the ESPresso Lite to espert.io.
b) Go to http://espert.io/mqtt and click on Connect to start connection with the Espert.io MQTT broker via MQTT Websockets Panel.
c) Please ensure that the host will be mqtt.espert.io and port is 8000.

d) For example, to rotate the motor that control by ESPresso Lite, key in {“DIRECTION” : <state>} in the message box and press Publish.
e) Please type ESPert/xxxxxxxx/Command in the Topic box where xxxxxxxx is your board id.

f) To display a message on MQTT Websockets Panel, try click to Subscription.
g) A dialog box will appear where you need to use your board id to create the topic in the format below: ESPert/xxxxxxxx/#.

h) Once the correct topic is entered and subscribed, a series of messages will appear.

Arduino IDE Programming

DIR1 and DIR2 of MDD10A are connected to GIO2 and GIO14 of Espresso Lite V2.0 respectively. The purpose of these connections is to control rotation direction of DC Geared Motor. DIR1 represent the rotation direction for motor 1 and DIR2 for motor 2. For example, if GIO2 give HIGH signal, motor 1 will rotate clockwise (CW) and vice versa. PWM1 and PWM2 of MDD10A are connected to PWM pins of Espresso Lite board to generate different value of PWM to vary the speed of the DC motors. When the PWM value is 0, the connected DC motor will stop. By programming, the PWM values from 0 to 1023 to control the rotation of DC Geared Motor from fully stop to full speed. Here the procedure to write sample source code for this project:
1. Firstly, open the Arduino IDE and configure some setting which we set the board under (Tools) as Espresso Lite 2.0.

2. After that, open example “_2000_ESPert_workshop” under (File>Examples>ESpert) as shown below:

3. We modified the original code by deleted the unnecessary code that are not related to rotate DC Geared Motor when command is given through MQTT Websockets Panel.
4. Since there are no buzzer is used, the following code can be removed.

5. Same goes to the code related to DHT sensor.

6. Next, we write the setup code to set the pins as input or output in void setup() function. Also, declare temp variable as integer to put initial value of DC Geared Motor (Initial value should be between 0 and 1023) after “Espert.h” library. The sample code is as shown below:

7. Now, we can replace the code to control the rotation direction of each DC Geared Motor with the original code that control LED. The following sample code shows that it will have 5 characters to move the wheeled robot which are “F” for move forward, “B” for move backward, “R” for turn right, “L” turn left and “S” to stop the wheeled robot. The wheeled robot move forward when right motor rotates clockwise while left motor rotates counter-clockwise with full speed and backward when both motors rotate in reverse direction from previous with lower speed. To turn the robot to the right, we just simply rotate left DC Geared Motor counter-clockwise and if only right DC Geared Motor rotate clockwise will results wheeled robot to turn left. “String outString = “{\”WHEELED ROBOT\”:\”TURN LEFT\”}”;” code cause the movement status of wheeled robot is displayed on Messages dialog box of MQQT Websockets Panel. The table simplified the wheeled robot movement and sample code as shown below:

Ok, that’s all. If you have any question, feel free to ask in our technical forum as we seldom check the tutorial’s comment section. Thank you.

Attachment

1. Espresso Lite V2.0: Wheeled Robot Basic Movement Control With MQTT Websockets Panel completed sample code, download here.

BUY

, , , , , , , , ,

Related Post

Getting Started with Encoder Sensor Module (SN-ENC-MOD)

Getting Started with 3A Motor Driver Shield and Arduino Uno

#mydigitalmaker Holiday Programme 2017: IoT Home Security System with ESPresso Lite V2.0

How to Upload Arduino Codes to Arduino Yun Through WiFi

Leave a Reply

Your email address will not be published. Required fields are marked *