Hi everyone.
I try to connect between ESP32 and visual basic in my PC.
My visual basic can read data from ESP32 as below.
Visual Basic .NET | Receive Serial Data From Arduino - YouTube
However, I have problem. ESP32 cannot read data from visual basic.
I put the code here
#include <BLVD20KM_asukiaaa.h>
#include <rs485_asukiaaa.h>
#define RS485_DE 4
// #define RS485_RE RS485_DE // you can unify DE and RE
#define RS485_RE 5
#define RS485_BAUDRATE 115200
#define RS485_SERIAL Serial
#define MOTOR_A_ADDRESS 1
rs485_asukiaaa::ModbusRtu::Central modbus(&RS485_SERIAL, RS485_DE, RS485_RE);
BLVD20KM_asukiaaa motorA(&modbus, MOTOR_A_ADDRESS);
char i='0';
String textForSMS;
void setup() {
Serial.begin(115200);
BLVD20KM_asukiaaa::beginModbus(&modbus, RS485_BAUDRATE);
motorA.beginWithoutModbus();
}
void loop() {
while (Serial.available()){
i = Serial.read();
Serial.println(i);
}
int A;
int B;
A=random(0,100);
B=0
if(i=='a'){
B=1000;
}
textForSMS= textForSMS + (A) +"," + (B) + ","+ i;
Serial.println(textForSMS);
textForSMS="";
}
Visual basic can read data that A and B.
Now I can read i is zero.
I define i is variable for read data from visual basic i = Serial.read();
i cannot read data from visual basic.
I have tried communication between ESP32 and Visual basic in my previous project before.
I don't have any problem.
For this project, I think the problem is RX and TX pin
#define RS485_SERIAL Serial (I use this function to control motor.)
If I delete the serial (RX and TX), I can communicate between ESP32 and visual basic that same as my previous project. Because my previous project doesn't use RX and TX pin.
However, I need RX and TX pin in this project.
Anyone can help me?
Visual basic can read data from ESP32, but ESP32 cannot read data from visual basic when I use RX and TX pin.