Electronic – arduino – Ultrasonic sensor(ping) and deep sleep Arduino

arduinointerruptssensorsleepultrasound

Is it possible to use an ultrasonic sensor to wake up an Arduino which is in deep sleep when an object is detected within a few cm and then do stuff?

Best Answer

For a truly low-power, Arduino-based solution at least the following is needed:

A) HARDWARE SIDE:

  1. Use a supply voltage and clock frequency as low as possible. The Arduino Pro Mini 3.3V @ 8Mhz board is a good starting point for a first project.
  2. Get rid of all the LEDs in the board. Their consumption is in the mA range, way too high.
  3. Get rid of the onboard regulator and replace it with a low quiescent current, low dropout regulator like the MCP1700. It can source only 250 mA whereas the AMS1117 is rated up to 1A, but 250 mA will probably be good enough for your low-power application. OTOH, just in case you were wondering: you don't need a switching regulator unless your Arduino spends most of the time awake and consuming a lot of current, which is a very unlikely scenario. The high quiescent current of switching regulators rules them out for this kind of applications.
  4. Select a low-power consumption sensor and signal conditioning circuitry. PIR and CMOS logic family 74HC are good technologies for this. As pointed by Nick Alexeev, an ultrasonic sensor will be constantly emitting, thus rendering useless your power savings on the Arduino. Avoid it.
  5. The signal conditioning circuit must generate a level interrupt from whichever signal is delivered by the sensor. Timing elements (like capacitors) or latches may be required for this. To be on the safe side, design it for a 100 ms resettable pulse.

B) SOFTWARE SIDE:

  1. Install a low power Arduino library like this one. Use the ATmega328p power-down sleep mode.
  2. Write a interrupt service routine (ISR). This is the piece of code that will deal with whichever needs to be done upon an interrupt event.
  3. Configure (attach) the interrupts as required. Note that only level-triggered interrupts can wake up ATmega328p from power-down sleep mode, as per its datasheet:

Wake-up sources

Here you can find really good, practical information on the way to go low power. For a more thorough guide, read this as well.

Related Topic