I'm trying to interface an energy meter (A9MEM2050) with an Arduino Uno using the MAX485 chip. I keep getting the following error:
"Failed, Response Code: E2"
Has anyone dealt with such an error before? I'd be happy to put up my code- it's a build up on the example halfduplex code (but has no comments- I know, it's a crime, sorry!).
based on the missing code, missing schematic and missing pictures I guess its due to
/**
ModbusMaster response timed out exception.
The entire response was not received within the timeout period,
ModbusMaster::ku8MBResponseTimeout.
@ingroup constant
*/
static const uint8_t ku8MBResponseTimedOut = 0xE2;
I was recommended to use Arduino Mega as a way to overcome the serial ports issue. But I've only got an Adafruit Metro M0 express. Reckon it will work better than UNO? I believe there's a way to set multiple serial ports on Metro M0. (Please excuse if my wordings aren't correct, English is not my first language).
I want to ensure if the Mega will be able to run it before committing to buying one.
That is corrent.
Use Serial1.begin() to setup the serial port on the TX and RX pins.
You need to set the speed and protocol. The meter uses even parity
Serial1.begin(9600, SERIAL_8E1)
Hmm, not sure if I understand that. So to read the value off, basically reading- would be done through Serial1? Or would I just be using Serial1 in my 'setup' bit to talk to the energy meter.
Would my circuit still be the same- RS485 a and b connected to pins 10 and 11 (considering they are the set Serial1 rx, tx) through a TTL convertor (MAX485)).
For now, I think there's something wrong with my mcu considering it's not even running a basic blink. But that's solvable.
I was originally using Arduino Uno Rev 3 (the code I mentioned above is written for/tested with Uno).
I was advised and given a Adafruit Metro ESP32-S2 ( Adafruit Metro ESP32-S2 | The Pi Hut) to play around with because it can have multiple serial ports (I was told Uno can't)