I'm trying to read data from Makel M600 model meter with ESP32. I use RS485 and IEC 62056-21. I send command to get device identification but serial monitor prints unreadable characters. Here is the my full code:
#include <WiFi.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(16,17); // RX, TX pins
const char* ssid = "--";
const char* password = "--";
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
delay(1000);
Serial.begin(9600);
mySerial.begin(9600);
// Cihaz kimliği sorgusu gönderme
mySerial.println("/?!<CR><LF>");
}
void loop() {
if (mySerial.available()) {
String response = mySerial.readStringUntil('\n');
Serial.println("Received: " + response);
// Baud hızı değişikliği isteği gönderme
if (response.startsWith("/SAT")) {
mySerial.println("[DATA]050<CR><LF>");
}
// Aktif tüketim sorgusu gönderme
if (response.startsWith("/SAT")) {
mySerial.print("[SOH]R2[STX]1.8.0()[ETX][BCC]");
}
}
}
And here is the output:
14:56:18.453 -> �z����....
14:56:20.577 -> WiFi connected
14:56:20.577 -> IP address: **********
14:56:22.608 -> Received: ������
I'm new with it so I hope you can help me.
I tried to use HardwareSerial but it didn't work. I tried to convert it to string, change pins, and different codes but it's not working. Serial monitor still prints unreadable characters.