Modbus with micro Bus RS485 Click

Has anybody gotten a RS485 click to work with Modbus?
is there any sample code?
What is another good RS485 board?

I'm trying to read a Banner GPS50M.

Any help would be appreciated.

This is some code that I've tried.

// This #include statement was automatically added by the Particle IDE.
#include <ModbusMaster.h>
#include "Particle.h"


//instantiate ModbusMaster object as slave ID 1
ModbusMaster node(1);
unsigned long interval = 0;
unsigned long base_T = 10000;

void idle() {
    delay(10); // in case slave only replies after 10ms
    Particle.process(); // avoids letting the connection close if open

void setup() {
	// initialize Modbus communication baud rate
	node.enableTXpin(D7); //D7 is the pin used to control the TX enable pin of RS485 driver
	node.enableDebug();  //Print TX and RX frames out on Serial. Beware, enabling this messes up the timings for RS485 Transactions, causing them to fail.
	node.idle(idle);      //function gets called in the idle time between transmission of data and response from slave

	while(!Serial.available()) Particle.process();
	Serial.println("Starting Modbus Transaction:");

void loop() {
	uint8_t j, result;
	uint16_t data[10];

        if (millis() - interval > base_T) {
                interval = millis();
		result = node.readHoldingRegisters(0x65,1);
	// do something with data if read is successful
	if (result == node.ku8MBSuccess) {
		Serial.print("Success, Received data: ");
		for (j = 0; j < 2; j++) {
			data[j] = node.getResponseBuffer(j);
			Serial.print(data[j], HEX);
			Serial.print(" ");
			Particle.publish("Modbus", String(data[j], HEX), PRIVATE);
        base_T = 1000;
	} else {
		Serial.print("Failed, Response Code: ");
		Serial.print(" - ");
		Serial.print(result, HEX); 
		base_T = 5000; //if failed, wait for bit longer, before retrying!

Hi @gmaendel,
I have gotten that exact MikroE Click board to work and my example is even outlined in this document which includes example code. What behavior are you experiencing and how familiar are you with the ModbusMaster library?

1 Like

Nice! thank you @erik.fasnacht ! not sure how I missed that.
I'll dive into that doc later today.
I'm not getting anything back at the moment, but I think I'm missing something, I definitely think that doc will be able to help me.

Thanks again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.