XBee Chat Exercise:
- 2 Digi XBee.
- 2 Xbee Explorer.
- 2 cables.
- 2 Computers.
- 2 Arduino micro.
- 2 Breadboard.
- Several wires to interconnect the breadboard and Arduino.
Step1: Download software(CoolTerm) and driver(FTDI USB). The first step consists in achieving communication between two machines connected to the following set:
Step2: Change the configurations of the radio in command mode. In this second part we are going to show how we can display the information transmitted between two XBee in a screen connected to Arduino. To do that, we need to understand how the XBee Explorer works:
The pins we must connect to the Arduino in order to be able to display the information sent by the other XBee module. The input voltage must be 3V instead of 5V to avoid potential problems. The XBee Explorer is not only important to connect the XBee to the computer, but also to put it in the breadboard so as connections can be set.
1) Attach Xbees to SainSmart boards and plug into computer
2) Open two CoolTerm Sessions and click on one of the Options buttons.
3) In the Options pop-up select the COM Port of either Xbee and then go into the Terminal Tab and select Local Echo (in order to see what is being transmitted). Then press OK. No additional changes are necessary for standard comms.
4) Repeat the above step for the other Xbee in the other port. If either time you do not see the Xbee’s port as an option, or if you plug it in with the options box open, press the Re-Scan Serial Ports button show in the red box from the above image.
5) Now press Connect for each terminal and you can now type in either and it will transmit to the other. Press Disconnect when finished with the session to ensure it is available for other programs to use.
6) We need to configure XBees to enable the communication. These radios are configured with AT commands, so we learnt some basic AT commands from AT command set:
ATRE = factory reset – this will wipe any previous settings
ATMY = my address – the label on your radio
ATDL = destination low – the label on your partners radio
ATID = pan ID – the agreed upon “channel” both radios are using to communicate
ATWR = write to firmware – this will make sure the configurations are saved even when the radio loses power
ATCN = end command mode
Go to Options → Serial Port
Go to Terminal → Select Local Echo
Step 3: Let’s chat!
Once connectivity between the two XBee modules has been established, we can implement the part where we display the information on computer screen.
Metronome Receiver Device:
Use “Serial” to test the code. Change “Serial” to “Serial1” when arduino is connected to xBee and send the “H” and “L” commands via the serial monitor.
Sample Code is from Arduino example, Physical Pixel. It is an example of using the Arduino board to receive data from the computer.
Add a servo and change the Arduino code:
Connect the circuit as show in the figure below:
- The servo motor has a female connector with three pins. The darkest or even black one is usually the ground. Connect this to the Arduino GND.
- Connect the power cable that in all standards should be red to 5V on the Arduino.
- Connect the remaining line on the servo connector to a digital pin on the Arduino.
- Servo red wire – 5V pin Arduino
- Servo brown wire – Ground pin Arduino
- Servo yellow wire – PWM pin Arduino
I want to have a fan connected to the servo, so I went to dollar store and got this candy toy for 2 dollars, along with an unexpected free motor, a button and a battery.
It was my first time to use servo though we had c&c last semester. Usually, they have a servo arm that can turn 180 degrees. Using the Arduino, we can tell a servo to go to a specified position and it will go there. I don’t know how to make it work like a fan. I think I need to choose another type of servo. The code I had will turn a servo motor to 0 degrees, wait 1 second, then turn it to 90, wait one more second, turn it to 180, and then go back. I need to check if I can make it rotate in one direction(not back and forth).