Project Help Needed

agdsaghgsdahgadsgjadsgjsadgjads

The consensus seems to be that those soil sensors are a scam and have about as much validity as a golf ball locator.

Yes to all your questions except that sensor has been seen here many times, and it is a scam. You can measure Temp, PH, and Moisture, but the NPK is fake. Real NPK meters cost hundreds to thousands.Just ignore everything but Temp, Moisture and Ph

Hi van_der_decken,

You're right. The NPK measurement on these sensors is very questionable. Thanks for the heads-up.

Still, the sensor can be used for more reliable measurements, such as temperature, humidity, and conductivity. I'm having a lot of trouble with the wiring and programming part of the project.

Could you please help me out? Any tips would be very useful!

Don't be shy, just valid N sensor costs 4-5 digits.

Hi sonofcy,

Thanks for the clarification about the sensor. My main goal is just to complete the project and learn from it. I'm having a lot of difficulty with the wiring and programming, so any help would be greatly appreciated.

So at what point are you. How's your wiring and your code?

Hi, @Level_Automation
Welcome to the forum.

Are you building your project in stages?
First JUST get the sensor working with the ESP32, nothing else.
Then when you have that working , write code JUST another part to be addee.

DO NOT try and connect everything and expect it be correct, then write in one big mass some code and expect that to work.

Can you please tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

Hi kmin!

Thanks for asking! To be honest, I'm starting from scratch.

I tried to adapt several codes I found, but none worked out, and the wiring wasn't correct either. At the moment, I don't have a working code or a functional part of the project.

I'm having a hard time putting the whole thing together from the very beginning, so any help from you would be essential.

Hello!

I sincerely appreciate the advice and the warm welcome. Your approach of building a project in stages makes perfect sense, especially for a beginner like me.

You're right, the code I'm currently using works perfectly on a standard ESP32. However, my ultimate goal is to use LoRa technology, which is why I chose the ESP32 Heltec V3. I've tried to adapt the code for this board, but I haven't had any success, and I believe it's due to my very basic knowledge.

If you have any tips or could guide me on how to adapt the code for the Heltec V3, I would be extremely grateful. Any help in understanding the differences in programming for LoRa would be a huge help.

Thanks again!

There are plenty of beginner tutorials on line. Pick one that matches the sort of equipment you have and follow it very carefully.

If you run into trouble, post again with the required details. You can find those requirements in the "How to get the best out of this forum" post, linked at the head of every forum category.

Hello Jremington,

Thanks for the suggestion. I've actually already looked for online tutorials, but my difficulty is precisely that I can't find anything specific that combines the RS485 Sensor with the ESP32 Heltec via LoRa. That's why I made this post, hoping to find a starting point or a ready-made example that I could replicate and adapt.

If you happen to know of any tutorial or project that uses this specific setup, I would be very grateful.

You should be fine with any tutorial that uses an ESP32. You will also need an RS485 adapter. Randomly chosen tutorial from many examples.

Ignore the radio for now, as you have a great deal to learn. And as others have said, the "NPK" readings are nonsense.

Why didn't you mention any of this in your first post?

The first step in learning to use the radio is to follow relevant Heltec "getting started" tutorials and get basic communication working, without the soil sensor.

Once you understand that completely, it should not be a major problem to merge the two independent sets of code.

Forum members are happy to help with specific difficulties you encounter, but you are expected to do most of the work.

Hello Jremington,

My apologies for not providing all of this information in my first post. As I'm a beginner, I wasn't sure which details were most important to describe my difficulty.

You suggested starting with LoRa tutorials, and I have already tried that. My main problem is when I try to combine the RS485 sensor code with the LoRa communication code. When I try to merge them, I get many errors and can't adapt the code.

Since I couldn't find anything online that specifically combines the ESP32 Heltec with an RS485 soil sensor via LoRa, my intention with this post is to find a complete, ready-to-use project that I can replicate and study. My goal is to learn from a working example.

Then spend some time studying the "How to get the best out of this forum" post, and follow the directions.

Post wiring diagrams, all the code, using code tags, and a detailed description of the problems.

my intention with this post is to find a complete, ready-to-use project

That is not going to happen. However, if you want to hire someone to do the work, you can ask a moderator to move this thread to the Jobs and Paid Consultancy forum section.

Good luck with your project.

Thanks for your instructions. If there's nothing else to add, you don't need to post anything more.

to use the ESP32 hardware serial on the Heltec LoRa V3 I used GPIO39 and 40 (other GPIOs may be used)
sample code to test the loop back and RS232 module

// Heltec ESP32S3 LoRa  V3  Serial1 test - for loopback test connect pin GPIO40 U1TXD to pin GPIO39 U1RXD"

