Example Code for Arduino-Alternate Hardware Serial for Bees

Last revision 2026/01/12

The article provides an example code for using alternate hardware serial with the Bees Shield on Arduino, detailing the necessary hardware and software setup, wiring instructions, and a sample code to facilitate the functioning of BLE LINK modules with the UNO board. It highlights the importance of correctly configuring the xBee TX & RX connections and programmable switch settings to ensure seamless communication between the Arduino and connected devices.

Hardware Preparation

  • UNO x1
  • Bees Shield x1 (SKU: DFR0210)
  • BLE LINK x2 (SKU: 1073, Purchase Link)
  • Android or iOS device x1

Software Preparation

Wiring Diagram

If you need both BLE LINK modules working with the hardware serial port alternately, you can change the jumpers and switches like so:
(You can select a pin from digital 4-12 as the xBee Enable pin to make them work. The following example uses "D4".
BLE LINK modules working with the hardware serial port alternately

Other Preparation Work

Programmable Switch:
Set the switch to "PROG" when you upload a program
Set the switch to "RUN", when you use the hardware serial port
xBee TX & RX: The silk-screen shows the xBee RX & TX pins, which connect to the Arduino TX & RX ones. It means if you define D2 as Arduino_RX in the code, you should connect to D2 to xBee_TX on the shield. The same goes for Arduino_TX.

Sample Code

/*
 # This sample code is used to test an Arduino hardware serial switch.
 # Editor : Mickey
 # Ver    : 1.0
 # Product: Bees shield
 # SKU    : DFR0210
*/

void setup()
{
  Serial.begin(115200);
  pinMode(4, OUTPUT);
  delay(500);
}
void loop()
{
  digitalWrite(4, LOW);
  Serial.println("this is Bee1 hardware!");
  Serial.println(" ");
  delay(500);

  digitalWrite(4, HIGH);
  Serial.println("this is Bee2 hardware!");
  Serial.println(" ");
  delay(500);
}

Result

The app shows the result of Bee1.
the app result of Bee1 working with the hardware serial port
The app shows the result of Bee2.
the app result of Bee1 working with the hardware serial port

The Bees Shield only has three modes above. Currently it is not possible to make two Bees work with the software serial port at the same time.

Was this article helpful?

TOP