@patent willow @frank obsidian Could I get away with mounting a LoRa FeatherWing on the bottom of a Feather stack? So, basically, a TFT ESP32-S2 Feather on top with bottom-facing male headers, LoRa FW on the bottom with top-facing female headers. I mean, it will have an antenna of some sort, so I feel like the answer is yes, but I wanted to verify.
#Mailbox project
1 messages · Page 1 of 1 (latest)
Should be fine.
With an external antenna I'm 99.9% sure it would make no difference... the 0.1% is that radio is weird
This thread is for discussing the in-progress "smart" mailbox project.
@patent willow I'm going to paste your comment from #help-with-projects so it's here.
From Jerry: "I just wanted to let you know that I have added examples that send and receive the data as bytes rather than ascii strings. I find it much easier to parse the data on receipt this way rather than having to pick it out of the ascii string. Of course, you can do it any way you want. I just wanted to provide the examples. Let me know if you have any questions about it. I did not see the need for an ascii message since the arrival of the packet itself serves as the "alarm". I probably should be using struck for this which means I have to learn more about it."
That absolutely works for me. I'm completely new to all of this, so I honestly wouldn't know the difference regarding how the data is sent and received. As long as I can use it for something on the receiving end, I'm good!
I liked your solar option. I have the parts to try that as well.
I got them this morning! The solar panels are smol and cute. I didn't realise what size they'd be, it's not obvious from the images.
Also I think I might be able to cram it all into the smaller project box, but I only ordered one of those, not two.
So I'll see what's what in the larger one first.
I have two of those.
I'm not sure how (or if) the battery monitor will work with the solar charging -- will have to think about that. I have only tried using solar power on a Pi , not on a feather.
I was thinking about the same thing last night. Trying to picture how it wires up and what that means for monitoring, etc.
And it did not work well on the Pi -- too much power consumption .This should be much better.
I got a solar breakout as well, which is supposed to handle everything for me, but I'm not picturing how to wire up the Feather. I'll see how it works tomorrow.
But the solar charger has a "charging/done" signal.
I did see that.
My feather/charger can report battery levels so it is possible. I'd have to look at the adafruit charger again to see how it works compared to mine
Oooh good to know.
Though what it reports is the current power the feather is getting. So at night maybe it is 3.6V but then the sun may be on it and register 3.9V - even if the battery is still only at 3.6 as it charges
are you using this one https://www.adafruit.com/product/4755
That's the one, yes.
I assume it's a JST to JST connector to get the Feather wired to it.
I had used the older one https://www.adafruit.com/product/390 but have the new one to try.
Like with that external battery monitor breakout.
The adafruit site is taunting me that I got the newer one in Nov 2020 to work with and its still in its package 🙂
Haha nice. I use that all the time to remember whether I have something or not.
I got mine in Sept and its still in package!
You both win. I got mine this morning.
I just started an "inventory spreadsheet"
No you win you will use yours first!
We actually started a database that held everything, and you could scan a barcode on the packaging to enter it or find it, and we organised it by labeled containers/drawers etc. That worked for about 10 minutes. 😂
Thing is, you can download your entire order history, which only sort of helps me because I've done a lot of ordering for other folks or presentations or whatnot.
I do that frequently.
At the moment, about 1/3 of my stuff is sort of organised into labeled bins. (Everything I had in Canada.)
Trying to extend that to everything here, but it's going to take a while.
Mine is unlabeled bins 😦
That was my winter project (got 3/4 of it into bins and now some of that scattered out again)
Get a label maker! They're the best.
sort of grouped -- but i can never remember the grouping scheme
I did! that was the best part
Yeah this is why I labeled most of it. I say most because there are some that are "misc" and, like you, I have no idea what the scheme was for the misc bins. They were supposed to sort of be similar things, but... what things? 😄
yup
how large a battery are you putting on this? meaning capacity not physical size
I ordered 2200, 4400, and 6600. Depends on what fits physically. Those are all the round ones. I have a ton of flat ones already, so if one of those will work better, I'll go with that.
Ah cool just noticed the jumper for charge rate on that solar charger. If it was a smaller battery (< 1000mah) would probably have to reduce the charge rate. With those you can solder the other jumper for the 1.5a charge rate
Oooh ok. Yeah like on the other LiPo chargers Adafruit carries.
I don't think I'll go with super tiny on the battery. The weather here is unpredictable, so having enough to last a while without sun might be good.
That's why I got the new charger myself. Thought was to redo my solar part with a larger panel and battery
Oh - will a Pi0W work on the receiving end? I have plenty of Pi 4s too if that's necessary, but since the LoRa thing is a bonnet, I figured I'd go with a smaller package if possible.
Pi 0W will be fine
Ok good.
I have so many of those. 🙄
Might have to design a case for it though so it's not nekkid. Also so the bottom of it doesn't scratch up whatever surface it's on. I have those 2-piece acrylic shells Adafruit made, I could simply use the bottom of one of those and leave the rest exposed. But a nice case would be nicer.
On this , I added a stemmaqt shim
@patent willow Oh! I meant to ask you - can you send me a picture of your LoRa wing? Don't I need to solder wires to it for interrupts or something? The guide is old enough that the newer chips aren't mentioned. So I'm not sure how to wire up the wing.
I wish I had ordered more of those SHIMs. I think I have a couple, but one is in use. I didn't think about leaving them on projects permanently, only temporarily, heh. So I didn't order very many.
you don't need IRQ for Circuitpython
Ah
On some I use header pins and jumpers -- for flexibility
Neat idea. Never thought of that.
But that layout works for all my feathers
Excellent
this one is wired up for LoRaWAN
need IRQ + DI01
This is the one I meant to show you
Fancy!
You can jumper to any setting -- or directly to the stacking header.
Th original BAD layout came from this guide and works very well for most of the feather boards https://learn.adafruit.com/radio-featherwing/wiring#feather-m0-2567192-10
For the JST to JST cable, do I create that? I looked and I have single ended JST cables (i.e. one end bare wire, one end JST), and I have really long JST>JST cables, but nothing short. Can use the single ended ones to make a double, I assume... Now that I think about it, I might have a connector kit for making JST cables. Hmm.
I have this. https://www.adafruit.com/product/4422 But no idea how to make it work.
Ah need a crimping tool which I do not have.
Oh I have that too.
I have used these
But I think I'll try to make my own cable!
splice 2 single ended
Also thought about that.
But my housemate evidently has a crimp tool. So I'm in business.
actually 3064 won't help -- looking at mine
ah I was going into a boost converter with terminals for the Pi
Ah
The short ones I have somewhere came with the LC709203 breakout.
Not sure where they are though.
Oh nice ok
Same one comes with the chip, ok.
Makes sense that it would be in the shop separately as well.
I added an example for the transmit and receive using a packed struct - alarm_rfm9x_ack_pack.py for the transmit and rfm9x_rpi_receive_pack.py for the receive. This uses the struct module to pack 3 bytes and 2 floats into the packet then unpack them on the receive side. I think this is a nice was to go. Much more concise code than manually packing/unpacking as in the "bytes" examples. See https://docs.python.org/3/library/struct.html for info on using struct and https://circuitpython.readthedocs.io/en/latest/shared-bindings/struct/index.html for the CP limitations.
The code is all at https://github.com/jerryneedell/rfm9x_remote_switch
I didn't get to try this out this weekend, which was disappointing. I have what I think is all the parts, but I'm certain I'll figure out I need something else during the build.
Also, I can't find a single Raspberry Pi 0 W. I had.... SO many.... For a while, every time I went to Micro Center, I bought one when they were $5 for the first one. And I went to Micro Center fairly regularly, heh. So in theory there's easily 10+ of these things around here somewhere doing nothing, but I can't find them. Bleh. I only know the location of one with a bunch of extras soldered to it already so the bonnet won't fit, and one that I evidently soldered the headers on the wrong side. Might have to go with a Pi 3 or 4 for the receiving end. Or try to remove the incorrect headers, but I don't relish doing that with a Pi header.
It will be fine with any Pi. I have it running on a zero W now, but it won't make any difference. It more depends on what else you want to do with the information and if the receiving computer will be used for anything else. If it is a Pi4 , at least then, it can be a useful desktop system....
I have been playing with the antenna a bit. It will be interesting to see how the wire or spring does at your distance and in the plastic box. I just switch to the external antenna after painfully soldering the uFL connector https://www.adafruit.com/product/1661 in place and it does improve the signal. I am using the 1/2 wave antenna https://www.adafruit.com/product/3340 on both ends for now. they are out of stock at Adafruit, but Sparkfun has some https://www.sparkfun.com/products/14876 -- just something to keep in mind if range is an issue. I have a hole in my project box to mount the antenna.
It simply needs to receive data. My dad wouldn't know what to do with a Pi otherwise. Heh.
Good to know!
I do not recommend swapping to the external antenna if you don't have to. The uFL connector is a real pain to solder. I ended up using my hot air reflow machine to do it.
The Pi bonnet already has one. but the featherwing does not.
Oof. Yeah I'll avoid that if at all possible.
I have Pi 0 Ws inbound, so I can set up the receiving end on a Zero W instead of a PI 4. Carter saw me asking Limor on Slack about the Zero 2 Ws, and offered to send me a couple of Zero Ws. Hooray!
Just a thought. To get better access to some ground pins you could use a GPIO stacking header PID 2223 . It makes the stack bigger but may make it easier to add your led.
@pine musk meant to tag you with the above. It’s fine with me to resume the discussion here.
@patent willow Oh hmm. Stacking header isn't a bad idea. If my hack fails, I'll look into it.
@patent willow
No idea yet if it works but at least I managed what I wanted!
I think I'll use this one in the prototype and if it works, transfer it to the final. Sounds better than doing that again. 😄
Turns out I bought the wrong adapters for the solar panel to the solar charger. So I won't have that bit until next week. Soldered the Feather ESP32-S2s up, soldered the wires and the uFL antenna connector to the top of the wing, and the LED to the bonnet. Need to solder headers to the wings, and then at least for now, I'm done soldering, I think. Might need to change the jumpers on the solar charger to charge faster, but not sure that's needed. I think I can at least test the basics as soon as I solder the headers onto the Wing. But for now, it's dinner time. 🙂
Great progress! Nice to have that UFL connector done! They are a challenge!
Not going to lie, I had help with those. 😊
Help is good!
@patent willow Good afternoon! Are you around by any chance?
I'm to the point of testing the reed switch, and I am thoroughly confused. Need to test it on the Feather separately from everything else so I can solder it through the Wing. Because I didn't think it through doing it any other way until everything was soldered. It'll work fine, but should be tested on Feather first.
@frank obsidian Maybe you can help with this part, if you're around.
Hey Im around, good timing just sat down at my computer
Nice!
Here is the exact switch I have. Their demos seem backwards to me, but maybe I just don't understand reed switches. https://smile.amazon.com/gp/product/B07YW47395/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&th=1
I want it to have the magnet-next-to-the-switch be the baseline (i.e. the mailbox door is closed).
I'm sure I can compensate in code either way, but the whole point of getting one that wired both ways was so I could not have to do that.
Right off the bat I immediately assumed black was ground which is wrong.
why would they use black as ground - i mean who does that 🙂 besides everyone
Hah ok, I feel less bad 😄
I guess at least they included demo images? Seems like that's pretty rare as well.
"HERE IS A SWITCH. GOOD LUCK."
OK, so here's what I want to do. Use pin 12 or 13 on the Feather, and I assume one of the lines goes to ground anyway.
oh so they give you two wires for open or close
Yeah
It was the only way to guarantee getting the right one, because so many of them claim to be one but turn out to be the other.
So I went for both.
Would it be white to GND, and brown to pin 12, and black not connected?
wait
no
Yeah sounds right to me. You could use black or brown but should only need one of them
I want it to send signal when the door is opened, and the magnet is separated from it
Which is why I feel like their demos are backwards, but if I follow the description and not the name they give it, I should use black.
I guess easy enough to try
and find out
But!
Yeah reading it is confusing me even
I need help here too. Not sure what I'm doing to test this code-wise
Is it simply a digital pin?
Yeah consider it a button
it is the same thing just with a magnetic instead of your finger "pressing" it
Ok, let me try this.
I think you want the NC (so brown) line but the way they worded it is confusing
Does it need a pull, and if so, what kind?
I'm trying black first because that's what's connected, heh
I'd assume pull up yeah cause need something to grain to the white in ground
OK thanks
The other way would be to hook the white to 3.3V and the brown/black to ground but then you'd want a resistor in there (like 10K). So same result - more trouble
You are correct.
LED is on when magnet is not near switch.
Turns off when magnet gets to switch.
👏🏻
yay!
Whee! Ok. Step 1 for that done. I guess I need to solder it to the wing. Mmmmmm wait. No I can't do that yet. Because it'll have to be fed out of the case through a hole, which will be significantly smaller if only feeding the wires.
Wait! That's why I have 2 of these.
So not used to doing projects like this.
I can solder this one up.
I always forget assembly order.
I'm surprised I remembered.
And then have a closed loop I have to put through a box that will not work
And am not slapping past self for screwing over future self by soldering everything up ahead of time.
Hehe yeah
Also, looks promising that the tiny project box will work for this.
Which means not a giant box on my dad's mailbox pole.
It'll be a matter of cable management at this point, but I'm pretty good with puzzles like that.
yeah I've gotten to using more JST type cable assemblies so I can plug/unplug and not have to feed it and solder somehow while the box is open
Speaking of which I need to crimp a JST battery cable 😖
Worst case I'll cut a long one and solder it back together shorter.
I have all the tools and supplies to make battery cables.
i hate crimping
Same.
Hmm actually.... the LC709203 breakout came with a shorty battery cable. I have at least one. If I can locate that, I'll steal it.
Turns out I have 2. And both were organised in bins with their cables. Done!
bonus! I think my new strategy is to order a cable assembly or two with every order. Just a couple bucks so I don't notice
That is a smart person's plan.
the smart part would be making sure they're organized 🙂
Hahaha.... So approximately 1/4 to 1/3 of my stuff is VERY organised.... because I organised it all for moving back here from Ottawa. It was bad enough potentially having to explain having SO much stuff with me, I didn't want to also deal with it being completely disorganised and badly packed if I got searched.
The rest? Disaster still.
And of course the border folks didn't even ask. Heh.
It's ok. Means I have some organised stuff.
that's a bonus. I started but then when I got more stuff it kinda just ended up about
My first ever board (and Intel Edison) and grove kit I won at a conference led to a couple questions but mostly about how much it cost if I owed duty ha
@pine musk sorry, I have grandkids visiting so will be offline until tomorrow! Sound like you have made great progress!
Grandkids are way more important! Have a lovely time! (And thanks, yep, I made quite a bit of progress!)
The code is running on the Feather but seems unhappy to not have something to talk to. I guess it's time to face the next hurdle, and get the RPi set up.
We all just want someone to talk to, even our electronics
Hmm, no, it's that I broke something in the code 😄
I changed the pin number the switch was on, and also changed how it was set up, which I think means I have to change it from if not pin.value to if pin.value which made it seem to go through the whole thing, but it's sending a packet every time the switch changes, not only when the "door is opened".
Maybe it's designed to do that
I have very little grasp on what this code is doing. So it could easily be a situation where it's doing what it's supposed to, and I broke something.
hmmm im not sure if you want to paste some of the code or send it to me go ahead
Oh sure. Um... Here's the original, and let me upload my changes.
Changes are minimal, but probably not minor.
I feel like something is backwards about the switch pin.
Yeah the not pin.value or just pin.value always confuses me but from how i read the code it basically wakes up from deep sleep, reads the pin and if its set sends an message? right?
I thought it was supposed to wake up from deep sleep when the switch was opened, send a message, go back to sleep until the door is opened again.
But maybe I didn't make that clear in the first place, and Jerry wrote it to do something else.
Or maybe it's not possible to only wake up when it is opened, and instead, must wake up whenever there's a change in the pin status.
I don't really get how deepsleep works. So I have no idea.
pin_alarm = alarm.pin.PinAlarm(pin=board.A4, value=False, pull=True)
This is what is setting the alarm so the pin would be the magnetic pin
the value may have to change if you are triggering on True
Oh hmm.
Good call.
Testing.
Except I thought I set it to be "False" when the magnet is close to it. OH! Oh oh oh ok. It's True when the door opens, so that is what the alarm would trigger on.
It never deepsleeps. And I mean it never gets past the "about to deep_sleep" print. (I know it doesn't really deep sleep on USB, but it's not even getting to the fake USB deepsleep.)
And also the code jams up at that point.
Reload in the serial console doesn't work and updating the code doesn't autoreload.
Hard resetting.
the deep sleep may prevent the "about" print from running
Uff, still not doing anything.
No, the print is running
Nothing happens after the print.
that's weird
lol
Hmm. Going to see if Dan's around and willing to tag in. I don't want to tag him into the thread without asking first. Obviously.
what board are you using for this? I forgot what you planned to use
Feather ESP32-S2. Decided it was worth it for the battery monitor.
So that data will be sent as well.
"Door open, Battery 80%" or something. I think.
yeah makes sense
I say I think because that was my understanding of the plan, not that I understand what this code is doing 😄
Pinged Dan. Also asked if a lack of a receiving end could be causing these issues. I feel like no, but maybe it's worth eliminating that variable before continuing to troubleshoot the sending end.
so is it supposed to continuously send alarm packets once the door opens (or the swich or whatever changes)
Hmm.. Ideally no.
No idea if that is what is happening though.
I want one packet that I can receive on the Pi, and then do a thing based on it.
All I see is if it fails it will print a message but won't stop. If it threw and exception you'd see that
Or maybe 2 packets, just in case?
so the while not pin.value loop will keep sending packets and sleep 3 seconds between them as long as it is open
@spice gorge Here is the code: #934142159211352144 message (Actually not sure that link will work because it's including the version of Discord I'm using which is not stable. - if it doesn't work, scroll up to 4:37pm, and see a link to Jerry's original code, and the upload of my working changes)
Ah ok. That's ... I can deal with that on the Pi end I guess.
Have it only trigger the resulting events once.
Even with multiple packets coming in.
The only downside is that would waste battery
Hmm yeah that too.
Which would be Bad News if the door gets left or blown open.
That should be simple enough to fix. Have it send three times in case one gets missed, and then stop sending.
Yup! just thinking you could make two main loops and use alarm memory to remember if the door is open/closed. If it opens sleep till its closed, if its closed sleep till its open
I have literally no clue how to do that. 😄
I get the idea...
But the execution is a blank in my brain.
this is on an S2 board, right?
@spice gorge Right now, the output is this when the switch is closed: ```code.py output:
no wake up alarm
count: 0
packet sent - rfm9x sleeping
about to deep_sleep
Yes ESP32-S2
Feather.
I don't have time now but remind me later I can probably mock something up as to what I'm thinking of
Will do for sure!
if it is plugged into USB it will only fake deep sleep, but if it never comes back that is still a problem. Try a TimeAlarm of 10 seconds or whatever, and see if it comes back.
It sends a message saying it's fake sleeping. This isn't even getting to that message.
It says ```Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
Pretending to deep sleep until alarm, CTRL-C or file write.``` When it fake sleeps.
Not getting there at the moment.
so replace the PinAlarm with a TimeAlarm to see if PinAlarm is broken somehow
Ok
or just write a program that does nothing but a PinAlarm sleep and report on wakeup - remove the LoRa stuff
Ok, I'll try that if this doesn't do anything.
@spice gorge TimeAlarm is working.
with the LoRa code.
I'll distill it down to PinAlarm and see what happens.
there were some changes about the quiescent state of pins relatively recently, but I forget exactly when.
import board
import digitalio
led = digitalio.DigitalInOut(board.LED)
led.switch_to_output()
led.value = True
pin_alarm = alarm.pin.PinAlarm(pin=board.D12, value=True, pull=True)
print("about to deep_sleep")
# exit and set the alarm
alarm.exit_and_deep_sleep_until_alarms(pin_alarm)
try 7.1.x; change was in 7.2.0 before release
also we thought we fixed some issue with PinAlarm: https://github.com/adafruit/circuitpython/pull/6144
that was pretty recently
Trying earlier CP version.
ok, I gotta go
Thanks for your help!
@spice gorge Same results on 7.1.1. Going to leave this be for now. Thanks again for your help.
Time to facilitate dinner here.
@pine musk this is what I was talking about earlier. In this case change the type of alarm that is set. So if it opened wait for close and vice versa. In this case I only send the message in the one state but you could send both if you wanted to.
if pin.value is True:
# Mailbox was triggered, send a packet and sleep until it is closed
packet = struct.pack('<BBBff',alarm.sleep_memory[0],alarm.sleep_memory[1],alarm.sleep_memory[2],sensor.cell_voltage,sensor.cell_percent)
if not rfm9x.send_with_ack(bytes(packet)):
alarm.sleep_memory[2] += 1
print("No Ack")
alarm.sleep_memory[1] += 1
#create an alarm on Pin IO5
pin.deinit() #free the alarm pin
pin_alarm = alarm.pin.PinAlarm(pin=board.A4, value=False, pull=True)
else:
# Mailbox was closed, set an alarm to sleep until it is opened
pin.deinit() #free the alarm pin
pin_alarm = alarm.pin.PinAlarm(pin=board.A4, value=True, pull=True)
Kattni. My demo wakes up when the switch is opened (on when the button is pressed) and sends a message. It then waits for 3 seconds and checks the switch status again. It will keep sensing messages every 3 seconds as long as the button is pressed - switch is open. I have been using a pushbutton for testing, but i'll hook up a reed switch to make sure it works as well. If there is nothing to listen to, the send with time out and fail with a "no Ack" message. It should keep trying.
My code also works with the reed switch (I have a switch that does both Normally Open and Normally Closed - I had to try both options to get the correct one connected - They are not labelled on my switch so it was trial an error).
Ah --i I had some problem initially when I connected it to USB but t is now working OK after a hard RESET. it wakes when I remove the magnet and sleeps when I put the magnet back. I guess, it got confused when I initially connected the USB while it was running off the battery and was not "simulating" sleep until I RESET it. It was working OK, but kept disconnecting from USB when it went to sleep .. all OK now.
BTW - I am running 7.3.0
If the RPi is not running, then it just keeps reporting "No Ack" as long as the switch is open. When I close the switch , it does erroneously indicate that the packet was sent before going to sleep. It wakes up and retries when it is opened again.
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
awake <PinAlarm>
count: 2
No Ack
No Ack
No Ack
No Ack
packet sent - rfm9x sleeping
about to deep_sleep
Code done running.
Press any key to enter the REPL. Use CTRL-D to reload.
Pretending to deep sleep until alarm, CTRL-C or file write.
Woken up by alarm.
Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
awake <PinAlarm>
count: 3
I still haven't sorted out the Feather end of things, but I finally have a Pi up and running. Need to get the code going.
@spice gorge So, when the LoRa code isn't modified to match my reed switch mode, it goes into fakedeepsleep successfully, and wakes up when I change the switch state. But the code's not doing what it's supposed to in terms of the hardware at that point (my switch is NC, and I think Jerry's is NO or the opposite, but either way I think they're different). So I modify it to do what I think it's supposed to be, and it immediately hangs. I finally realised, the "hanging" that it's doing is perhaps partially entering deep sleep but never quite getting to the point where the alarm is valid, because neither a reset or a unplug/replug fixes it, and changing the switch state doesn't make the code continue. However, then it gets weirder. I have the Pi receiver set up, and even when it's in that limbo state, it's sometimes sending packets to the Pi when I open or close the switch. I'm really confused. I guess I could try wiring up a new switch to it in the opposite state and see if it happens then. Either way, I'm done for the night, I simply wanted to let you know where I was at with it.
sure, thanks. The PinAlarms maybe active low only or active high only, so you'll want to make sure that you can wake up on the right transition. So I would follow Jerry's lead on this. I can take a look at what is possible tomw
@pine musk I think you have a similar switch to mine. It has 3 wires -- ground, NO,NC. I have found it too confusing to predict what the manufacturer calls NO, NC so I just try both. My demo code will work either way, but only one will be the sense you want. That is, it triggers when the magnet pulls away (door open) and goes back to sleep if the magnet is near the sensor (door closed). Is that what you are seeing with my original code? I don't think I've seen your modified code posted. Please post it and I will see how it works with my setup.
This makes SO much sense. I bet you're right.
@patent willow I think it's what Dan surmised - PinAlarm might only work active low.
Because when I update that to accommodate my switch everything breaks.
I'm going to wire up another switch with the other wire, and see if it works with your code as-is.
Here's my updated code anyway in case you want to look at it. I still think my best bet is to wire up the switch opposite and use your code without my changes.
@spice gorge So I tried the code way of doing it, and none of your suggested changes are making it work. But the code appears to be working if I treat the reed switch backwards. So it seems to me if I grab another switch, and wire it up the opposite way, it should work.
okee doke!
My blue LED on the bonnet works!
I wonder if there is an issue with the pin_alarm combination value=True, pull=True - According to the documentation, this "should" create a "Pull-Down" but I have not yet been able to decipher the code to see if/how that is done. My example uses value=False, pull=True and seems to behave as expected. I'll try to experiment with this today.
FYI -- I have verified that what works for me is a switch that is "normally closed" when no magnet is present (that is door open). When the magnet is near the sensor the switch opens. The switch Adafruit stocks is "normally open" so it won't work for this configuration. (the code works but the trigger occurs when the door is closed - that is, magnet present In the past, I attempted to reconfigure the pin alarm as you didi but was not successful. I ended up getting a switch that was normally closed. Like the ones you are using- it has both options available. One thing I ran into with another switch that had nice NC/NO labels on it was that the manufacturer considered the "normal" state to be with the magnet attached! This essentially revered the meaning of NC/NO in my mind!! One I figured that out, it made a lot more sense. So for now, I suggest sticking with value=False, pull=True and using a Normally Closed (Closed with no magnet) switch.
Some new information. I tried all four combinations of value and pull.
With value=True, pull = True -- it does not work at all - no triggers
With value=True, pull = False I get continous triggers
With value=False the setting of pull does not seem to actually matter. it appears to work as expected with pull=True and pull=False ...False makes more sense to me so I'll stick with it. All of these tests were with my "normally closed" switch. So the demo code I have in my repository continues to be to be the configuration I recommend. I do not understand the implementation of the "pull" argument.
Note that there is an error in my repository -- the example use import alarm.pin which must have been deprecated. - not sure when. I will update them.
I noticed, I figured it out quickly and deleted it. Thanks for the heads up though.
If it's closed with no magnet, how does that work in situ? Won't the magnet be present when the mailbox door is closed? So do I understand right that if the magnet is present, it will think it's open? I'm still confused about this. Wait........ My simulation here is the opposite wiring we need, I haven't wired up the new switch yet. Nevermind! If I wire up the switch in the opposite way, and the code continues to work, then it'll send a packet when the magnet is pulled away.
Ok, nevermind all that until I wire up a new switch.
Then if it's still not working right, I will be confused again.
I was trying to modify the code to do the rest of the shenanigans that I wanted it to, and struggled...... I think there's going to be more modification than I think. I might need some help understanding what is going on in the code to begin with, at some point. (Have to get back to work now, though 😄 )
when the door is closed, the magnet is in contact with the sensor -- the switch will be "open" so the pull-up will hold the signal high. When you open the door the magnet goes away and the switch closes so the signal goes to ground triggering the event.
Ok that makes sense for now. I'll wire up the new switch the opposite way and see if it behaves how I think it should based on that.
that is why value=False trigger on ground
Right, ok
Good luck!
Thanks!
@pine musk let me know if there is some part of the demo code that you would like me to explain, I should do a better job of annotation...
I'll send you my current working version before asking for more explanation. I added a couple of things and tweaked a couple of prints... Better to be looking at what I'm looking at. Thank you for offering!
Sounds good! Glad to help.
@patent willow Hey! So my partner went to town on the Pi code, and it's nearly where I want it. Displays "MAIL!" on the little OLED, blue LED blinks, continues until you reset it, then waits for the next door open packet. I'll tell my dad to reset it after he picks up the mail so it doesn't notify him twice. She still needs to make it send him an email, but we have today and tomorrow for that. I wired up a new reed switch to the Wing in the opposite way, and it's working as intended now. At this point, while she's hacking away on it, I'm working on actually building it into the project box. Need a bigger drill but for one thing, so that's being obtained. Testing on the bigger project box because I only have one little project box, and I'm a little worried that it won't withstand the same drilling (the bigger ones are thicker-walled). Fingers crossed, and I ordered another one today in case I do destroy it. Guessing at wire length for the reed switch, I don't want to ask my dad for measurements because it would give away what I'm doing. Might take my soldering iron and hot air station with me when I head up there to put it up so I can adjust the wire length on the fly so there's not a bunch of extra. Or in case I need more! Anyway......... oof, wall of text, but that's my update!
The solar panel adapters I ordered, one kind works and the other one doesn't. Product copy says it should... I think I can make it work with the one that does fit, so I think I'm still ok to proceed? But oof. It was, for a minute there, a pretty big setback. I'm planning to email about whether I'm missing something or if the product that was shipped to Adafruit is actually the product they think it is. Says you have to apply more force than you expect to make it click in, but I tried pretty hard and couldn't get it into the adapter. So... no idea.
I have some of those and I do recall that did require some "force". I've also seen others complain in the forums that they have not been able to get them to work.
I got an L version, and a cable version. L version works, cable does not. I think I can make the L version work though.
Got two of each, neither of the cable ones work for me.
I'll have to review what I have. May take some digging....
Ordered entirely the wrong thing to begin with. Thought I had it right the second time 😄
When you have it done, I'd love to see the code. No rush.
For sure! I'll create a repo for it and post it once we have it working. The email thing is going to have the actual mailing bit handled by my partner's personal mail set up. Gmail used to work for stuff like this, but now it's super complicated. So, that part might not be good for everyone since you have to figure out how to handle outgoing mail. But, the rest of it will work for anyone 🙂
do you have a link to the "L" version -- I have the cable version and they work -- I may not have the L
Ah -- I do have them -- I'll see if I can find one and try it.
Let me get a picture of my cable from the solar panel end of it. The issue is the pin is too big, not the whole connector being wrong.
the nem "gmail" is a pain. I also tried using "Twilio" to send SMS messages -- Very easy to set up -- Does cost $1/month and $.01/message
That was the other thing my partner suggested! That's not bad, I expected it to be more.
which panel are you using?
I guess if my dad wants to do that, he could set up the account and we could update the code.
In the end, I'm using https://www.adafruit.com/product/5367 but I also have https://www.adafruit.com/product/200
These panels come to us from Voltaic Systems, makers of fine solar-powered bags and packs. These are waterproof, scratch-resistant, and UV resistant, and they use 10 high efficiency ...
Personally I'd rather get a text message. But I didn't want to pay for it forever for this project.
oops -- I have to go offline for awhile -- I'll dig out the panel and connecter later and give it a try. I do have the same panels.
No worries! Thanks for replying!
Hmm, my cable connectors work ok but the pin does appear to be smaller.
@patent willow !!
That looks amazing!! Congratulations!
Thank you! We're still working on the receiver code a bit, but they are talking to each other successfully across the distance with various barriers in the line of sight.
My dad entirely redid the mailbox mount on top of the pole to hold the solar panel.
Then we sorted out the rest around that.
Great! I’m glad it is communicating
Jerry - thank you so much for your help with getting going on this. I had no idea where to start, only an idea of what I wanted it to do. I've been hug reporting you in the meeting for the last few weeks. I wanted to tell you personally though. My dad was entirely blown away. I'll hand it to him knowing what it was when he saw it. But he is super excited about it, said it looks amazing, is really looking forward to us getting it solidified.
@pine musk I’m glad I was able to be of some help. It was entirely a pleasure. I’m so glad it worked out and your dad is excited about it. Great job!
Hey just saw this, it looks amazing!
@frank obsidian Thank you! Was a lot of work and a huge scramble to get there, and we still have to fix the Pi, but they are able to talk to each other, so that concern is at least alleviated.