I’ve had my electronics engineer colleague have a look at the simple setup, saying: “That’s an easy fix, just try this.” he then tried several things like i already did, and after an hour he gave up, saying that it defies all logic.
I showed him the setups that worked with me closing the magnet, and it wakes up (FALLING). He then told me to just set it to RISING edge instead so it works with removing the magnet instead of closing the magnet. Of course, like I’ve already tried, the device didn’t wake up at all (closing or removing magnet).
That’s when he left.
So yeah…
I measure with a multimeter, direct 3v3 to one and ground to other.
Is there really no one else having trouble with this or is it just me?
If someone could just show me how they got a magnet contact switch to work with their device, this could be closed.
I mean odds of me being the only person in the community trying to use a switch like this as a sleep wake, is very slim. And this is a very beginner like issue (should be atleast)
Btw I bought the capacitors and they are on the way.
Can you first establish the actual behaviour of your reed switch by means of a continuity check with you MM?
While commonly reed switches are NO and close when the magnet is near some switches are different. There are variants that are directional/polarised, some switch between two poles (open one close the other) ...
Especially if you have an opaque one it's not always easy to tell
Be sure you have the switch connected to ground on one leg, the other the input pin.
Trigger on a rising edge. Put a 4.7-40k resistor pull up from the input pin to 3.3v.
Verify when you remove the magnet the voltage jumps to 3.3v across the switch.
If it does not trigger on rising there could be a bug.
Be sure you are on the latest stable firmware. The latest beta was unstable for me.
Look up you’ve got mail on hackster for a similar setup with sleep and a reed switch trigger.
As said earlier, when setting the interrupt for RISING or FALLING the interrupt will not trigger on the opposite edge, but your switch is creating the exact kind of edge you are triggering for in both cases - when applying or removing the magnet - due to contact bounce.
Update: Now you changed the wording of your post the statement makes sense
But it didn’t react to either removing or closing the magnet switch, so I experimented a bit on my own and found this setup to work EXACTLY as intended:
I made some changes to my gotmail code. It seems to be more reliable now.
I wanted it to sleep for long periods if the network could not be found and thingspeak not updated.
If a thingspeak update fails, it waits until 60 seconds and sleeps for double the normal interval of 1 hour.
I implemented the watchdog with a 2 minute timer. FYI I have discovered the watchdog must reset each sleep/wake event.
I never call a checkin and it never seems to reboot.
However, if the particle hangs for some reason, it should automatically reboot after 2 minutes. after the reboot it should attempt a reconnect and update. If the update fails it should sleep after 1 minute for 1 hour.
This way if my home wifi dies, the photon shuts down and reattempts an update an hour later. As always it will wake on interrupt when the door opens if that happens first.
The mailbox is operating on a photon… there is no battery charge controller on the photon. These boards are quite cheap, 10/ for 10$ so not a big deal to add. The electron however has a lipo charge controller onboard.