Adsense HTML/JavaScript

Friday, March 12, 2021

Simple test DX-BT24 (BLE 5.0 Bluetooth module), with Seeeduino XIAO as serial bridge.

DX-BT24 is a BLE 5.0 Bluetooth module with UART interface. Seeeduino XIAO is programmed (in Arduino platform) as a serial bridge to link Arduino Serial Monitor and DX-BT24. The another side, Serial Bluetooth Terminal app (on Android) is used to test with.

/*
Xiao act as a bridge between USB and BT-24

The device (BT-24) is powered on 3V3
Connection
Xiao Rx   - device Tx
Xiao Tx   - device Rx
XIAO GND  - device GND
XIAO 3V3  - device VCC
XIAO D1   - STATE

*/

const int PIN_STATE = 1;


void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(PIN_STATE, INPUT);
  
  delay(1000);
  SerialUSB.begin(9600);
  Serial1.begin(9600);

  //wait serial ports to device
  //while(SerialUSB);
  while(!Serial1);
  
  //Blink the LED 3 times to indicate program started
  for(int i=0; i<3; i++){
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);
    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
}

void loop()
{
  if(SerialUSB.available() > 0){
    Serial1.write(SerialUSB.read());
  }

  if(Serial1.available() > 0){
    SerialUSB.write(Serial1.read());
  }


  if (digitalRead(PIN_STATE) == HIGH){
    digitalWrite(LED_BUILTIN, LOW);
  }else{
    digitalWrite(LED_BUILTIN, HIGH);
  }
  
}




link:
DX-BT24 product page


1 comment: