power failure project

hi iam new to arduino so be gentle with me , I have got a uno and gsm shield .what I want is a program to monitor say A0 pin and if it goes from gnd to +5v the gsm will send a text message to a set number say( power down ) but also if it goes back to gnd send another message to say(power on).Is there such a program or is it possible for someone with the knowledge to write one , many thanks in anticipation .


No one is going to write your code for you here but we can help you figure it out.

I have not worked with a gsm shield yet but the Arduino ide has a library that has a send sms example which is simple to use and under basics in the examples is read analog voltage which you can use to read if theres 5V on your A0 pin or not, I would just use a 5V cellphone adapter to supply the 5v to know if theres power or not.

You could just have an if statement to see if your analog pin doesnt have 5V then send a sms and the same if the power comes on but you will have to set a variable so that once the power is on it only sends the sms once and when it goes off you reset the variable.


I agree with the cell phone charger. Note however that the voltage is often higher than 5v so best fed into an optoisolator to a digital input. There is also a short (seconds) delay as the charger discharges.

This part of the programming is simple. Loop around until the input changes then go to your SMS procedure.


I understand loop around till the state changes but how do I then go to sms procedure ? .

Yes I agree with Weedpharma it will be better to use a digital pin with a optoisolator.

You would just have something like this:

if (Pinstate == LOW){// If theres no power on your digital pin send power off