Arduino Robot RF Explorer – Part 2 – Putting Everything Together

Arduino Robot RF Explorer – Part 2 – Putting Everything Together

Click here to read Part 1 of this Article>

arduino robot

In Part 1, we discussed several important steps in building an explorer robot. We designed and created our own PCBs using Eagle. In Part 2, we will be adding the rest of the parts and test the program to make sure that the RF robot functions the way it’s supposed to. The explorer robot we design here will be able to travel autonomously, sense its surroundings, and transmit the collected data wirelessly. The goal of this project is to prototype an explorer robot, equipped with a set of sensors such as temperature and pressure, which will be able to send collected information in real time with the help of digital radio communication modules (RF).

Hardware

  • Arduino Uno
  • 2x Transceiver NRF24l01+
  • 2x Pololu motors 100:1
  • 4x Wheels
  • Voltage regulator
  • Crystal
  • L298
  • nRF24L01
  • Barometric pressure sensor BMP085
  • Distance sensor HC-SR04

Software

Tools

  • Eagle CAD

 

arduino robot

Figure 1: RF Robot Setup from Part 1

Step 1:The structure and the mechanical part

The remote will take information from laptop’s USB port and redirect it via the second nRF24l01+ module. It will be composed of the Arduino board and a board with NRF connector and supply which will be mounted above the Uno to avoid using wires.

arduino robot

Figure 2: The remote schematic

arduino robot

Figure 3: Remote PCB

arduino robot

Figure 4: The remote with NRF24L01+ mounted connected to Arduino Uno

You will see that we incorporated two LEDs which signal the circuit’s functionality and the other components discussed above. We’ll include little coolers for overheating protection for the voltage regulator and the NPN transistor as well. The circuit board will be positioned above the batteries as shown below in Figure 5.

arduino robot

Figure 5: The remote mounted above the batteries

Step 2: Module

We’re using nRF24L01+ wireless transceiver module. nRF24L01+ is an ultra low power wireless RF transceiver. Using this module is the best choice when it comes to such an application. It is one of the most popular models because of its great performance and cheap price. Its common communication protocol enabled it to gain a huge global software support.

nRF24L01+ Datasheet

Specifications:

  • Working frequency 2.4GHz – 126 channels
  • Speed: 250kbps, 1 and 2 Mbps
  • Transmitter: 11.3mA at 0dBm output power
  • Maximum power: 100mW (because of preamp)
  • Interface: 4-pin SPI – Payload: 32 bytes
arduino robot

Figure 6: NRF24L01+ module

To obtain pressure and temperature data, we’ll use a Sparkfun BMP085 barometric pressure sensor. It offers measurement from 300 to 110 kPa with an error of 0.03 kPa. BMP085 also provides a temperature measurement from 0 to 65 °C. The supported voltage must not exceed the interval 1.8-3.6V and the connection is made directly with the microcontroller by l2C.

BMP085 Datasheet

Specifications:

  • Interface(l2C)
  • Wide barometric pressure range
  • Wide supply range
  • Very low current consumption
  • Measurement with low noise
  • Completely calibrated
  • Motion sensor included
arduino robot

Figure 7: BMP085 barometric pressure sensor

Now we will mount HC-SR04 ultrasonic sensor. HC-SR04 has detection range of 2-200 cm. The microcontroller sends an impulse to the sensor which emits sound wave. When the sensor knows that the wave has returned it sends an impulse back to the microcontroller. This calculates the difference between when the impulse was sent and the moment the impulse is received and thus calculates the distance:

𝐷=(𝑡2−𝑡1)×170

 

arduino robot

Figure 8: HC-SR04 distance sensor placed at the front of the chassis

Step 3: Data route

The Arduino platform provides predefined functions which spares the user of configuring some registers. There are libraries that allow interfacing the platform with many other peripherals. The programming is done in a very simple way with a single Arduino-PC cable. The board comes equipped with a USB-UART converter.

In this project, two programs are needed: one for the robots functioning and another for the remote. The two programs communicate with one another by radio with the help of nRF24101+ module. The data flow diagram is shown in Figure 9. There are two ways. Direct way: First, the information is being sent by the application to Arduino. Then the information taken over by the transceiver is further sent down to the second transceiver and then back to the microcontroller. This takes decisions for the control of the physical movement of the robot.

arduino robot

Figure 9: Data flow diagram

Reverse way: the controller takes the information from the sensors and processes them and sends them to OTA (on the air) in order for them to finally reach PC.

Step 4: The application

The application was done with Microsoft Visual Studio 2010 using the Visual C# programming language. Having a very intuitive interface, Visual Studio combines the visual elements with the programming part. This helps achieve some very complex applications. The application sends commands and receives data which are then displayed. The robot controller is done with the help of the keyboard arrows. The movement buttons light up as you press an arrow to indicate that the command was received. These commands are actually letters transmitted in serial that are meant to reach the robot controller to be interpreted. For example, when you press the “Up” key, the application sends “U” on the serial port by USB. The interpretation table of the commands is shown below:

Letter Action
U Go on
R Turn right
D Move backward
L Turn left
N Update
B Turn on the lights
O Send PWM value

To achieve this we have implemented the following algorithm: the application sends the LED “turn on” command and then the remote control takes the command and sends it to the robot. Once the robot receives the command, it turns on the LEDs and sends an instruction to the application to turn on the light indicators. We have introduced this algorithm to avoid desync (the case in which the LEDs are off and the indicator is on).

Another important issue was the import and display of information in the interface. To make the application differentiate the information and know where to display it, we have implemented the following method: Once the robot receives information from the remote control, it does not simply forward it but it processes it and sends commands as follows: “CMD: TE =” + val.marime. The application will know that once retrieved an information that starts with “CMD” through the serial port should remove “:” and read the following two letters that refer to the field where the information will be written. The “val. marime” is read after “=” and for the above example, the program will know how to assign it to the temperature field.

In order to make the application recognize two simultaneous key presses we have initialized a variable for each key. When a key is pressed, the event increments its variable to 1; when it released another, the event decrements it to 0. A timer continually evaluates these variables.

arduino robot

Figure 10: Design the application

Step 5: About Program

This time the robot uses a program compiled in Arduino IDE, having greater complexity than the remote control program:

  • This has defined functions for forward/backward movement, cornering, turning on the lights, calculating the distance, temperature and pressure.
  • The main program is an infinite loop that evaluate continuously whether the radio module receives something, and if so, it evaluates the input code.
  • If it matches one preset instruction in the program, it executes the corresponding function according to the letter received.
  • When it receives the command to deliver the information from the sensors, it performs a number of functions to collect that information, planning to introduce them in a vector to be transmitted.
  • If we refer to the movement functions, when received the letters “U”, “D”, “R” or “L” it executes a command for 20 ms. Although this is a very short period of time, by holding down the keys on the laptop keyboard a series of commands will be sent successively and very quickly.

Step 6: The Codes

1. The remote

 

2. The robot

 

arduino robot

Figure 11: Complete RF robot

arduino robot

Figure 12: Assembled RF robot (side view)

Now we have built an autonomous arduino robot that is capable of self-navigating and collecting data from the surrounding environment! It was quite challenging but very rewarding project. The prototype can be further improved such as including housing case for protection in rough terrains/environments. Please feel free to share with me if you have any suggestions for further improvement!