Photon and Modbus 485 RTU - Connections & interface requirements

@BIBZY84, the Sparkfun board should work. Some information on how to hook things up are in the library comments:

USARTSerial MBSerial = Serial1;		 ///< Pointer to Serial1 class object
uint8_t MBTXEnablePin = D7;		 ///< GPIO pin used for toggling RS485 Driver IC's TX Enable pin, default is D7

From this we know that Serial1 is used (RX/TX pins) and we know that pin D7 is used for controlling the RS485 transceiver direction. The schematics for the Sparkfun board are poorly drawn (missing RTS pin indication on JP9). With minor adjustments it should show:

JP9 is the 5-pin un-numbered connector on the board. From the schematics, the connections from the board to the Photon should be:

RS485 Board     Photon
 1 (Vcc)         Vin
 2 (RX-i)        TX
 3 (TX-o)        RX
 4 (RTS)         D7
 5 (GND)         GND

Notice that the RTS line has a resistor and LED and pin D7 of the Photon also has a resistor and LED connected to it. If things don’t seem to work due to the voltage drops caused by the resistors/LEDs, you should change pin D7 to another digital pin on the Photon. The code in the library example that specifies this pin is in setup()

node.enableTXpin(D7);  // If this is not working, specify a different can and make sure you
                       // change the wiring to match

Hope that helps! :wink:

5 Likes