I have a parking guide using an ultrasonic sensor (HC-SR04), based on the instructions here. I'm trying to modify the code so that the Arduino goes to sleep after a certain period of inactivity (say, 30 seconds), and wake again when the sensor 'sees' a car drive into the garage. The code here shows how to wake it with a solar panel.

However, the way I understand it, the solar panel is able to wake the Arduino because it doesn't need external power to work (because it's a solar panel). Would it be possible to do the same with an ultrasonic sensor (HC-SR04), which does need power?

It'll be running off mains power, but I don't want it to be drawing power when it's not needed.

1 Answer 1


In order to make the ultrasonic sensor work, the Arduino has to run some code to control it. So it won't do anything while the Arduino is asleep.

What you can do is have the Arduino sleep for some reasonable amount of time, wake up and read the sensor, and then go back to sleep. Maybe wake it up once every few seconds. Do you really need to react to a car in the lot the millisecond it pulls in?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.