Introduction: Make:it Robotics Starter Kit – Wireless Connectivity
In this blog post we are going to take the information that we learned in the earlier blog post entitled “Make:it Robotics Starter Kit – Software Part 2″ and capture real time sensor data and send this data wirelessly to our computer.
In order to complete this section we need to purchase a few items:
RF Radio Transmitter and Receiver, (5 volt, not a 3.3 volt)
Male Female jumper wires
In addition we will need our FTDI USB cable, or a FTDI USB dongle.
I did a bit of searching on the web and found a RF Data Module Tx/Rx kit. This kit has a 315 MHz transmitter and receiver. I paid $9.00 plus shipping for this kit.
(Click on the Images to make them larger)
This male FTDI USB adapter would be more compact and have a nicer form factor for your computer. But since I already had the FTDI USB cable I will use this for the tutorial. Later if you want to make a permanent configuration, you can always order the male version of the FTDI adapter.
You can purchase any frequency transmitter/receiver kit as long as the frequencies are the same between transmitter/receiver. This blog post will explain in detail how to connect the RF radios to the robot and your computer. We will make a few small modifications to our original lineFollow.ino program. But the changes to get the robot communicating using the RF radios is pretty easy.
Check out my blog for more info:
Step 1: Transmitter/Receiver
First we must identify the components of the radios. Your kit might be different than mine, My kit did not come with any documentation. So I had to do a bit of searching on the web to find out pin configuration, transmitter/receiver identification etc.
The nice thing is there is lots of info out on the web about configuring RF radios. First let us determine which board is our transmitter and which board is our receiver. Look very closely at the pin labels on both boards that you have:
This is an image of the boards that I received. Your boards might look different.Size and number of pins will not determine which board is a transmitter or receiver.
On the above image look at the pin labels on the smaller board. The pins are labeled VCC, GND, DATA and ANT. VCC is voltage applied to the board.GND is the ground (earth) connector.
DATA is the pin that transmits the data to the outside worldANT is the Antenna. Chances are that the board that has the Antenna pin is your transmitter. Lets look at the other larger board. GND, OUT, OUT, VCC
This board is the receiver.Important, your boards may be configured differently. On your receiver you may only have one OUT, or data pin. Check the instructions that came with your RF kit or perform the same identification process that we just did in this post.
Step 2: Wire the Driver Board - Transmitter
Looking at our driver board, we need to find the following pins.
We will now wire our transmitter to the robot. Get three female to male jumpers, Red, Black and Green, if you have them, if not choose three different color jumpers and write the colors down.
Take the (Red wire) female socket end of the jumper, plug it into the pin labeled VCC on the transmitter, take the male end of the same jumper and plug it into the 5V socket on your driver board.
Take the (Black wire) female socket end of the jumper and plug it into the pin labeled GND on the transmitter, take the male end of same jumper and plug it into either GND socket on the driver board.
Take the (Green wire) female socket end of the jumper and plug it into the pin labeled DATA on the transmitter, take the male end of the same jumper and plug it into pin 5 (lower right header bank) of the driver board.
Your transmitter has been wired to the robot.
Step 3: Wire the Receiver to the FTDI Board
For the time being I just laid the transmitter on the top of the driver board for testing. Once we want to run the robot we will tuck the transmitter in away from the wheels.
Take the (Red wire) female socket end of the jumper and connect it to the VCC pin on the receiver, take the male end of the same jumper and plug into the socket of the FTDI connector that has the Red wire.
Take the (Black wire) female socket end of the jumper and connect it to the GND pin on the receiver, take the male end of the same jumper and plug it into the socket of the FTDI connector that has the black wire.
Take the (Yellow wire) female socket end of the jumper and connect it to the OUT pin on the receiver, take the male end of the same jumper and plug it into the socket of the FTDI connector that has the Yellow wire.
Your receiver has been wired to your USB FTDI.
Step 4: Modify the LineFollowing.ino Program
We now need to modify our lineFollow.ino program as the RF radio kit has slightly different requirements than our hard coded serial port does.
Here are the changes we need to make:
#define rxPin 4
#define txPin 5
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
In our definition section we need to add a counter variable that will be used to test the wireless serial port. This counter will have a data type of int.
//tell the Arduino to communicate with Make: it
PCBdelay(500); //delay 500 ms
//initialize the status of line following robot
line_following.all_stop(); //all motors stop
// set the data rate for the SoftwareSerial port
counter = 0;
In our setup() function we need to make the following changes: We need to comment out the mySerial.begin(9600); command and add the following command:
1200 is the baud rate (speed of data transfer) that the RF radios can communicate with each other. This value may be different for your radios.
Check your documentation. In my situation the radio came with no documentation, so I first tried 2400 baud, which did not work, so I then lowered the baud rate to 1200 baud, which did work.
We also initialize the counter variable to a value of 0. In the Loop() function we need to add the following:
// mySerial.println(sensor_in, HEX);
First we comment out the mySerial.printLn(sensor_in, HEX); line and add the following line:
In order to test that we configured our RF radios properly we just want to send some numbers to our workstation. Later when we make sure that our RF connections are working we will change the mySerial.printLn() back to what it was before.
These are all of the changes we need to make.
Just attach the USB cable to the Arduino USB connector on your robot. we will first compile and upload the program to our Arduino.
Remember we need to check to make sure that we are using the correct serial port number, Check the earlier blog entry “Make:it Robotics Starter Kit – Software Part 2″ for details on how to accomplish this task.
Remember you do not need to turn on the battery box switches in order to have the robot communicate across the serial port.
Once your lineFollow.ino program has uploaded to the Arduino, plug your FTDI USB cable into your computer. Load the Arduino IDE, select the correct serial port and open the Serial Monitor program. Select the correct baud rate, in my case I selected 1200 baud.
If you performed all of the tasks correctly then you should see the following in your serial monitor program. Your program should look a bit different as this screen shot was taken from the ATMEL Studio IDE:
If your serial monitor is receiving, what appears to be a lot of junk characters or a bunch of question marks.
Then either your baud rate on the serial monitor does not match the baud rate you set in your lineFollow.ino program or you need to change the baud rate that the program is using as the RF radios may not support this baud rate:
It is also easy to corrupt the serial port, so in many situations, it is best just to unplug all of the USB ports and try again, maybe even rebooting your computer if you cannot get it to work.
In the next blog, tutorial we will setup the lineFollow.ino program to send sensor data to our computer while the robot is running around the black circle sending real time data to our computer wirelessly.
We have a be nice policy.
Please be positive and constructive.