Soil Sensor 7 in 1 using an Arduino UNO

Hi, I´m a beginner in these topics, and I have to work with and a soil sensor that measure 7 parameters, I only receive the sensors and I don´t have any information about it, but I am using a code and I only have a value of 255 in all the them, also I don´t give attention with the OLED monitor part now, because i want to make it work first, I hope that someone could help me with this, thank you, that is an image of the sensor, the code and the values in serial:


#include <SoftwareSerial.h
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
/////
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define RE 8
#define DE 7

//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 soil_ph[] = {0x01, 0x03, 0x00, 0x06, 0x00, 0x01, 0x64, 0x0b};
const byte soil_moist[] = {0x01, 0x03, 0x00, 0x12, 0x00, 0x01, 0x24, 0x0f};
const byte temp[] = {0x01, 0x03, 0x00, 0x12, 0x00, 0x02, 0x64, 0x0e};
const byte ec[] = {0x01, 0x03, 0x00, 0x15, 0x00, 0x01, 0x95, 0xce};

byte values[11];
SoftwareSerial mod(2,3);////// TX AND RX

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

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)
delay(500);
display.clearDisplay();
display.setCursor(25, 25);
display.setTextSize(1);
display.setTextColor(WHITE);
display.println(" Soil Sensor");
display.setCursor(25, 40);
display.setTextSize(1);
display.print("Initializing");

display.display();
delay(1000);

}

void loop() {

byte val1,val2,val3,val4,val5,val6,val7;
val1 = nitrogen();
delay(250);
val2 = phosphorous();
delay(250);
val3 = potassium();
delay(250);
val4 = ph();
delay(250);
val5 = moist();
delay(250);
val6 = stemp();
delay(250);
val7 = econd();
delay(250);

Serial.print("Nitrogen: ");
Serial.print(val1);
Serial.println(" mg/kg");
Serial.print("Phosphorous: ");
Serial.print(val2);
Serial.println(" mg/kg");
Serial.print("Potassium: ");
Serial.print(val3);
Serial.println(" mg/kg");
Serial.print("Soil pH: ");
Serial.print(val4);
Serial.println(" pH");
Serial.print("Soil Moisture: ");
Serial.print(val5);
Serial.println(" %");
Serial.print("Temperature: ");
Serial.print(val6);
Serial.println(" C");
Serial.print("Electrical Conductivity: ");
Serial.print(val7);
Serial.println(" mS/m");
delay(1000);

/////
display.clearDisplay();

display.setTextSize(1);
display.setCursor(0, 0);
display.print("N: ");
display.print( val1);
display.setTextSize(1);
display.print(" mg/kg");

display.setTextSize(1);
display.setCursor(0, 15);
display.print("P: ");
display.print( val2);
display.setTextSize(1);
display.print(" mg/kg");

display.setTextSize(1);
display.setCursor(0,30);
display.print("K: ");
display.print( val3);
display.setTextSize(1);
display.print(" mg/kg");

display.setTextSize(1);
display.setCursor(0,43);
display.print("PH: ");
display.print(val4);
display.setTextSize(1);
display.print(" ph");

//
display.setTextSize(1);
display.setCursor(0,57);
display.print("SM: ");
display.print(val5);
display.setTextSize(1);
display.print(" %");

// display.setTextSize(1);
// display.setCursor(50,57);
// display.print("T: ");
// display.print(val6);
// display.setTextSize(1);
// display.print(" C");
//
//
// display.display();
// delay(3000);
//

//

//
// display.setTextSize(1);
// display.setCursor(0,60);
// display.print("T: ");
// display.print(val7);
// display.setTextSize(1);
// display.print(" C");

display.setTextSize(1);
// display.setCursor(0,60);
// display.print("T: ");
// display.print(val7);
// display.setTextSize(1);
// display.print(" C");

display.display();

delay(1000);

}

byte nitrogen(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(nitro,sizeof(nitro))==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();
}
return values[4];
}

byte phosphorous(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(phos,sizeof(phos))==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();
}
return values[4];
}

byte potassium(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(pota,sizeof(pota))==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();
}
return values[4];
}

byte ph(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(soil_ph,sizeof(soil_ph))==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();
}
return values[4];
}

byte moist(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(soil_moist,sizeof(soil_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();
}
return values[4];
}

byte stemp(){
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();
}
return values[4];
}

byte econd(){
digitalWrite(DE,HIGH);
digitalWrite(RE,HIGH);
delay(10);
if(mod.write(ec,sizeof(ec))==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();
}
return values[4];
}

![SERIAL|257x499](upload://ukpPpDfThgNHlUnOuNnl4kRpd5N.jpeg)
![IMG_8295|666x500](upload://5AHfs2mYtznEWR1UuXIDJN2lhgW.jpeg)
![IMG_8294|666x500](upload://zBMGB7lXYKNMTL9nKmoNIhoFBV9.jpeg)

Don't bother, those sensors are fake. It's simply impossible for them to do what they claim to do, other than some conductivity measurement.

This scam is getting quite annoying, and based on the volume of questions here (several a week it seems) they must be doing very good business, sadly...

How can i know that they are fake?

Five metal prongs can't measure what they claim. It's of course utterly ridiculous that they can measure five totally different parameters with a few pins.

There is no way for those pins to distinguish between the various ions. No specificity possible with just some steel pins. No pH sensor there - those are always in the form of glass bulbs, you can't just ram those in the ground, and even if you stick them in the ground they can't read pH as pH depends on it being a watery solution.

There doesn't even exist a way to measure all those ions (nitrogen comes in various forms in the soil, atmospheric nitrogen is not even part of the equation) short of doing a lab analyses.

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