I just got my first two Particle Photons. I have already created a little device that sits on the back of my mailbox and can tell me if the box is closed (photo resistor reads 0) or if the door is open (photo resistor reading is > 1)
I was just thinking about doing this myself after checking to see if the mail had been delivered today about 5 times
If you want to do it the easy way then checkout www.Ubidots.com since they make it really easy to setup triggers to send emails or SMS text messages. There are some examples on their site and on this site for how to setup the code.
Yeah, I agree with @kennethlimcp, I’d probably do this with a webhook, rather than trying to do SMTP directly from the Photon. I mean, SMTP is pretty simple (if you don’t need TLS or anything), but it’s still more work than is necessary. If I were personally doing this, I’d most likely have the webhook call an AWS Lambda function via the Amazon API Gateway, and have the Lambda function send the mail via my service of choice. But if you already have a webserver running somewhere, you could run it there too (I just like the Lambda solution because it’s totally independent of any of my servers).
Hi @axexgabe,
if the email is not a hard requirement, you could use Pushbullet to send you push notifications to your devices (phone, tablet, browser).
I wrote an article on how to achieve that here:
It works!! Thank you @RWB. Now, does anyone have any suggestions on how to make the device go to low-power mode at night and wake up in the morning, or at least turn off the WiFi at night? The device uses up the battery at night and when it comes back up in the morning it does not automatically connect to the WiFi network.
@axexgabe You can use the Real Time Clock feature to set the Sleep and Wake up times.
Or I would just use the light sensor on the WKP pin set so a rising edge input will wake up the Photon from sleep and then run your code to send you notification and then go back to sleep until the Light sensor get’s hit with light again when the mail box is opened.
It now runs once, then it goes to sleep but no input from the photo resistor on A0. Even a direct flash light on the photo resistor will not wake the system. Here are couple of pics from the device.
I can’t quite tell if the photo matches the schematic, but the schematic is definitely wrong. You show A0 connected to ground when it should be connected to the junction of the resistor and the photoresistor.
I’d drawn the schematic wrong. Now the schematic matches the actual configuration. Is my resistor’s value 47 ohm @ 1% to high? I would get a value of 0 when the mailbox was closed and a value 2 - 5 when the door was opened.
I’d rather think 47Ohm might be a bit low (quite a bit).
Have you measured the resistace of your photo resistor dark and lit?
Do the voltage division.
Your pull-down should be at least twice the resistance of your photo resistor when lit (not full brightness but your expected illumination when installed) to get a voltage up to at least 2/3 Vcc.
This proves my point
You actually now have an “infinite” resistor to GND in series with the photo resistor.
But this only works due to the finite internal resistance of A0 to GND. Without it there would be no current flowing through the photo resistor resulting in zero voltage drop across it causing 3.3V on either side of it and A0 being stuck on HIGH.
The thing not obvious is, that System.sleep(pin, RISING) does in fact attach a pull-up resistor which is 40 ~ 50k and hence it does work for waking the device.
I guess I wasn’t clear with the resistance values. I thought the lower the number the lower the resistance. So it is the oposite then? The higher the number the lower the resistance?
Nope, the lower the number the lower the resistance, but the lowest resistance (0.0Ω) is a direct wire and no wire at all is “infinite” resistance (∞Ω).
The reciprocal value of resistance (unit Ohm) is conductance (unit Siemens), so 1/0.0Ω = ∞S (infinite conductance = ideal conductor) and 1/∞Ω = 0.0S no conductance what so ever (ideal insulator - like in your sample towards GND).