Skip to content

Example 3 - Wireless Serial LCD

In this example, we will be using the basic serial UART example from the SerLCD tutorial. However, the wires between the SparkFun RedBoard will be replaced with a pair of BlueSMiRF v2s.

Changing the Baud Rate

Before using the BlueSMiRFs with the SerLCD, we need to make sure that the baud rates match. You can either change the baud rate on both BlueSMiRFs or the baud rate of the SerLCD. To keep the original Arduino code the same, let's change the baud rate on both of the BlueSMiRFs. This will also be a good exercise to change the baud rate using the AT Commands.

Connect a USB-to-Serial converter to the BlueSMiRF. Depending on the BlueSMiRF that you have, you may need to solder headers. Then connect the USB cable between the converter and your computer.

USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header
USB-to-Serial Converter (CH340) to BlueSMiRF v2 Header with an Additional Stackable Header

Open a serial terminal and connect to the COM port at 115200 baud. Type $$$ within 60 seconds of powering the BlueSMiRF to enter command mode.

BlueSMiRF v2 Connected to Serial Terminal and in Command Mode
BlueSMiRF v2 Connected to Serial Terminal and in Command Mode

Type AT-SerialSpeed=9600 to change the baud rate to match the SerLCD's baud rate (which is set to 9600 baud by default). Enter ATW to save the settings.

Configuring the Baud Rate of the BlueSMiRF v2
Configuring the Baud Rate of the BlueSMiRF v2

Now that the first BlueSMiRF v2 is configured, repeat the same steps explained above to change the baud rate of the second BlueSMiRF v2.

Hardware Hookup

Replacing the connection with the BlueSMiRFs is similar to the basic serial UART connection listed earlier in this tutorial. We'll be using it as a guide to wire everything up. Since the SerLCD is only receiving data to display, we only need to use its RX pin.

From the microcontroller, you will need to wire the following pins. Since the BlueSMiRF v2 includes logic level circuitry on the TX and RX pins, we can wire the SparkFun RedBoard Plus directly to the pin when the switch for the microcontroller's logic level is set to 5V. Notice that we are only wiring software serial TX pin since we are just sending characters from the microcontroller to the SerLCD. Users that want to also connect software serial RX pin can also wire the connection to the BlueSMiRF v2's TXO but it is not necessary. We will assume that we are using power supplied from a USB port or USB power supply.

SparkFun RedBoard Plus
(ATmega328P) Pinout
Transmitting BlueSMiRF v2
Pinout
7 RXI
5V VCC
GND GND

On the SerLCD side, we can simply insert the BlueSMiRF v2 in the SerLCD's USB-to-serial 1x6 header. For users that are using the BlueSMiRF v2 with headers and soldered male header pins on the SerLCD, you can place them in a breadboard. A 9V power supply and barrel jack adapter was used to power both boards. The + pin from the adapter was connected to the SerLCD's RAW pin which is regulated down to 3.3V. Of course, the - pin from the adapter was also connected for reference ground.

Receiving BlueSMiRF v2
Pinout
SparkFun 16x2 SerLCD
RGB Backlight (Qwiic) Pinout
Power Supply (5V TO 9V)
with Barrel Jack Adapter
TXO RX
VCC +
RAW +, Center Positive Pin
GND GND -, Sleeve

If you have not already, make sure to upload the Arduino example code from the basic serial UART example. For your convenience, the code shown below was pulled from the OpenLCD's Serial Examples folder. Select the board (in this case, the Tools > Board > Arduino AVR Boards (arduino) > Arduino Uno) and COM port that the board enumerated to. Then hit the upload button.

/*
 OpenLCD is an LCD with serial/I2C/SPI interfaces.
 By: Nathan Seidle
 SparkFun Electronics
 Date: April 19th, 2015
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

 This example shows how to display a counter on the display over serial. We use software serial because if 
 OpenLCD is attached to an Arduino's hardware serial port during bootloading  it can cause problems for both devices.

 To get this code to work, attached an OpenLCD to an Arduino Uno using the following pins:
 RX (OpenLCD) to Pin 7 (Arduino)
 VIN to 5V
 GND to GND

*/

#include <SoftwareSerial.h>

SoftwareSerial OpenLCD(6, 7); //RX, TX

byte counter = 0;

void setup()
{
  Serial.begin(9600); //Start serial communication at 9600 for debug statements
  Serial.println("OpenLCD Example Code");

  OpenLCD.begin(9600); //Start communication with OpenLCD
}

void loop()
{
  //Send the clear command to the display - this returns the cursor to the beginning of the display
  OpenLCD.write('|'); //Setting character
  OpenLCD.write('-'); //Clear display

  OpenLCD.print("Hello World!    Counter: "); //For 16x2 LCD
  //OpenLCD.print("Hello World!        Counter: "); //For 20x4 LCD
  OpenLCD.print(counter++);

  delay(250); //Hang out for a bit
}

With both boards powered, follow the steps to pair and connect the two BlueSMiRFs together. If all is well, you should see the RedBoard Plus transmitting the same message to the SerLCD. Instead of a wired connection, a pair of BlueSMiRF's were used!

Wireless Serial LCD
Wireless Serial LCD with the RedBoard Plus

Try adding a Qwiic-enabled device like the Human Presence and Motion Sensor - (STHS34PF80) to the RedBoard Plus and writing code to display a message notifying you when someone has passed by a door. Then place the SerLCD by your desk so that you can monitor the traffic.