The sensors I use are dht11 for humidity and for those soil moisture sensor are capacitive soil moisture sensor v1.2. As for the microcontroller the one who receive is esp32 wroom and the one that sends data is arduino.
" The DHT-11 sensor uses a one-wire protocol to communicate the humidity and temperature values. The sensor act as a slave to a host controller. The digital communication between the DHT11 and the host controller (like Arduino) can be breakdown into four steps: ......."
So, even though I'm not sure if the other man mean it when he said that the DHT11 sensor is not I2C compatible. That in order for me to send the data to another micro controller, I must have a certain kind of I2C sensor.
will the lever shifter have an impact to data transmission?
also from what you said. Do I need to separate the sensor arduino to another arduino to act as master?
Tell me the type number or picture of your Soil Moisture Sensor. I will show you the schematic (connection diagram among DHT11, SM Sensor, UNO, Level Shifter, and ESP32) based on your descrption of post #3.
will you show me the schematic diagram of what you say. That will save me a lot of money if ever. If you also have program recommendation it will be great. Thank you so much.
1. Build the setup as per Fig-1. You must use Level shifter; otherwise, one or both MCU will be damamged due to mismatch of logic levels (ESP32 is a 3.3v device and UNO is a 5V device).
2. Upload the following sketch into Master-UNO to collect data from Moisture Sensor, show it on Serial Monitor and send to ESP32. (Sketch is taken from net; it is compiled and NOT tested.)
#include<Wire.h>
#define slaveAddress 0x23
const int AirValue = 620; //you need to replace this value with Value_1
const int WaterValue = 310; //you need to replace this value with Value_2
int soilMoistureValue = 0;
int soilmoisturepercent = 0;
void setup()
{
Serial.begin(9600); // open serial port, set the baud rate to 9600 bps
Wire.begin();
}
void loop()
{
soilMoistureValue = analogRead(A0); //put Sensor insert into soil
Serial.println(soilMoistureValue);
soilmoisturepercent = map(soilMoistureValue, AirValue, WaterValue, 0, 100);
if (soilmoisturepercent >= 100)
{
Serial.println("100 %");
}
else if (soilmoisturepercent <= 0)
{
Serial.println("0 %");
}
else if (soilmoisturepercent > 0 && soilmoisturepercent < 100)
{
Serial.print("Soil Moidture: ");
Serial.print(soilmoisturepercent);
Serial.println(" %");
}
Wire.beginTransmission(slaveAddress);
Wire.write(highByte(soilmoisturepercent));
Wire.write(lowByte(soilmoisturepercent));
byte busStatus = Wire.endTransmission();
if(busStatus != 0)
{
Serial.println("I2C Bus error!");
while(true); //wait for ever
}
delay(1000);
}
3. Upload the following sketch in ESP32 to acquire "SoilMoisturePercent" quantity from I2C bus and show on the Serial Monitor. (Compiled and NOT tested.)
4. Check that the Serial Monitor of both Arduino shows reasonable values. 5. Test the soil moisture value by dipping the soil moisture sensor probe in water or in soil or any liquid.
6. Use the sketches of Step-2, 3 as building blocks to develop sketch ofr the programming of DHT11.