Tips and Tricks (Part 20)

Previous tip and trick

Acquiring data is great, sending data away is even greater. In this way, all sorts of physical measurements can be remotely read in order to capture events, record signals, trigger alarms, etc.

More and more communication solutions exist, each of them having their advantages and drawbacks. The aim of this post is not to provide an exhaustive list of them. However, let’s mention the most popular devices and protocols from the Arduino planet:

  • Xbee/ZigBee: versatile, pretty low power, from cheap to costly
  • RF12: cheap, low power, limited range and functions
  • GSM/GPRS: almost universal, power greedy, expensive

The Xbee modules have a very particular foot print which features 2x 10 pins with 2mm spaces. Many makers addressed the need for Arduino compatible shields, including the Arduino team it self (Check this thread). This particular shield features a sliding switch which allows the user to manage data exchanged between the Xbee module and the micro controller unit (MCU) or the USB cable.

switch1 switch2

But the principle of sharing Rx Tx lines from Arduino has strong limitations, mainly when you need to upload code to the Arduino board, while the shield and the Xbee module are attached to it.

Here is a very easy (almost trivial) trick which will release some of your stress. The idea is to leave the Rx Tx pins in peace with the MCU while applying no non-reversible changes to the electronics or PCB from the shield. This is how:

Take an Arduino board

UNO

Slightly bend the Rx Tx pins from the shield so that they no longer get into the Arduino board socket

shield_pins

Plug the shield on the Arduino board

assembly_pin_in_a

Place one jumper between Rx pin and digital pin 2 and one jumper between Tx pin and digital pin 3

jumpers1

Instead of using the commands from the Serial library, use the commands from any soft serial library (This one for example) and link the pin 2 and 3 to the receive and send pins.

#include <SoftwareSerial.h> // Include library
SoftwareSerial mySerial(2, 3); // Create object and declare Rx and Tx pins

void setup()  
{
    mySerial.begin(9600); // initialize comm port
}

void loop(void)
{
    mySerial.println("AT"); // Send any instruction to the comm port
    while(true); // Run once
}

That’s all! Under these conditions, the shield will perform as before and blink as it should. In addition, you re now free to use the Serial commands for debugging your application.

HTH

Next T&T

Leave a Reply

You must be logged in to post a comment.