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.
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.
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.
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.
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!
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.