safwan092

RX Bletooth ESP32

Mar 6th, 2025
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. //RX
  2. #include "BluetoothSerial.h"
  3.  
  4. #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
  5. #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
  6. #endif
  7.  
  8. BluetoothSerial SerialBT;
  9.  
  10. void setup() {
  11. Serial.begin(115200);
  12. SerialBT.begin("ESP32test"); //Bluetooth device name
  13. Serial.println("The device started, now you can pair it with bluetooth!");
  14. }
  15.  
  16.  
  17. void loop() {
  18. uint8_t recv_data[6];
  19. if (SerialBT.available()) {
  20. SerialBT.readBytes(recv_data, 6);
  21. //Serial.printf("%c %c %c %c %c %c", recv_data[0], recv_data[1], recv_data[2], recv_data[3], recv_data[4], recv_data[5]);
  22. Serial.println((char*)recv_data);
  23. Serial.println();
  24. }
  25. delay(20);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment