Problem Connecting Arduino to IOT Gateway via RS485


So i’m working on a small project which involves connecting several Arduinos to an IOT gateway. Each Arduino is supposed to send different kind of data through different means of communications.
I’m having trouble to establish a connection between an Arduino Uno and the gateway using a MAX485 module.
I eventually want to transmit data from a sensor to the gateway but at the moment i’m only trying to establish a basic connection and then build on it.

The wiring is quite simple: (using softwareserial to use digital pins for serial communication)
Arduino >> Max 485
Pin 10 >> R0
Pin 11 >> DI
Pin 3 >> DE and RE

The other end of the MAX485 is then connected to the relevant RS485 ports of the Gateway using twisted wires (Followed the Gateway Manual Instructions ).

From the Gateway device configurations i added the arduino device(they have pre-installed drivers for Arduinos) and configured the port parameters to match the ones of the Arduino.
Now when i run the arduino, the RX light on the gateway starts blinking periodically (depending on the delay that i enter in the sketch) - but the interface keeps showing that there is no connection with the Arduino.

Any advice/help would be great, I’m fairly new to micro-controller communication.

testabc.ino (995 Bytes)

Any advice/help would be great, I'm fairly new to micro-controller communication.

You should post a link to the documentation of that gateway device. In the sketch you posted you send a random byte (you don't initialize it). I guess that gateway device expect a certain protocol to be talked on the RS-485 interface.

If you are free to change some pin numbers you should consider to throw away that horrible SoftwareSerial library and use one of the better alternatives (AltSoftSerial or NeoSWSerial). Once you don't need the hardware serial interface for debugging anymore I strongly suggest to switch to that one for productive use.

Thanks for the answer. The gateway is provided by a startup and hence they still don’t have proper documentation regarding communication with an arduino.
I have been in contact with them and today they sent me the Arduino Library to be used to establish a connection with their gateway.

The problem is that they can’t find the manual/documentation that was originally written for the library. I tried to use the example given in the .h file but it still doesn’t seem to work. Maybe i’m not using the right pins.
I have connected it like this:

RS485 — Arduino uno
D1 — 1 (TX)
R0 — 0 (RX)
DE and RE – 2

And i’m using the following sketch:
#include “arduino_modbus.h”

ArduinoModbus modbus;

void setup() {
modbus.init(1, Serial);

modbus.setBool(2, 1);
modbus.setBool(79, 1);
modbus.setLong(0, 0x0AAAAAAA);
modbus.setLong(19, -12345678L);
modbus.setLong(8, modbus.getLong(19));
modbus.setFloat(0, 2.2f);
modbus.setFloat(8, 3.141592653f);
modbus.setFloat(9, -1.618e-2);

void loop() {

I’ll be really grateful if someone can have a look in the .h file and help me out with the pins to be used. Thanks in advance

arduino_modbus (1).zip (6.17 KB)

I’ve figured it out. Just had to change some of the wiring and now it’s finally communicating with the gateway.