I want to connect a sensor to this lora board (RoLa Lora Radio Node containing Atmega328P as microcontroller) through MAX485 to transfer a RS485 data from a soil sensor. The sensor seems remains unconnected if i use pins D5-D8 or D3-D4. The D2 pin already used by the Lora 1278. When I use an Esp32 or Arduino Nano the sensor and MAX485 works
A quick look at a better image I found suggests that the yellow 1x6 connector has GND, 3V3, TX & RX available on it. You need an additional digital output pin to control the direction of data flow on your RS485 line driver - assuming you don't have one of those auto switching line drivers.
Depending on what else is connected to your node, you could use one of D4 or D3 (broken out onto those 3-pin headers) or else maybe D5, D6, D7 or D8 from that unpopulated connector J3.
You're using 3V3 which I think excludes the more commonly available MAX485 based RS485 modules as they are 5V devices - but I could be wrong on that point.
Would that be one of those NPK devices (think that's their initials) Nitrogen, Phosphorus & Potassium? There's several discussions on the site about trying to get them working using Modbus so search the forums for NPK.
Have you connected any jumpers?
there a connections to the lora module if you have set jumpers.
here I have a pinout
https://werner.rothschopf.net/202006_lora_radio_node_v1.htm
I know it's German, but I guess you can find all pin information of the lora radio node board.
imho D3 D4 A0 A1 are save to use.
Thanks. I have tried the J3 pins as well as the yellow ones TXD RXD pins you pointed out. I supply 12V to the Soil (yes its the infamous NPK sensor that actually is a electrical conductivity correlated directly to N and from there to P and K) and yes I do supply 5V directly to the MAX, maybe its 4.8V from a power bank that may be an issue. However everything works when i use it with ttgo lora 1276 Esp32 or simply another Atmega328P called Arduino Nano. I couldnt understand wbat you say about "need additional pins to control direction of flow"
Thanks. Looks interesting, let me go thru it.
The RS485 bus when using MAX485 line drivers operates at half-duplex - i.e. you can't send and receive at the same time. The MAX485, for example, has 2 pins called RE & DE which enable/disable the line driver and line receivers in the chip.
RE & DE are nicely configured so that you can join them together and control them both from 1 digital output pin. When you drive RE & DE low, the MAX485 chip is in receive mode and any data on the 485 bus will appear on the RO pin. When RE & DE are driven high, the receiver is disabled (so you don't hear your own transmission) and line driver enabled so data on DI appears on the 485 bus.
Thanks. That saves on pins you mean?
J3 has 4 jumpers
next to the antenna is DIO1 - D5
depending on your settings the next 3 jumpers might be connected or not.
If you have connected them - D6/D7/D8 are not usable any more.
if you haven't set jumpers (on the last 3 positions) D6/D7/D8 can be used in your layout.
Some setups that use MAX485 chips drive RE & DE from 2 separate pins. Probably because it's easier to run a couple of jumper wires, rather than try and join the 2 pins together to be controlled by 1 wire.
I've not used LoRa myself, but the modules are similar to the RFM69 modules. I think DIO0 is used to generate an interrupt when a message is received but I can't be sure. @noiasca will be able to tell you more. Have a look at the LoRa RFM96 datasheet as it will explain what the DIO signals are used for.
That is the normal setup, DIO0 flags a RX or TX done.
Its just eaiser that way, although you can just read the IRQ register direct and save an IO pin.
They are not connected, at least by me. Then you think the problem of not being able to activate the EC sensor is due to 1)not having interrupt pins on the RoLa Radio board or 2)me not being able to choose proper pins? Four digital pins D3, D4, A1 and A0 are available so i use them or 3) there is no solution?
I can't judge with the current information.
draw a schematic
post real pictures of your setup where we can see each module/wire
post a datasheet of your sensor.
post a minimalistic sketch showing your problem.
imho D3/D4 with a DE/RE on A1 should work fine and I guess your problem is in an area what we haven't seen so far.
You can use LoRa modules with an interrupt pin if you choose, but it should not be neccessary.
I am not aware of a LoRa library that requires you to use an interrupt pin, but then we dont know which LoRa library or code you are using (hint).
codeI tried D3 D4 and A0 A1 but the same results , i get no signal only FFFFFFFFFF from the sensor. I am attaching the code, pic and a schematic.
#include <SPI.h>
#include <LoRa.h>
//define the pins used by the transceiver module
//#define sck 5
//#define miso 19
//#define mosi 27
#define ss 10
#define rst 9
#define dio0 2
const int SensorPin = A1;
//define NPK sensor control pins
#include <SoftwareSerial.h>
#define RE A1 //13
#define DE A0 //25/7
SoftwareSerial mod(3,4); //R0--21, D1--22/5/4
const byte temp[] = {0x01,0x03, 0x00, 0x01, 0x00, 0x01, 0xD5, 0xCA};
const byte moist[] = {0x01,0x03, 0x00, 0x00, 0x00, 0x01, 0x84, 0x0A};
byte values[11];
int soilMoistureValue=0, valnitro=0,valphosph=0,valpotash=0, valmoist=0, valtemp=0, valec=0, valph=0;
float temperature1=0, moisture1=0, ph1=0;
int counter = 0;
void setup() {
//initialize Serial Monitor
Serial.begin(9600);
while (!Serial);
Serial.println("LoRa Sender");
//for NPK modbus
mod.begin(4800);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);
//setup LoRa transceiver module
LoRa.setPins(ss, rst, dio0);
//replace the LoRa.begin(---E-) argument with your location's frequency
//433E6 for Asia
//866E6 for Europe
//915E6 for North America
while (!LoRa.begin(866E6)) {
Serial.println(".");
delay(500);
}
// Change sync word (0xF3) to match the receiver
// The sync word assures you don't get LoRa messages from other LoRa transceivers
// ranges from 0-0xFF
// LoRa.setSyncWord(0xF3);
Serial.println("LoRa Initializing OK!");
}
void loop() {
// for rs485
valtemp= temperature();
delay(1000);
valmoist= moisture();
delay(1000);
Serial.print("Temperature: ");Serial.print(valtemp);
Serial.println(" C");
Serial.print("Humidity: "); Serial.print(valmoist);
Serial.println(" %");
Serial.print("Sending packet: ");
Serial.println(counter);
soilMoistureValue = analogRead(SensorPin); //put Sensor insert into soil
//Send LoRa packet to receiver
LoRa.beginPacket();
LoRa.print("temp value ");//moisture value
LoRa.print(temperature1);//soilMoistureValue
LoRa.endPacket();
counter++;
delay(500);
}
int temperature(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(temp,sizeof(temp))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(mod.read(),HEX);
values[i] = mod.read();
Serial.print(values[i],HEX);
}
Serial.println();
}
temperature1=values[4]/10;
return temperature1; // int(values[3]<<8|values[4]);
}
int moisture(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(moist,sizeof(moist))==8){
digitalWrite(DE,LOW);
digitalWrite(RE,LOW);
for(byte i=0;i<7;i++){
//Serial.print(mod.read(),HEX);
values[i] = mod.read();
Serial.print(values[i],HEX);
}
Serial.println();
}
moisture1=values[4]/10;
return moisture1; // int(values[3]<<8|values[4]);
}
You might find it easier to reduce your code down to just read a single parameter from the sensor and then get that working before incrementally adding functionality.
What logic levels does the MAX485 use and what logic levels does the RoLa module use ?
its already reduced to two.
RoLa at 3.3V and MAX485 at 5V




