Mailbox notification

Nice; keeping the quiescent current low is essential for when you’re trying to save energy by staying asleep :slight_smile:

Hi guys any updates on that project?

Cheers.

Yes, I kept it simple and decided to use a micro switch (from an old mouse) instead of a photocell. My notification has been running since Dec 17th on 4 AA batteries. Has ran fine through the cold winter and now in the heat. I have it sending notifications using PushOver and updating to Xively. I do have code to send through other methods if I ever need to; like emails using Mailgun, Notifications through PushAlot, and SMS Messaging through SendHub.

Hey!

That’s a fast answer! do you have any pics of your project?

I think it is a cool thing to do!

Since Dec on the same batteries?

A switch is a good solution to me too.

Pierre.

Pierre, I do not have any pics. Sorry. Never felt the need to but would be happy to help you build one if you want. As for the batteries, yes, the same 4 AA’s. Since I have it reporting voltage to me each time, and the fact that it hasn’t depleted much, I will probably get through the rest of this year and maybe much further.

no worries, I’d be pleased to have some tips. ElectricImp is new for me.
What sheild did you use ?
Do you have a wooden mailbox or metallic?
I am wondering about range issues.

Pierre.

I have the standard April board with sd card. Though, I have looked at some of the new stuff from themakedeck.com. I like not having to have a separate sd card. Was looking at the Aria. I have a metallic mailbox and it is within 100 ft of my wifi router. The signal is pretty strong and I get a response back from the mailbox, when the door is opened, within 1 second. The unit is mounted underneath the mailbox and not inside. I have it in a weatherproof plastic case and the switch is to the inside of the door and mounted using double-sided sticky tape from 3m.

Range is pretty good! Do you sleep all the time and the door is an interrupt or you powerup the entire system each time ?

It deeps sleeps until the door is opened. When opened, the unit powers up, connects to wifi, sends status, and then immediately returns to deep sleep. I have the switch connected to PIN1 to allow imp to wake. The micro switch, with a small lever, is a switch I got out of an old mouse, of course you can buy them anywhere and they are usable in either normally closed or normally opened. There is about a million different switches and methods you could use to do this. I just used what I had and again, kept it simple.

Just to be sure, the imp is always powered by the batteries, the switch interacts only win pin1?

Correct! I have no other power sources. I have connected the red (+) and black (-) wires from my quad AA battery holder to the P+ and P- on the pad.

Ok thx, I was wondering to powerup the entire system each time, but as the batteries seems to last for ever that way :wink:

Well, you are not using hardly any power at all. I have not changed a single battery and I have had no problems with power. I would truly be surprised if the batteries did not last me through the rest of this year. If anything, changing just one or two of the four.

I’ll add a small solar panel I think if there is an issue.
Just need to cannibalyze a tiny solar spot for the garden.

themakerbot.com has a board with a LiPo connector on it. You could put a LiPo battery and recharge it via solar.

I’ll think about it thx!

I’ll go for the april board, any random switch I’ll find at home, some AA batteries and that’s it!

Hey Jerry!

I have my imp now, do you mind sharing your code?

Thx

Hi!

I took, a moment last night and here is result!

It is the first batch :wink:

I used mailgun for the notifications as I have not found a way to send SMS for free in France!

Agent:

function mailgun(subject, message)
{
local from = “Mailbox@home.com”;
local to = “blablabla@blablabla.com
local apikey = “key-blablabla”;
local domain = “blablabla.mailgun.org”;
local request = http.post(“https://api:” + apikey + “@api.mailgun.net/v2/” + domain + “/messages”, {“Content-Type”: “application/x-www-form-urlencoded”}, “from=” + from + “&to=” + to + “&subject=” + subject + “&text=” + message);
local response = request.sendsync();
server.log("Mailgun response: " + response.body);
}

function sendEmail (startTime)
{
mailgun(“Electric Imp”, “Just saying hi! :)”);

}

device.on(“mail”, sendEmail);

Device:

// Alias the GPIO pin as ‘button’
button <- hardware.pin1;
led <- hardware.pin9;
led.configure(DIGITAL_OUT);

// global variable to track current state of LED pin
etat <- 0;
// set LED pin to initial value (0 = off, 1 = on)
led.write(etat);

// function to blink LED
function blink() {
// flip the state variable
if (etat == 0) {
etat = 1;
}
else {
etat = 0;
}

led.write(etat); // set LED pin to new value

}

function buttonPress()
{
local state = button.read();
if (state == 0)
{
// The button is released
server.log(“Release”);
} else
{

     // The button is pressed
      agent.send("mail", hardware.millis());
      local i; 
      for (i=0; i<100; i++)
      {
        led.write(0);         // set LED pin to new value
        imp.sleep(0.05);
        led.write(1);         // set LED pin to new value
        imp.sleep(0.05);
        
}
      imp.deepsleepfor(3600);

      server.log("Press");
}

}

button.configure(DIGITAL_IN_WAKEUP,buttonPress);

here is a little picture of the current development stage:

I have used a 3.7V nokia cellphone battery, it is small and should last a long time.

As Jerry said, keep it simple!

I now have to reduce the wiring, find a nice box and switch.

A bientot!

Sorry I did not get back to you sooner. Busy with family. Looks great though!

No pb Jerry I understand, same thing here :wink: