Receiving 25.5 for all readings from PR-3001-TR-ECTHPH-N01 soil transmitter

五插针土壤变送器(485型).pdf (2.7 MB)
@markd833 @TomGeorge @Ballscrewbob
Please I need your help with this, I was receiving just 25.5 for all the readings, I guess my code was wrong.
Attached are the multi sensors datasheet and a screenshot of the address page.

@markd833 @TomGeorge @vision2max997 @Ballscrewbob
My connection's illustration

Since you have not shared your code, we can only guess that your guess might be right.

1 Like

useless.

Provide the data sheet of the sensor used as PDF.

1 Like

@paulpaulson
@markd833

Attached is a pdf copy of the sensor's data sheet
五插针土壤变送器(485型).pdf (2.7 MB)

@markd833
@paulpaulson

#include <SoftwareSerial.h>

#define RE 7
#define DE 6

const uint32_t TIMEOUT = 500UL;

//const byte code[]= {0x01, 0x03, 0x00, 0x1e, 0x00, 0x03, 0x65, 0xCD};
//const byte nitro[] = {0x01, 0x03, 0x00, 0x1e, 0x00, 0x01, 0xe4, 0x0c};
//const byte phos[] = {0x01, 0x03, 0x00, 0x1f, 0x00, 0x01, 0xb5, 0xcc};
//const byte pota[] = {0x01, 0x03, 0x00, 0x20, 0x00, 0x01, 0x85, 0xc0};

//const byte code[]= {0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x44, 0x09};
const byte moist[] = {0x01, 0x03, 0x08, 0x02, 0x92, 0x57, 0xB6};
const byte temp[] = {0x01, 0x03, 0x08, 0xFF, 0x9B, 0x57, 0xB6};
const byte EC[] = {0x01, 0x03, 0x08, 0x03, 0xE8, 0x57, 0xB6};
const byte PH[] = {0x01, 0x03, 0x08, 0x00, 0x38, 0x57, 0xB6};

byte values[11];
SoftwareSerial mod(8, 9); // Rx pin, Tx pin

void setup() {
Serial.begin(9600);
mod.begin(9600);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);

delay(500);
}

void loop() {
byte val1, val2, val3, val4;

Serial.println("Moisture: ");
val1 = moisture();
Serial.println(val1);
Serial.println(" %");
delay(1000);

Serial.println("Temperature: ");
val2 = temperature();
Serial.println(val2);
Serial.println(" *C");
delay(1000);

Serial.println("Conductivity: ");
val3 = conductivity();
delay(1000);
Serial.println(val3);
Serial.println(" us/cm");

Serial.println("Ph: ");
val4 = ph();
delay(1000);
Serial.println(val4);
Serial.println(" ph");

delay(5000);
}

byte moisture() {
uint32_t startTime = 0;
uint8_t byteCount = 0;

digitalWrite(DE, HIGH);
digitalWrite(RE, HIGH);
delay(10);
mod.write(moist, sizeof(moist));
mod.flush();
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);

startTime = millis();
while ( millis() - startTime <= TIMEOUT ) {
if (mod.available() && byteCount<sizeof(values) ) {
values[byteCount++] = mod.read();
printHexByte(values[byteCount-1]);
}
}
Serial.println();
return values[4];
}

byte temperature() {
uint32_t startTime = 0;
uint8_t byteCount = 0;

digitalWrite(DE, HIGH);
digitalWrite(RE, HIGH);
delay(10);
mod.write(temp, sizeof(temp));
mod.flush();
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);

startTime = millis();
while ( millis() - startTime <= TIMEOUT ) {
if (mod.available() && byteCount<sizeof(values) ) {
values[byteCount++] = mod.read();
printHexByte(values[byteCount-1]);
}
}
Serial.println();
return values[4];
}

byte conductivity() {
uint32_t startTime = 0;
uint8_t byteCount = 0;

digitalWrite(DE, HIGH);
digitalWrite(RE, HIGH);
delay(10);
mod.write(EC, sizeof(EC));
mod.flush();
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);

startTime = millis();
while ( millis() - startTime <= TIMEOUT ) {
if (mod.available() && byteCount<sizeof(values) ) {
values[byteCount++] = mod.read();
printHexByte(values[byteCount-1]);
}
}
Serial.println();
return values[4];
}

byte ph() {
uint32_t startTime = 0;
uint8_t byteCount = 0;

digitalWrite(DE, HIGH);
digitalWrite(RE, HIGH);
delay(10);
mod.write(PH, sizeof(PH));
mod.flush();
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);

startTime = millis();
while ( millis() - startTime <= TIMEOUT ) {
if (mod.available() && byteCount<sizeof(values) ) {
values[byteCount++] = mod.read();
printHexByte(values[byteCount-1]);
}
}
Serial.println();
return values[4];
}

void printHexByte(byte b)
{
Serial.print((b >> 4) & 0xF, HEX);
Serial.print(b & 0xF, HEX);
Serial.print(' ');
}

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