Events

:

:

Elektronik | Funk | Software

Der Technik-Blog

  • Social Media

    Werbung:


    New Posts


    Events

    • Keine zukünftigen Events vorhanden

    The Tech-Blog

    iOS iPhone HC08 Bluetooth Module Arduino

    Arduino HC-08 Bluetooth Module

    Alex @ AEQ-WEB

    There is also a video on YouTube for this article: Arduino HC08 Bluetooth Module - LED control with iOS and Android (German)

    In this article we show how to connect the HC-08 Bluetooth module to the Arduino Uno board. This module is compatible with Apple iOS and is also used with an iPhone in this review. Of course, the module also compatible with Android. The sample code for Arduino can switch the on-board LED (pin 13) with two commands.

    How to connect the HC-08

    The module works with 5 volts, which means that the 5 volt power supply can be taken directly from the Arduino. In addition to the two lines for the power supply two more data lines are needed. The data transmission works via a serial connection with 9600 baud rate at pin 11 and 12. By default, pins 1 and 2 can be used. But we also want to see an output at the SerialMonitor in. Therefore we access the SoftwareSerial connection on pin 10 and 11. The module comes preconfigured and does not need to be configured anymore.

    Werbung:

    HC-08 Pairing with iOS and Android

    The module is very easy to pair and is compatible with all newer devices that support the BLE standard. For the first connection, the manufacturer recommends the App LightBlue. If you want to connect your Android smartphone you can download BLE Scanner from Google Play Store. Then you need another app that can send commands to the module. It works like the serial monitor of the Arduino IDE. However, the connection does not run here via a COM port but via Bluetooth.

    HC-05, HC-06 vs HC-08

    You can also use two other Bluetooth modules with your Arduino. The other modules are unfortunately not compatible with Apple but cheaper. With the HC-05, the Bluetooth name can be changed relatively easily and a password can also be configured. However, the HC-05 and HC-08 modules can only run in slave mode. So if you want to actively build a connection from the module to another device, you can only switch to the HC-06. You can order the modules between 5 to 20 euros

    Arduino Example Code

    The example code can execute received commands. In addition, when the command is executed, the arduino send a feedback back via Bluetooth. There are two commands that can switch the integrated LED on pin 13.

    led_on: This command turn the LED on.
    led_off: This command turn the LED off.

    The code converts the received data into a string. The string can then be compared with an IF query and trigger appropriate actions. In addition, all received commands are also displayed in the Serial Monitor on your PC.

    Werbung:

    #include <SoftwareSerial.h>
    
    SoftwareSerial btSerial(10, 11); // RX, TX PIN
    
    String bt_rx;
    int ledpin = 13;
    
    void setup() {
      Serial.begin(9600);
      pinMode(ledpin, OUTPUT);
      btSerial.begin(9600);
    }
    
    void loop() {
      if (btSerial.available()) {
        bt_rx = btSerial.readString();
        Serial.print("Received:");
        Serial.println(bt_rx);
        if (bt_rx == "led_on") {
          digitalWrite(ledpin, HIGH);
          btSerial.println("LED turned on");
        }
        if (bt_rx == "led_off") {
          digitalWrite(ledpin, LOW);
          btSerial.println("LED turned off");
        }
      }
    }


    Info: This page was automatically translated and may contain errors
    122X122

    About the Author

    Alex, the founder of AEQ-WEB. He works for more of 10 years with different computers, microcontroller and semiconductors. In addition to hardware projects, he also develops websites, apps and software for computers.

    Top articles in this category:

    Arduino LM358 PT1000 Sensor Converter

    PT1000 Converter for Arduino

    • Video
    • DE/EN

    PT1000 sensors can not be measured directly analog with a microcontroller. How to build a PT100 Converter with LM358 and Arduino?

    read more
    Arduino PT100 Temperature Sensor Converter

    PT100 - Measure temperature with Arduino

    • Video
    • DE/EN

    The PT100 is a very precise industrial temperature sensor. This article is about building a measuring amplifier for reading a PT100 on the Arduino

    read more

    Social Media

    Werbung:


    New Posts


    Events

    • Keine zukünftigen Events vorhanden