Particle Electron rs485

Hello,

I am working a project to connect an Acurev 1300 (https://www.accuenergy.com/files/acurev/AcuRev-1300-User-Manual.pdf) to the Particle Electron. The Acurev transmits data through rs485 communication, so I decided to use a max485 circuit board (http://hobbycomponents.com/wired-wireless/663-max485-rs485-transceiver-module) and the Modbus Master Library (https://github.com/pkourany/ModBusMaster). However, I am struggling to make this work.

My circuit follows the diagram below:

And my current test code is:

#include <ModbusMaster.h>

ModbusMaster node(200);

void setup() {
	node.begin(9600);
	Serial.begin(115200);
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
	uint8_t result = node.readHoldingRegisters(0x1048, 1);
	if(result == node.ku8MBSuccess) {
		Serial.println(result);
	} else {
		Serial.println("not working");
	}
	delay(5000);
}

Can you help me figure out the problems with the circuit/code?

You could try this more current library
https://build.particle.io/libs/ModbusMaster/1.2.0/tab/ModbusMaster.cpp

Unfortunately the contributor hasn’t enabled issue-reporting on his library, otherwise I’d have suggested to him to add means to select other serial ports than hardcoded Serial1.

I’m using that library. I accidentally linked the wrong one. Do you think this is a software or hardware issue?

One suggestion is to have LED wired up to the TX and RX for a visual indication that data is being sent and received.

If the RX LED doesn’t blink, it’s an indication that either the TX/RX is flipped from Photon to MAX485 or a configuration needs to be fixed.

Eg. Start bit, stop bit and parity settings for the modbus serial line.