Ultrasonic Sensor A01NYUB (SEN0313): how to read every 60 minutes?
Hello, if i change the example code to read data once a hour I always read zero value.
I modified the original example in the page https://wiki.dfrobot.com/A01NYUB%20Waterproof%20Ultrasonic%20Sensor%20SKU:%20SEN0313
just to test to read the measure every 10 seconds but it doesn't work.
The code is here below. Can I attach the code here in the forum?
https://pastebin.com/3dv4JiHe
I tested this simple code and it works only if I use a delay of 100ms. Why?
void loop()
{
Serial.println("TURN ON!");
turnOnSensor();
measure();
Serial.println("TURN OFF!");
turnOffSensor();
delay(100);
}
I would like to have a measure every 30minutes, then i would like the sensor OFF for 30 minutes.
What am I missing?
Carl078
Ultrasonic sensors work by sending a pulse and measuring the time it takes for the pulse to bounce back. If you have set the sensor to measure once an hour, there might be a timing issue that is causing the sensor to miss the echo response. The sensor might not have enough time to complete the measurement within the one-hour interval.
bidrohini.bidrohiniI don't use RTC. If i configure Arduino timer, it works to do any action (I print something) but it doesn't work to measure distance.
I had an idea both to measure every hour and also to save sensor life.. I will power the sensor every hour using a digital output. It looks that the sensor absorbs <15mA and each raspberry digital output can give up to 20mA.
I will test it in next days.
Carl078Either you have to configure the timer of the Arduino, or you'll have to add an RTC.
https://forum.arduino.cc/t/how-to-write-code-to-run-program-for-1-hour-and-cease-for-1-hour-and-keep-going/669544/14
https://www.theengineeringprojects.com/2016/04/ds1307-arduino-based-digital-clock-proteus.html
bidrohini.bidrohiniyes , the example code works perfectly.
I noticed that the sensor stops working after few months. Is it possible that reading fast 24h creates some damage?
I would like to try to read just once a hour. Is there a way ?
Carl078Is your sensor working well otherwise? Have you tested it with the example code here? https://wiki.dfrobot.com/A01NYUB%20Waterproof%20Ultrasonic%20Sensor%20SKU:%20SEN0313
bidrohini.bidrohiniYes it works with the example code.