Undefined reference to SoftwareSerial (Arduino NANO)

Hello!
Help me solve the problem when uploading a sketch for Arduino Nano, where I use both Modbus and SoftwareSerial at the same time, and it keeps giving me this error:
undefined reference to `void Modbus::begin(SoftwareSerial, long)'*
Where am I doing wrong?

Here is part of the code:

#include <SoftEasyTransfer.h> //https://github.com/madsci1016/Arduino-SoftEasyTransfer
#include <SoftwareSerial.h>
#include <ModbusRtu.h> //https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino
#include <EEPROM.h>
#include "EEPROMAnything.h" //https://github.com/collin80/EEPROMAnything
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <avr/wdt.h>

SoftwareSerial mySerial(8, 6); //Arduino RX - RS485 RO, Arduino TX - RS485 DI

The code snippets are useless. You don't know where is the error in your code and since that you can't decide which code parts will be useful to locate the error.
Please show your code in full.

1 Like

The library Modbus that you use hasn't method

begin(&mySerial, 9600)

Perhaps you copied the code that needs a different Modbus library.

Also, on the Arduino Nano board the pins A6 & A7 are analog input only. You can't use it as digital output:

pinMode(A6, OUTPUT);
digitalWrite(A6, LOW);
pinMode(A7, OUTPUT);
digitalWrite(A7, LOW);

Are you using a classic Nano board?

Why did you delete the code?

Yes, I use a classic NANO board. The code I copied needs the smarmengol/Modbus-Master-Slave-for-Arduino library. But the code is older and maybe the current library has already been changed. Not supported slave.begin( &mySerial, 9600);
When I change it to slave.start(); it is OK

Terminals A6, A7, 2, 3 are not used. They are software connected to GND (constant value LOW) to avoid interference.

Technically you can't do that with A6 A7 by the code, because it hasn't a digital output. Use an external pulldown resistors.

Thanks, I already found the reason, I needed an older library smarmengol / Modbus-Master-Slave-for-Arduino for this code.
The current version is from 2022 and the 2018 version was used for this code.
Now no more errors during compilation.

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