TroubleshootingArduino

Ultrasonic Sensor A01NYUB (SEN0313): how to read every 60 minutes?

userHead Carl078 2023-07-14 22:40:46 723 Views8 Replies

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

 

 

 

 

 

 

2023-12-10 13:16:05

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?

 

 

userHeadPic Carl078
2023-07-24 06:06:39

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.

userHeadPic bidrohini.bidrohini
2023-07-19 22:24:42

I 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. 

userHeadPic Carl078
2023-07-17 09:25:42

Either 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

userHeadPic bidrohini.bidrohini
2023-07-17 08:27:48

yes , 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 ?

userHeadPic Carl078
2023-07-15 06:30:48

Is your sensor working well otherwise? Have you tested it with the example code here? https://wiki.dfrobot.com/A01NYUB%20Waterproof%20Ultrasonic%20Sensor%20SKU:%20SEN0313

userHeadPic bidrohini.bidrohini
Carl078 wrote:

Yes it works with the example code.

2023-12-12 07:27:09
1 Replies