I bought a 3 in 1 EC meter which made in China and the interface is RS-485.
Hardware wire connection I think is correct.
I also get the values from Arduino IDE serial monitor.
But I thought the values are not correct.
Here is the data sheet and result link: - YouTube
And here is my code:
#include <SoftwareSerial.h>
#include <Wire.h>
#define RE 8
#define DE 7
const byte ec[ ] = {0x01, 0x03, 0x00, 0x00, 0x00, 0x03, 0x05, 0xCB};
byte values[8];
SoftwareSerial mod(2, 3);
void setup()
{
Serial.begin(9600);
mod.begin(9600);
pinMode(RE, OUTPUT);
pinMode(DE, OUTPUT);
delay(1000);
}
void loop()
{
// EC reading
digitalWrite(DE, HIGH);
digitalWrite(RE, HIGH);
delay(1000);
if (mod.write(ec, sizeof(ec)) == 8)
{
digitalWrite(DE, LOW);
digitalWrite(RE, LOW);
for (byte i = 0; i < 7; i++)
{
values[i] = mod.read();
Serial.print(values[i], HEX);
}
Serial.println();
}
int soil_ec = int(values[3]<<8|values[4]);
delay(1000);
Serial.print(" Soil EC: ");
Serial.print(soil_ec);
delay(2000);
}
// datasheet
Inquire Frame
Address Function Start/End address Data length CRC-L CRC-H
0x01 0x03 0x00 0x00 0x00 0x03 0x05 0xCB
Response Frame
Address Function Return Soil-moisture Soil-temperature EC-value CRC-L CRC-H
0x01 0x03 0x06 0x02 0x92 0xFF 0x9B 0x03 0xE8 0xD8 0x0F