Mailbox notification

@beardedinventor to the rescue!

Do you have the pushover stuff working? I’m not familiar with it. I do use Twilio for SMS messages, and can recommend that as an alternative. I was able to use a 100K resistor and one of the phototransistors that is recommended for the blink-up circuit to wake an Imp. You’ll need to tweak that for the minimum amount of light that can get into your mailbox on a cloudy day though.

Ok, thanks.

i found this on the forum:

`USER_KEY <- “put your user key here”;
APP_TOKEN <- “put your application api token here”;
POST_URL <- “https://api.pushover.net/1/messages.json”;
function pushOver(title, msg) {

local post = http.urlencode({
    token=APP_TOKEN,
    user=USER_KEY,
    title=title,
    message=msg
});

local headers = {
    "Content-Type": "application/x-www-form-urlencoded"
};
    
local response = http.post(POST_URL, headers, post).sendsync();
  
server.log(response.statuscode + ": " + response.body);

}`

I wrapped your code in a < code > block @JerryW - makes it a bit easier on the eyes (and keeps formatting)

@beardedinventor thanks!

Ok, I must be doing something wrong. Using the sample code above, I cannot get the imp to go to sleep and act correctly. So, what do I mean act correctly? Well, I have a mini photocell and I have put the pin1 wire to one pole of the cell then a 10k ohm resistor, then on the 3.3v. The other pole is going to gnd. I am getting 0 when the photocell is exposed to light and a 1 when I cover the cell. Seems backwards. The imp will sleep when exposed to light but will not sleep and remains active if the cell is covered. I have tried putting pin1 on the same side of the resistor as the 3.3v and I get no reading other than 0. I have tried putting the 10k ohm resistor on the side of gnd and I get nothing other than 0. I am nowhere near proficient in electronics but I thought I had this small project.

Assistance would be great and thank you ahead of time!!

If I’m understanding your wiring correctly, what your describing (for pin 1 voltage) sounds like correct behavior … which is indeed backward (from what you’re trying to achieve).

The photocell has high resistance when dark, and low resistance when light … so your voltage divider circuit is behaving as designed. You may want to switch the photocell to be hooked between +3.3v and pin 1, then your 10k between pin 1 and ground. This should give you the voltage inversion you are looking for.

@LarryJ, thanks for responding. I connected 3.3v to one pole on the photocell and pin1 to the other pole of the cell. I then connected the 10k between pin1 and gnd. I get the same result. 0 when not covered and 1 when covered. I am assuming that I followed what you said or meant!?

Hmmm, strange that you would get the same result no matter which leg of the voltage divider contained the photocell. I’ll look into the specs of the part further and see if I can make sense of what’s happening … seems unexpected. Do you have a way of measuring the light and dark resistance of the part (with an ohmmeter?)

(It looks like a fun project, so I actually put a couple of photocells on order from Digikey to play around with. Hopefully they’ll arrive by tomorrow and I can check them out this weekend).

Edit: Also, to be specific, are you measuring the actual voltage at pin 1 during light and dark conditions? Or just what the imp interprets the signal to be … i.e. ‘0’ or ‘1’ ? I’d be interested in knowing the actual voltage levels you see at pin 1.

Thanks! Yeah, I can put a meter on it and will do so now. I cannot seem to get it to work on the imp though. Will let you know my results.

Update: I just put a meter on the photocell and I am getting readings from the cell. Higher the more distance I put between my light source and the cell and lower as I get near it.

One idea for a solar powered unit is to use the solar powered landscaping units - available at places like Lowes. There are versions with with LiFePo4 ~max 3.6V batteries, easly replaceable/removable.
Need to do some slight re-wiring to always provide battery power to the power connector.

@LarryJ curious if you were able to test your photocells?

If I’m not mistaken, the new firmware upgrade allows you to use the photocell on the imp itself (“blinkup” LED). When I get another imp for my next project, I’m going to experiment with that. You may not even need the external photocell after all.

@mlseim would this work if the imp is asleep?

@JerryW - it would not. Pin1 and timers are the only things that can be used to wake the imp from sleep.

@beardedinventor That is what I thought. So, Maybe you can help. If you read further up the discussion, you will see that I am having trouble with the way the photocell is acting. I am getting a 1 when dark and a 0 when getting light. The imp will sleep when lit, and go on and offline when dark. I was utilizing the code you gave me as well. Now, all of this happens no matter the configuration I have tried with the 10k resistor. Suggestions?

@JerryW - Do you have a part # / datasheet / link to the product for the photocell?

@beardedinventor - https://www.sparkfun.com/products/9088