Page 1 of 1

RS485 Device ignoring Bluetooth Commands via ESP32

Posted: Wed Aug 28, 2024 9:10 pm
by hoti123
Hi,

I am having difficulty sending commands to control output data from a RS485 device connected to a ESP32 device via bluetooth smartphone. The ESP32 has bluetooth enabled and is connected to the PC via USB and has Pins TX, RX, 5V, and GND connected to a TTL to RS485 Adapter Module which is connected to the RS485 device.

I am able to receive data from the RS485 device via ESP32 bluetooth to my phone's bluetooth serial app. However, when I try to send a command via the bluetooth serial app the command is completely ignored and I can only read the received data only.

The TTl to RS485 module details is found here:
https://esp32io.com/tutorials/esp32-rs485

The code I used is the following via Arduino IDE. I use bluetooth serial app on my phone as bluetooth to be paired with the ESP32 bluetooth.

#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;

void setup() {
Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}

void loop() {
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(20);
}

I have disconnected the ESP32 and connected only the TTl to RS485 adaptor hooked to the RS485 device to my PC with a 4Pin TTl cable and entered the input commands and I was able to see a change in output responce from the RS485 device. So that eliminates any hardware issues with the TTL to RS485 module connected to the RS485 device.

I am really stumped and puzzed as why I am able to receive output data from the RS485 device via blueooth on my phone with no issues but the RS485 is ignoring the commands I send from the phone bluetooth. Any help will be appreciated.