Hi guys, my soil moisture sensor shows wrong datas and it doesn't vary according to humidity, it is at a fixed value like 100%.
I'm begginer in things like this, so please help me! Thanks a lot!
My code is:
// Projeto Curto Circuito – Estação Climática
#define BLYNK_PRINT Serial // Blynk Serial
#include "DHT.h" // Biblioteca DHT
#include <ESP8266WiFi.h> // Biblioteca ESP Wi-Fi
#include <SPI.h>
#include <Adafruit_BMP280.h> // Biblioteca BMP280
#include <BlynkSimpleEsp8266.h> // Biblioteca Blynk para ESP
#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
#define DHTPIN 0 // Define que o pino OUT estará em D3
#define BMP_SCK 2 // Define que o pino SCK estará em D4
#define BMP_SDI 14 // Define que o pino SDI estará em D5
#define BMP_CS 12 // Define que o pino CS estará em D6
#define BMP_SDO 13 // Define que o pino SDO estará em D7
BlynkTimer timer;
DHT dht(DHTPIN, DHTTYPE);
Adafruit_BMP280 bmp280(BMP_CS, BMP_SDI, BMP_SDO, BMP_SCK);
char auth[] = "e28huBOCGl1LO2sW9ccmiUe1zzvFsJkS"; // Insira o token de autenticação do e-mail
char ssid[] = "Begas"; // Insira o nome da Rede
char pass[] = "Ferrari11"; // Insira a senha
int pino_c = 5; // Soil moisture sensor at pin D1
int pino_d = 16; // Rain sensor at pin D0
int pino_a = A0; // Rain sensor at pin A0
int val_c = 0; // Keeps the value at digital pin
int val_d = 0; // Keeps the value at digital pin
int val_a = 0; // Keeps the value at analog pin
void sendSensor(){
float h = dht.readHumidity(); // Stores the humidity reading in h
float t = dht.readTemperature();// Stores the temperature reading in t
float p = bmp280.readPressure();// Stores the pressure reading in p
float a = bmp280.readAltitude(1013.25); // Stores the altitude reading in a
Blynk.virtualWrite(V5, h); // V5 virtual door humidity
Blynk.virtualWrite(V2, t); // V2 virtual door temperature
Blynk.virtualWrite(V8, p); // V8 virtual door pressure
Blynk.virtualWrite(V9, a); // V9 virtual door altitude
Blynk.virtualWrite(V10, val_a); // V10 virtual door rain sensor
Blynk.virtualWrite(V11, val_c); // V11 virtual door soil moisture sensor
val_c = digitalRead(pino_c); // Stores the pin_c humidity value reading
val_a = analogRead(pino_a); // Stores the pin_a rain sensor value reading
}
void setup() {
pinMode(pino_d, INPUT); // Declare pin_d as INPUT
pinMode(pino_a, INPUT); // Declare pino_a as INPUT
pinMode(pino_c, INPUT); // Declare pino_c as INPUT
Serial.begin(9600); // Taxa de transmissão 9600
dht.begin();
bmp280.begin();
Blynk.begin(auth, ssid, pass);
}
void loop() {
timer.run(); timer.setInterval(1000L, sendSensor);
Blynk.run();
}
I'm use the pin_c for the soil moisture sensor.
I attached the photo of the sensor.
Sorry for the bad english and thank you!!!
Maybe you can give us more details on your method, expectations and all sensors that you are using.
Also, I don't think English is important to everyone here. It seems to be very international and everyone has their issues with the language. Don't apologize for bad English. We won't judge.
Is the picture the soil sensor? Well it consists of a transistor and two resistors. Why do you have it on a digital pin? Digital can only give 0 and 1. You have to use an analog pin.
It is a resistive type soil moisture sensors. They will work for a few hours. This one is even worse because the metal probes are very close to each other.
Maybe you can give us more details on your method, expectations and all sensors that you are using.
Also, I don't think English is important to everyone here. It seems to be very international and everyone has their issues with the language. Don't apologize for bad English. We won't judge.
Hi man, i don't solve the problem with BMP280 yet.
I have this two problems to solve, but when i get any solution i will post.
dyso:
Is the picture the soil sensor? Well it consists of a transistor and two resistors. Why do you have it on a digital pin? Digital can only give 0 and 1. You have to use an analog pin.
Alright, i understand, but when i put the sensor on analog, it starts to show crazy numbers that don't make any sense, i don't know what's wrong, i think the people who comment here are right, this is a bad sensor.
PS: I change the digital pin to analog ini the sketch.
It is a resistive type soil moisture sensors. They will work for a few hours. This one is even worse because the metal probes are very close to each other.
You need a capacitive soil moisture sensor.
Alright dude, i will try buy another sensor, i think it could be work
Well if you only use an analogRead command, then you will get values that range from 0 to 1023. That means that
Measurement(V) = measurement* 5/1023
Also you need a transfer Function. Use the transfer function and you’ll get what you need.
If you order a new sensor, I am pretty sure that it will be a simple probe consisting of the same components. I agree that more space between the connectors is better.
Have you actually asked yourself what you are measuring? I mean, have you asked yourself what does the sensor do when the dampness of the soil changes?
As an experiment, put 2 metal rods in dry soil (maybe 2cm apart) and measure the Resistance between the 2 poles with an ohmmeter (multimeter). Add water and observe the resistance again. How does it react?
dyso:
Well if you only use an analogRead command, then you will get values that range from 0 to 1023. That means that
Measurement(V) = measurement* 5/1023
Also you need a transfer Function. Use the transfer function and you’ll get what you need.
If you order a new sensor, I am pretty sure that it will be a simple probe consisting of the same components. I agree that more space between the connectors is better.
Have you actually asked yourself what you are measuring? I mean, have you asked yourself what does the sensor do when the dampness of the soil changes?
As an experiment, put 2 metal rods in dry soil (maybe 2cm apart) and measure the Resistance between the 2 poles with an ohmmeter (multimeter). Add water and observe the resistance again. How does it react?
Hi dyso, i think you are right, i'm begginer in arduino, but your idea makes sense, i will try use the multimeter.
I have already buy a new sensor, i'll gather all ideas that were posts here and try.