Control a relay on/off state using bluetooth

After establishing Bluetooth communication between the Blink Board and a smartphone, we can implement a simple yet highly practical project to control a relay’s ON/OFF state. This project showcases the power of wireless communication for remote control applications, offering an excellent starting point for smart home automation.

Using Bluetooth commands, you can toggle the relay’s state via a Bluetooth terminal app on your smartphone. Whether you want to control lights, fans, small motors, or even security systems, this setup demonstrates the versatility of Bluetooth communication.

The Blink Board will receive commands (“ON” or “OFF”) from the app. Based on these commands, it will control the relay:

Sending “ON” will activate the relay and allow power to flow to the connected device.

  • Blink Board 
  • 12V/24V Power Supply – Make sure you’re using an appropriate supply for your setup.
  • FTDI (USB-to-Serial Adapter) – This is required for programming and debugging the Blink Board.
  • Bluetooth Terminal App – A smartphone app that facilitates Bluetooth communication with the Blink Board. We recommend using a Serial Terminal App (look for the app with the familiar terminal logo).
  • Relay Module

Objectives

  • Remote Control: Enable wireless control of a relay using Bluetooth commands.
  • Practical Application: Demonstrate a simple setup that can be adapted to control appliances or devices
  • Scalability: Lay the foundation for expanding to more relays or adding sensors for automation.
  • Real-Time Feedback: Observe the relay state through an LED indicator on the Blink Board.

How It Works

  1. Bluetooth Communication:
    The Blink Board listens for commands from the Bluetooth terminal app. These commands are sent as plain text (“ON” or “OFF”) and processed in the loop.
  2. Relay Control:
    • When “ON” is received, the Blink Board sets the relay pin HIGH, activating the relay and powering the connected device.
    • When “OFF” is received, the pin is set LOW, deactivating the relay.
  3. Feedback Mechanism:
    • The app receives confirmation messages (“Relay ON” or “Relay OFF”) for each command.
    • An optional 20×4 LCD displays the current state of the relay.

CONNECTING 20by4 I2C LCD WITH BLINK BOARD

Now that your hardware is set up and your code is running, it’s time to test the system!

  1. Open the Bluetooth terminal app on your smartphone and connect to the Blink board.
  2. Send the command ON to turn the relay ON (which will also activate the connected device).
  3. Send the command OFF to turn the relay OFF (which will deactivate the device).
  4. Observe the LED indicator on your blinkboard as it lights up when the relay is activated and goes out when the relay is deactivated.

You can expand this project by adding multiple relays, creating an app interface with more control options, or even integrating sensors to make it a more automated system. Bluetooth’s wireless convenience makes this a great starting point for smart home projects, and the possibilities are endless!