I am using a SparkFun Pulsed Coherent Radar Sensor - Acconeer XM125 connected to a SparkFun IoT RedBoard - ESP32 Development Board via I2C.
The XM125 has been flashed with i2c_distance_detector.bin and I am using Arduino Example09_DistanceAdvancedSettings from the SparkFun XM125 Arduino Library. I have modified the sketch a bit. I am only interested in one distance reading. I am using the radar module to measure the distance to the surface of liquid in a tank. From there my program can calculate the tank fill level. The problem is the distance reading I get ranges from being within 1 or 2mm of actual measured value, or can be as far off as 20% less than actual measured value all the way to 50-100% higher than measured value. I have the sensor sitting on top of the tank that is 97cm deep. With the tank full the reading is very accurate but as I slowly empty the readings are sporadic even when I stop the flow to let the reading settle. There are times when the reading is spot on within 1 or 2mm but most times it jumps all over. I’ve attached my Arduino sketch. I only read distancePeak0. It is the only distance reading that comes close to actual measured value. I couldn’t figure out how to change from the default peak sorting from strongest to closest using the Arduino library. I’m not sure if that would have helped? Please let me know if you have any suggestions on how I could get a more accurate and consistent reading. All I need is one accurate reading to the surface of liquid in my tank.
Are the readings changing rapidly or are they fairly steady with some outliers? Paste your serial printout/readings
Some people have fashioned small floating platforms on poles that just slide up and down with the water level and use the radar to read the floating platform’s distance instead of the water’s
The readings changed rapidly and were sporadic at times and steady at times throughout the draining of the test tank. My test tank is 495mm deep.
I tried increasing the time from half a second to three seconds and that helped. I also tried putting a floating platform.
Even with the slowed down loop and the floating platform the readings are a bit whacky.
I’ve attached the serial monitor output with timestamps. There was a reading every three seconds as the tank drained over about a seven minute period. There were times when the reading was 0mm. My sketch is setup to only print if distance !=0. The jumps over three seconds in the serial monitor output are when the reading was 0mm,
I’ve attached the sketch used for this experiment.
Am I expecting to much on what to expect for consistency and accuracy?
Is there something in the sketch that could be tweaked, added or removed to stabilize the readings?
Thank you so much for any advise!
serial Monitor.pdf (14.2 KB)
Sketch.pdf (24.2 KB)
In a water tank the humidity is 100 percent, and very small changes in temperature lead to condensation, which is fatal to powered, unprotected electronics in the long run, and leads to errors and performance problems in the short run.
A float sensor or exterior water pressure sensor on the outlet are the preferred choices for measuring tank water level.
You might consider an ultrasonic sensor, they would be very reliable for determining the level of fluid in a tank.
The water tank is just for testing, the application goal is to monitor my 300 gallon heating oil tank in a climate that can get as cold as -40 degrees Fahrenheit in the winter and +100 in the summer. Ultrasonic is to flakey that is why I am toying with the radar sensor. There are some commercial grade products out on the market but are very expensive plus they wouldn’t easily integrate into my smart home system for remote monitoring.
Humidity is a problem in any outdoor sensor application, and extremes of temperature are another. Electronics have to be protected by at the very least “conformal coating” and in some situations, completely potted in an inert compound.
I am aware of extreme conditions on electronics. I’ve worked on electronics in remote Alaska for over 30 years. All I am looking for is advice on how to tweak my Arduino sketch to squeeze the best performance from the radar sensor.
I reached out to Acconeer and they provided some settings to add to my Arduino sketch that helped tremendously. After adding the following #define statements shown below to the sketch that I have attached previously I ran quite a few trials with and without a float. The readings without a float were actually more accurate. I’m still running trials to see how consistent and accurate this setup is in a controlled environment. Once I get it down I will introduce it to the outdoors and se how it performs.
#define SMALL_TANK_RANGE_START_M 0.03f
#define SMALL_TANK_RANGE_END_M 0.5f
#define SMALL_TANK_MAX_STEP_LENGTH 2U
#define SMALL_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_2
#define SMALL_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST
#define SMALL_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
#define SMALL_TANK_THRESHOLD_SENSITIVITY 0.0f
#define SMALL_TANK_SIGNAL_QUALITY 20.0f
#define SMALL_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true