I've been trying to interface between a NodeMCU and a Dotech DPX200 Pressure Multi-Switch over Modbus RS485 using a MAX485 Module for the past few weeks, going through nearly every Modbus post on this site with no luck. As my access to the multi-switch can be limited at times, I've also tried using several simulators like ModScan64, Simply Modbus Master/Slave, Modbus Poll etc. but could get none to work.

I'd like to know if the Modbus device's Slave ID has to be set on the device itself or the NodeMCU? Also to get the "Display of low pressure value" the address given in the manual is 40023. How would I write the NodeMCU code to read that value using either the ModbusRtu, ModbusMaster or any other appropriate library?

I've added the DPX200's Manual link with my NodeMCU script and wiring diagram, and would appreciate any help from you.

Wiring Diagram

#include <ModbusMaster.h>
#define MAX485_TX_ENABLE  12

int myInts[6];
ModbusMaster node;

void preTransmission(){
  digitalWrite(MAX485_TX_ENABLE, 1);

void postTransmission(){
  digitalWrite(MAX485_TX_ENABLE, 0);

void setup(){
  Serial1.begin(9600, SERIAL_8N1);
  pinMode(MAX485_TX_ENABLE, OUTPUT);
  digitalWrite(MAX485_TX_ENABLE, 0);

void loop(){
  uint16_t k = 0,Status;
  node.begin(1, Serial1); //Slave ID = 1?
  Status = node.readHoldingRegisters(0x0023, 5); //Since address is 40023 to 40027
  if ( (Status == node.ku8MBSuccess) ){
     Serial.print("\nIDK: ");
     for (k = 0; k <= 5; k++ ){
        Status = node.readHoldingRegisters(k, 1);
  • the slave id is set in slave. the id is in the documentation of the sensor. it is 1 (and can be set in register 40063)
    – Juraj
    Commented Jun 3, 2019 at 9:27
  • @Juraj Thank you for the info on Slave ID. I'm sorry but could you please explain what you meant in the second comment? Commented Jun 3, 2019 at 9:40
  • @Juraj Thanks a ton. So is the solution to just change it to Serial? Sorry if it's a silly question but I don't have much experience with this. Commented Jun 3, 2019 at 9:49

1 Answer 1


Now you have node.begin(1, Serial1), but you can't use Serial1 for RS485 because Serial1 doesn't have RX pin

According to the picture you wired the adapter to RX/TX pin of Serial, but this pins are wired on board to USB for communication with the computer (upload and Serial Monitor). You can't use Serial for RS485 adapter while you are using it for debug prints.

You can use SoftwareSerial fo example on D1/D2 for RS485.

Or if you have an USB-to-TTL-Serial adapter then you can use Serial1 for debug prints and Serial for RS485

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.