Throw-in Type Liquid Level Transmitter Spiking readings
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
I am experiencing some very unstable reading from the Throw-in Liquid level sensor, and have seen a few posts with similar problems, but no real resolution.
For the purpose of this post, I am reading the value from the Analog current to Voltage sensor using the ESP32 analogReadMilliVolts call. The code actually takes 60 readings 1 second apart and calculates the average on each loop (READER_SIZE == 60).
tank_value = 0;
for(u_int8_t count = 0; count < READER_SIZE; count++)
{
tank_read[count] = analogReadMilliVolts(A0);
tank_value += tank_read[count];
delay(1000);
}
uint32_t avg_value = tank_value / READER_SIZE;
During initial development I had a resistor and variable resistor connected instead of the Pressure sensor, set to give a range of current values equivalent to the Pressure sensor (1K to 2K Ohms with 24v). The readings I got were reasonable and fairly stable:
![](https://dfimg.dfrobot.com/61b05ef5aa9508d63a41925a/makelog/9811eec7dc277ef02bcf2e6e436539f8.png)
Once I connected the pressure sensor however, the readings became a lot more unstable (Same scale used here for comparison).
![](https://dfimg.dfrobot.com/61b05ef5aa9508d63a41925a/makelog/d476fc55abc4a4a50688a398b17c619f.png)
Looking a bit closer, the spikes seem to occur at fairly regular intervals of about 9-10 minutes apart.
![](https://dfimg.dfrobot.com/61b05ef5aa9508d63a41925a/makelog/c64100a326a0e045dafddddc4afb73cf.png)
Does anyone have any insight into this? I don't think it has anything to do with my code, or any RTOS background processing on the ESP32-C3 chip as I don't have any WiFi or Bluetooth etc enabled, and the previous runs of the code with the resistor network would rule out everything except the pressure sensor.
The fact that I am seeing a 15% difference on the readings even though I am taking 60 readings each time would also indicate that the pressure sensor is actually cycling through this range rather than just providing a single spike as this would be out of the range of the analog current to voltage sensor.
For reference, the sensor is sitting in a 4500l tank, which is about 80% full,. The water depth is about 1.5 meters, with the sensor near the bottom. If I move the sensor to just below the surface I get an adjusted reading as expected, but the spiking still persists.
This is my full loop() call:
void loop()
{
tank_value = 0;
for(u_int8_t count = 0; count < READER_SIZE; count++)
{
tank_read[count] = analogReadMilliVolts(A0);
tank_value += tank_read[count];
Serial.print("Analog Read: ");
Serial.println(tank_read[count]);
delay(1000);
}
uint32_t avg_value = tank_value / READER_SIZE;
Serial.print("Tank Level: ");
Serial.println(avg_value/41);
char cmd[13];
sprintf(cmd, "%02u%06u%03u%01u",
0x01,
avg_value,
avg_value / 41,
0x00);
lorawan->send(cmd, strlen(cmd));
}
Hi
Please use an external ADC. The in-built ADC of ESP32 is unstable and inaccurate. It is highly recommended to use an ADS1115 ADC with external power supply for ESP32, which should fix the problem.
Hope it can help.
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
A good article and a good book can change the fate of so many people. Thanks for the valuable sharing, please keep it up to date and I will always follow you. [url=https://play-snake.co/] play snake[/url]
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)