ModbusRTU with NodeMCU and no MAX485

Hi,

i was searching for the last 3 days now.
And i was not able to find a solution.

What i have:
Elfin EW11 that is integrated in the Wifi. The Elfin is the Modbus adapter for my openhab system. With my oscilloscope i can see the requests on the RS485. I did not decode the signal yet (since the timing is pretty much what i would expect). Elfin EW11 is Modbus Master.

I would like to test the connection and use a NodeMCU as a modbus slave. I have no MAX485 board. And as far as i understood it is not needed for my "simple" test.

I downloaded and installed all of those:

https://werner.rothschopf.net/microcontroller/202112_arduino_modbus_server.htm

but no reaction from the nodemcu...

i connected the A/B from the Elfin EW11 to RX/TX of my NodeMCU.

but i assume that i have a basic misunderstanding here...

Does anyone have a small idea where to look at?

I guess i got a little further.
The Elfin EW11 does the request (my assumption) and the answer of the nodemcu comes.
But the signal is like 5V from the Elfin and the response is like 1V peak.

Is that expected?
IMAGE1

There lies the problem.

The A & B signals of RS485 are not equivalent to RX & TX.

The A & B signals are opposites of eachother i.e. Differential.

A MAX485 is a half duplex RS485 transceiver. When it is in transmit mode, it drives both the A & B signals to output the data. When it switches back to receive mode, both the A & B signals are now inputs to allow a remote device to transmit on the A & B lines.

Thank you for your answer.
i managed to get a kind of an response.

After i removed the 150ohm resistor, my answer looks like below.
So for me that is good enough. i assume that my elfin ew11 is working.
Just the full protocol is not up and running.

i would like to mention here:

there is an example of two partners without an max485. i thought, it was mainly for robustness issues. well i can live with that!

Thank you and happy Easter :slight_smile:

with the request of one value:

Bridge poller holding "Modbus 1.1 Poller" [ start=40000, length=1, refresh=5000, type="holding" ]

IMAGE3

with the request of 3 values:

Bridge poller holding "Modbus 1.1 Poller" [ start=40000, length=3, refresh=5000, type="holding" ]

IMAGE2

with that source:

/*
  ModbusRTU ESP8266/ESP32
  Simple slave example
  (c)2019 Alexander Emelianov (a.m.emelianov@gmail.com)
  https://github.com/emelianov/modbus-esp8266
  modified 13 May 2020
  by brainelectronics
  This code is licensed under the BSD New License. See LICENSE.txt for more info.
*/

#include <ModbusRTU.h>

#define REGN 40000
#define SLAVE_ID 1

ModbusRTU mb;

void setup() {
  Serial.begin(9600, SERIAL_8N1);
#if defined(ESP32) || defined(ESP8266)
  mb.begin(&Serial);
#else
  mb.begin(&Serial);
  //mb.begin(&Serial, RXTX_PIN);  //or use RX/TX direction control pin (if required)
  mb.setBaudrate(9600);
#endif
  mb.slave(SLAVE_ID);
  mb.addHreg(REGN);
  mb.Hreg(REGN, 131071);
  mb.Hreg(REGN+1, 131071);
  mb.Hreg(REGN+2, 0);
  mb.Hreg(REGN+3, 0);
  mb.Hreg(REGN+4, 131071);
  mb.Hreg(REGN+5, 131071);
  mb.Hreg(REGN+6, 0);
  mb.Hreg(REGN+7, 0);
  mb.Hreg(REGN+8, 131071);
  mb.Hreg(REGN+9, 131071);
}

void loop() {
  mb.task();
  yield();
}


my equipment:
nodemcu v3
elfin ew11
openhab 3.4.2 running on raspberry pi 4
owon hds242