-
• #2
Which wires do you have connected? Just:
- 3.3v -> B3
- B6 -> B7
- B7 -> B6
Do you have ground connected between the two Picos as well?
If you don't, it's possible that could be causing your problems I guess?
- 3.3v -> B3
-
• #3
Which wires do you have connected? Just:
3.3v -> B3
B6 -> B7
B7 -> B6Yes - that's all.
Do you have ground connected between the two Picos as well?
Ah - I don't, no. I'll give it a try - thanks!
Edit: That seems to have fixed it - many thanks! Not knowing much about electronics that was seriously confusing the hell out of me - clearly I need to read up a lot more to get my head around more of these basic concepts. Thanks again!
-
• #4
No problem! It's pretty common as people tend to forget to mention it, and even circuit diagrams often leave out a connecting wire for it because they assume GND is always connected together :)
On most things you need GND connected. A voltage isn't really absolute - you (and the microcontrollers) need to measure it relative to something else. It's like me showing you where the top of my head is and asking you to measure my height - it's impossible unless you can also measure from where my feet are.
Complete electronics/embedded newbie here, so apologies if I'm just missing something really obvious...
I'm trying to set up a system where when I connect two Picos, one realises the connection has occurred and sends some data to the other over Serial1.
The simple way to achieve this I've found is to have both Picos connected via a Serial1 connection (9600/tx:B6/rx:B7), and then connect the 3.3v pin of Pico A to pin B3 of Pico B, and just use setWatch() on Pico B to detect pin B3 being pulled high when they connect.
This seems to work fine - every time I connect B's B3 to A's 3.3v the watcher triggers exactly once.
The problem occurs when I try to print text over Serial1 as a result - suddenly Pico B's setWatch() is continually being triggered, as fast as the debounce setting will permit it.
If I put a counter in and (for example) only output to Serial1
if(counter < 5)
, I get the expected number of outputs and no more, so obviously outputting to Serial1 isn't simply triggering thesetWatch()
event handler endlessly - it's doing it exactly once per write to Serial1... and then the event handler writes to Serial1, re-triggering thesetWatch()
event handler... etc, etc, etc.There's no obvious connection I can see between B3 and Serial1 on B6/B7 - can anyone explain what on earth I'm missing?
Example code follows - B6/B7 each lead to the other pin on another Pico, and I trigger the behaviour by connecting that other Pico's 3.3v pin to B3 on this Pico:
TL;DR: Basically it seems as if sending data over Serial1 resets the setWatch() on pin B3, leading to it triggering the event handler even if B3 was already high before the Serial write occurred. Why would writing to Serial1 re-trigger a watch on pin B3?
P.S. Apologies for the bad title - I only realised after posting that Serial1 was triggering the watch on B3 exactly once per write (and the event handler was then re-sending to Serial1 leading to an infinite loop), and not continually.