RoLa MAX485 to lora radio node

So which logic level conversion circuits are you using ?

None, i think. I use Arduino Nano with the same code and get results. But with RoLa Radio containing same Atmega328P the digital pins are not available and hence have to use A0 and A1

I support that.
You have a problem with your RS485 interface - so do a test with it.

a very simple pass Serial pass through

/*
   Modbus Diagnostic - Passthrough

   just prints each received byte on SoftSerial to Serial.

   by noiaca

   2021-11-03
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3);     // RX, TX
constexpr byte TxEnablePin = 11;

void setup() {
  Serial.begin(9600);
  Serial.println(F("\nModbus Diagnostic Passthrough"));
  mySerial.begin(4800);
}

void loop() {
  static uint8_t counter = 0;
  const uint8_t linefeed = 20;
  static uint32_t previousMillis=0;
  const uint16_t timeout = 1000; // automatic linefeed after ms idle

  pinMode(TxEnablePin, OUTPUT);
  digitalWrite(TxEnablePin, LOW);
  if (mySerial.available())
  {
    Serial.print(" ");
    Serial.print(mySerial.read(), HEX);
    counter++;
    previousMillis = millis();
    if (counter >= linefeed)
    {
      counter = 0;
      Serial.println();
    }
  }
  if (millis() - previousMillis > timeout && counter > 0)
  {
    Serial.println();
    counter = 0;
  }
}

I propose following aproach:

step a)
disconnect the Sensor.
connect a RS485 - USB adapter to your PC and your RS485 module and transmit plain data.
The Arduino must be able to read that data via RS485 and print it to serial Monitor.

step b)
Still only a rs485 - loop between your PC and your Arduino.
Adopt the test sketch to send a "HelloWorld" on startup.
You maust be able to read that data on other RS485-USB interface on a the PC

step c)
disconnect the Arduino.
Connect the Sensor to your RS485-USB interface directly to the PC:
send one modbus command form the RS485-USB interface to your sensor.
The sensor must respond with valid data.

step d)
Disconnect the RS485-USB interface
Connect the sensor to your Arduino-RS485.
Modify the test sketch and send one modbus command from the Arduino to the sensor.
The sensor must respond with data.

step e)
Take the example sketch from your modbus library and adopt it to make it work with your sensor
The sensor must respond with data.

step f)
add lora to the modbus Sketch
The sensor must still respond data.

Do it stepwise.
Don't make shortcuts on your way to success.
Disconnect not used parts - especially on the bus.
Make your wiring on the workbench as clear as possible
Always take care about ground connections
Report how far you get - what was working.
make clear pictures of the step that fails first.

I think u are missing my point. This is a module fitted with lora SX1278 connected inside at fixed pins to Atmega328P at pin 10,9,2. Now the available pins for a max485 input to Atmega328P are A1, A0, D3 and D4 and maybe D5-D8. None works, i tried all combinations. The sensor i have has a built-in microcontroller that only runs at baud rate of 4800. Any test that uses the pins in use of SX1278 wont work as it conflicts.

Now i run the max485 with Esp32 containing boards or boards containing them with lora sx1276 or 1278 and they work fine, sensor data is useful and i run an entire drip irrigation system with these. I use max485 with Nano and it works for all digital pins available on it. So its not an issue of testing every component. It may have to do with the digital pins available at this particular Atmega328P inside this module, i dont know. Maybe i contact Elecrow or the supplier. Thanks for all the help.

Looking back over your code in post #16, I don't see any check that you have received a response before you do a mod.read(). If the sensor hasn't responded, then according to the software serial docs, the read() function returns the character read, or -1 if none is available.

If you don't know something - you could analyze it in a systematic way.
You could ask yourself: Do you know if the RS485 communication is working with this particular board? How can you proof it? The ESP, the Nano the Lora Radio Node - all run on different internal frequency - does this effect the RS485 bus? Does your RS485 bus even work? Is the RS485 sending out data? Is the RS485 receiving data?

By holding the NSS pin on the LoRa device high, you could also use pins 11,12,13 that are on the ICSP connector.

Do not however connect the pins from the MAX485 module here, if thats using 5V logic levels you could damage the LoRa device or processor.

Thanks

My dear you seem to misunderstand what I ask. If it was about testing thebsensor or its rs485 i would certainly asked that, I have already done the bits you seem to suggest. Calm down, u dont have a monopoly over understanding rs485 or max or megas.

Oh, so it's the receiving side which causes communication problems.
Not the sender,
not the communication layer.
What a nice analogy to your problem.

Just ignore my posts and follow the advices from the others.

Since the Nano should use the same processor (Atmega328P) as your module, you would conclude your module is faulty, or the processor is a not so good clone.

So ask the manufacturer of your module if there are any known issues with it ?

Its Elecrow and the technology guys there appear to know no English as usual when its needed.

The supplier suggests using a 3.3V max485 ie max3485 as the board is 3.3v level. Now almost everywhere here people sell 5v max485. Is there a way out with 5v max485?

In order to use the MAX485, you're going to need a source of +5V to power it and some logic level converters for the data/control signals.

I picked up a bunch of MAX3485 modules on AliExpress precisely because some of my setups now operate at 3v3.

Thank you guys. Finally I found a solution. I need only connect a ttl to 485 converter module (that operates at 3-30V) like this and connect the output rx tx to atmega A1/A0 or D3/D4 or any digital pin and it should work! Here is what gave me the understanding.Basic Modbus RTU Master RS485 Test with ESP32 + XY-K485 + PZEM-016 (without libraries) - PDAControl
I hope those here will benefit too.

Hi, I am testing another chinese sensor MEC10 its soil sensor and measures soil temp, moisture, EC. Its cheaper $30 and operates with RS485 at 3.3V so a lot of battery saving. I managed to get correct readings via UART Assistant via code (01 0400000003 B00B ) but when used in an arduino program with RS3485 the results are strange and fluctuating as can be seen in the pics. I have attached pdf of the manual of MEC10 in the link below. Any suggestions what could possibly be the reason pics - Google Drive

Got it solved. Was taking the wrong bytes, 4 and 5 instead of 3&4 and so on. Also this sensor stabilizes after 5-10 readings. Its good. DC3.3V soil RS485 soil temperature and humidity soil conductivity sensor