M5 RS485 Modbus slave sample code does not compile

  • I have an Atom Switch that I want to use RS485 modbus with has not modbus sample code. So I trying to use sample code from the ATOM DTU devices.

    When I try to compile the sample code it gives the following error

    error: no matching function for call to 'RS485Class::RS485Class(HardwareSerial&, int, int, int, int)'
     RS485Class RS485(Serial2, ATOM_DTU_RS485_RX, ATOM_DTU_RS485_TX, -1, -1);

    Which makes sense as I don't understand where the RS485Class is defined or how it is in the below code sample. Has anyone got this working?

    #include <M5Atom.h>
    #include <ArduinoModbus.h>
    #include <ArduinoRS485.h>
    #include "ATOM_DTU_NB.h"
    const int numCoils            = 10;
    const int numDiscreteInputs   = 10;
    const int numHoldingRegisters = 10;
    const int numInputRegisters   = 10;
    RS485Class RS485(Serial2, ATOM_DTU_RS485_RX, ATOM_DTU_RS485_TX, -1, -1);

  • Have you downloaded and installed all the libraries required in arduino?

  • @ajb2k3 yup, all the libraries in the include section are downloaded and the compiler does not throw any missing file errors