Enter Your Project for a chance to win a Maker Tool Kit, an Oscilloscope Grand Prize for the project that brings the Most Joy to the Heart, and Gift to Gives! | Project14 Home | |
Monthly Themes | ||
Monthly Theme Poll |
Hooray!
I've made some real progress today, thank goodness!
You might recall the saga of motion sensors constantly sensing motion. That saga continued over the weekend and it was driving me nuts.
I finally decided to swap out to using pushbuttons, but those also still continuously acted like the buttons were being pressed.
I thought I might have burnt out a GPIO pin or something, the way it was behaving. Given that the motion sensors take 5v input, I did end up hooking up the button to 5v (not sure if I pressed one or not!), and then realized YIKES! the button needs to go to 3.3v for the GPIO to handle it.
Then this morning I thought I'd try hooking things up the same way I had it programmed on the Witty Wi-Fi - using the same GPIO as the Witty uses for the button and for the LEDs.
That then led me to wonder about the Wemos documentation that mentions pull-ups and pull-downs. I was thinking that meant the same as on the other Arduinos where you can, in code, specify input_pullup and pulldown.
HOWEVER, after looking at the schematics I see that's not the case for the Wemos! On the Wemos they are actual physical external resistors, not programmable.
So, note to self for later, and anyone else who might be interested:
GPIO0 (D3) and GPIO2 (D4, also built-in LED) are both connected with 10k resistors to 3.3v
GPIO15 (D8) has a 10k resistor to GND.
I suppose I could have used D8 for the button/sensor input and saved a bit of soldering. Actually no, because the Tree requires 5v.
So, I reprogrammed the trees to use the new pin assignments, swapped around the wires, and then hooked up pushbuttons for the time being to test it out.
And it works!
So at this point, I have both trees working nicely with pushbuttons. I can press the button on tree 1 to light the tree-top on 1, and send a message to tree 2 to light up that tree; and vice-versa.
Kinda cool how that works.
In this video I'm using the MQTT Websocket Client provided by HiveMQ to inspect the traffic that's being sent between my trees, which are both being powered by USB power adapters (one tablet charger, the other using an official Raspberry Pi power adapter). There are no wires between them, and all the MQTT traffic goes via the Internet to the HiveMQ broker, and back to my trees.
Next I'll try the motion sensors again to see if in all the confusion maybe I just misinterpreted what was going on. Fingers crossed!
ps, (edit),
The other thing I ran into on the weekend was that the Wemos boards were becoming unresponsive when I turned them on. sigh. Upon investigating that issue I noticed that my WiFi network was just not accepting them anymore. Resetting the network cleared that up.
But that also inspired me to add some startup code to flash LEDs to show progress. It flashes the blue LED a couple of times at startup, then flashes once with every WiFi network connection retry. Then when the tree is ready, it flashes all the LEDs on the main tree once as a signal.
When starting up, the trees also send a "Hello world" message to the other tree, so whichever tree starts up first will see the other tree coming online and will flash to acknowledge it.
Edit again:
I tested with a motion sensor on one tree and ran into the same repeated-triggering problem as in my previous post.
Still suspecting it might be power related, I hooked up an external power source (battery pack USB charger) to only power the motion sensor. I connected grounds together.
That works reliably now!
So to me that means if I want to use the motion sensors for the final build, that I'll have to figure out a better way to power them. Maybe intercept the input power, or bypass some bits on the sensors themselves. For this project I feel I've learned plenty already, and I'm running out of time. So I will stick with the easier push-buttons and wrap them up into a (hopefully) neat little package. Plus I've come to feel that the buttons give a more Christmassy "thinking of you" moment, rather than just random people (or cats) walking by.
Here's a picture of that test with external power:
(yes, that button is still half connected, to 3.3v - I'm not making THAT mistake again! )
-Nico
Previous posts:
Connecting the Tree to the Internet
Trees! one with motion sickness...
Motion Sensor Issues, continued
Next post:
Top Comments