#define RXD1 39
#define TXD1 40

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(9600, SERIAL_8N1, RXD1, TXD1);
  Serial.println();
  Serial.printf("\n\nHeltec ESP32S3 LoRa  V3 serial1  test pin GPIO%d U1RXD pin GPIO%d U1TXD\n", RXD1, TXD1);
  Serial.printf("   for loopback test connect pin GPIO%d U1RXD to pin GPIO%d U1TXD\n", RXD1, TXD1);
  Serial.printf("RS232: ESP32S3 GPIO%d RXD1 to TTL/RS232 Rx and GPIO%d TXD1 to TTL/RS232 Tx\n", RXD1, TXD1);
  Serial.printf("RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx\n");
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    //Serial.write(inByte);
    Serial1.write(inByte);
  }
}

the ESP32 uses 3.3V logic - many RS485-TTL modules use 5V logic
make sure your RS485-TTL module can work with 3.3V logic
with the ESP32 I used XY-017 3.3v 5v 12v RS485 TO TTL RS485 SP3485 RS-485 Breakout which looks similar to the photo in post 1

serial monitor output

Heltec ESP32S3 LoRa  V3 serial1  test pin GPIO39 U1RXD pin GPIO40 U1TXD
   for loopback test connect pin GPIO39 U1RXD to pin GPIO40 U1TXD
RS232: ESP32S3 GPIO39 RXD1 to TTL/RS232 Rx and GPIO40 TXD1 to TTL/RS232 Tx
RS232 - loopback connect 9-pin D-type pin 2 Tx to pin 3 Rx
loopback test 1
loopback test 2 123445676890

Heltec LoRa V3 connect to a pair of Nanos using RS485-TTL modules

Heltec LoRa V3 code (works on ESP32 change RSD2 and TXD2 to suit specific module)

// ESP32 Serial1 to RS485 bus
//
// see https://microcontrollerslab.com/rs485-serial-communication-arduino-tutorial/

#define RS485Serial Serial1  // hardware serial port on ESP32

// RS485 VCC ESP32 to to 3.3V
#define RXD2 39  //  ESP32 Serial1 Receive  pin 16 to RS485 RO  (Receiver Output) /RXD
#define TXD2 40  //  ESP32 Serial1 Transmit pin 17 to RS485 DI  (Driver Input) /TXD

// some RS485 modules automatically switch between transmit and receive DE/RE not defined
// RS485 DE (Driver Enable set HIGH to enable)  and RE (Receiver Enable set LOW to enable) to ESP32 pins 18 and 19
//#define DE   //RS485 Direction control pin
//#define RE   //RS485 Direction control pin

#define RS485Transmit HIGH
#define RS485Receive LOW

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println("\n\nESP32 connect to RS485 bus - enter/receive text");
#ifdef DE  // if DE and RE are defined
  pinMode(DE, OUTPUT);
  pinMode(RE, OUTPUT);
  digitalWrite(DE, RS485Receive);  // Disable RS485 Transmit
  digitalWrite(RE, RS485Receive);  // Disable RS485 Transmit
#endif
  RS485Serial.begin(9600, SERIAL_8N1, RXD2, TXD2);  // set the RS485 data rate
}

// loop sending data to RS485 and receiving data
void loop() {
  if (Serial.available()) {           // Arduino Serial data avaliable?
#ifdef DE                             // if DE and RE are defined
    digitalWrite(DE, RS485Transmit);  // Enable RS485 Transmit
    digitalWrite(RE, RS485Transmit);  // Enable RS485 Transmit
#endif
    RS485Serial.write(Serial.read());  // Send byte to Remote RS485
    RS485Serial.flush();               // wait for byte to be transmitted
#ifdef DE                              // if DE and RE are defined
    digitalWrite(DE, RS485Receive);    // Disable RS485 Transmit
    digitalWrite(RE, RS485Receive);    // Disable RS485 Transmit
#endif
  }

  if (RS485Serial.available())         // RS485 serial data available?
    Serial.write(RS485Serial.read());  // read character and display it
}

Heltec serial output

ESP32 connect to RS485 bus - enter/receive text
hello from nano1
hello from nano 2
test2 from nano1 abcdefgh
test2 from nano 2 0987654321

Nano 1 output

Nano to RS485 - Use Serial Monitor, type in upper window, ENTER
Use Serial Monitor, type in upper window, ENTER
hello from Heltec LoRa V3
hello from nano 2
test2 from heltec 01234567890
test2 from nano 2 0987654321

Nano 2 output

Nano to RS485 - Use Serial Monitor, type in upper window, ENTER
Use Serial Monitor, type in upper window, ENTER
hello from Heltec LoRa V3
hello from nano 2
test2 from heltec 01234567890
test2 from nano 2 0987654321

photo of setup

In that case, concentrate only on the LORA and getting that to work reliably. Then you can add one more feature at a time and get that working with the LORA.