I have a pressure sensor MPX5700 that outputs a variable voltage when air pressure is applied to it.
But I want to put an Arduino Mega into sleep state and have it woken up when some pressure is applied to the sensor. The sensor could be on all the time, it consumes 7-10mA when powered.
But my mega has an lcd display and other sensors, so I’d like it to sleep when not in use.
I understand a simple Low Pass Filter can convert a digital PWM signal to analog.
But is there a simple way (circuit) for me to convert my analog output voltage from the sensor to a digital signal, so I can hook this then digital converted signal to arduino pin 2 as an interrupt to wake it when certain voltage (that would mean ON) is detected? For instance, when voltage is from 0 to 0.5V means LOW. Above it means HIGH.
External interrupts, pin-change interrupts, and the watchdog timer interrupt, can also be used to wake the processor up. This can be very handy, as in sleep mode the processor can be configured to use a lot less power (eg. around 10 microamps). A rising, falling, or low-level interrupt can be used to wake up a gadget (eg. if you press a button on it), or a "watchdog timer" interrupt might wake it up periodically (eg. to check the time or temperature).
Pin-change interrupts could be used to wake the processor if a key is pressed on a keypad, or similar.
The processor can also be awoken by a timer interrupt (eg. a timer reaching a certain value, or overflowing) and certain other events, such as an incoming I2C message.
Waking from sleep with a timer
Well, this sleeping as all very well, but a processor that stays asleep isn't particularly useful. Although, I have seen an example of that: the TV Begone remote control. What that does is send out some codes (to turn TVs off) and then goes to sleep permanently. The "activate" button on the gadget is the reset button. When you press that it does its stuff again.
Meanwhile this sketch below shows how you can use the watchdog timer to sleep for 8 seconds (the maximum you can set up a watchdog for) and then flash the LED 10 times, and go back to sleep. Whilst asleep it uses about 6.54 µA of current, so presumably the watchdog timer has a bit of an overhead (like, 6.2 µA).
I read through your topics on your website, but I want to make myself more specific on what I want.
I specifically want to put the Mega to sleep after some minutes of not using it mostly because there are some sensors, a BLDC motor, and I want only to preserve my circuit, display and motor from wear and be on all the time. I don’t want to use a watchdog timer.
If I manage to convert the analog signal from the pressure sensor to a LOW/HIGH state,
and if it’s able to wake arduino from pin 2, is it possible, when arduino is back on, that it ignores pin2 as a interrupt so I can use the real analog values of the sensor in another pin to check the variable voltage and do its measurements?
I mean the sensor would be attached to pin2 (digitally converted) and to another analog pin (before the adc circuit) to read it’s real values and do it’s stuff.
Pin2 would only have to be used to wake up when asleep and be inert, innefective when arduino is on.
Have you tried simply connecting the sensor output to a digital pin on the Mega? It may work well enough. The pin will see low voltages as LOW and higher voltages as HIGH. The question is will the transition point come at a convenient pressure for your project.
If not, the simplest solution would be to use an analog comparator chip. These chips often have 2 or 4 analog comparators on the chip, but you only need one. Each comparator has 2 analog inputs and one digital output. You would connect the sensor output to one of the comparator inputs and a trimmer pot to the other. The output goes to the Mega interrupt pin.
PaulRB:
Have you tried simply connecting the sensor output to a digital pin on the Mega? It may work well enough. The pin will see low voltages as LOW and higher voltages as HIGH. The question is will the transition point come at a convenient pressure for your project.
If not, the simplest solution would be to use an analog comparator chip. These chips often have 2 or 4 analog comparators on the chip, but you only need one. Each comparator has 2 analog inputs and one digital output. You would connect the sensor output to one of the comparator inputs and a trimmer pot to the other. The output goes to the Mega interrupt pin.
Thanks PaulRB!
I liked your idea of a comparator chip.. It´s exactly what´s needed. I even found some ready modules, based on the LM393 over ebay/aliexpress already. Over my country I still didn´t find it yet. But I´ll keep looking for.
Use an OpAmp as comparator attached to the sensor output, and use the output of that as digital signal for your Arduino. You should be able to connect the same analog signal to an analog pin at the same time, so upon waking up you can take a measurement.