Pico W not working, even though it was

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Pico W not working, even though it was

Post by Rissy » Sat Aug 27, 2022 2:23 pm

So after a whole week of flawlessness from my Pico W connected to my SHT30 in the lounge with a USB mains power supply, today was the day to move it outside.

I've got some very expensive Belden 485 shielded cable from work, and i've got this going from the back of my lounge, to outside through a specially prepared hole. This goes into a junction box specially mounted on to the outside wall of my house, and then using WAGO terminal blocks, the Belden 485 cable has its four cores connected appropriately to the SHT30 cores, and at the other end on the Pico W end, the Belden cable cores are connected appropriately into the Pico W.

Everything works as expected..... As long as I power the Pico W from my laptop USB port.

As soon as I transfer the USB cable to any of an assortment of USB main adapters, including the one its been soak testing with for the past week flawlessly, then the Pico W fails in its programming. I know this because I'm familiar with the LED flashing I have the program doing to indicate each stage.

boot.py
Successful connection to the Wi-Fi
then reading from the sensor over and over every 10 secs.

I thought maybe the Belden cable was being subjected to noise of some sort, so I even tried connecting the shielding of the cable to a GND on the Pico. Even connected to the Laptop where I can see what its doing, it fails, complaining of a BUS error. Remove the shielding connection to GND again, and it's quite happy once more. But only as long as the USB cable is connected to my laptop, which at the time was running only from its battery. It wasn't even connected to the Mains.

All of this is still using the same USB cable and running the same program.

The only thing I can think of, is that my laptop is somehow providing a connection of some description that the mains adaptor isn't, and as long as the SHT30 is only connected with its 1m long tail of cable, it still works with the mains adaptor.

As soon as I connect my Belden cable into play, it refuses to work with the mains adaptor only. Why?!

Mt Belden cable is only about 5m long. In my opinion, this should all be fine!?

Has anyone else every found this, and if so, how did you fix it?

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W not working, even though it was

Post by Rissy » Sat Aug 27, 2022 3:15 pm

Fixed it!

I forced the I2C serial link to operate at 50,000Hz instead of whatever it defaults to without putting "freq=####".

Now it works irrespective of what is powering the Pico W. Thank God! (I spent far too many hours of my day on this today!)

Can someone tell me the default frequency?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pico W not working, even though it was

Post by Roberthh » Sat Aug 27, 2022 3:57 pm

The default frequency is 400000. I2C is designed for short wires, like 30cm. If you use longer wires, you have either to lower the frequency, which you did, or use pull -up resistors with a smaller value, e.g
470 ohm instead of 4700 ohm. There are special transceiver chips which you could use, but that's additional hardware.

User avatar
scruss
Posts: 360
Joined: Sat Aug 12, 2017 2:27 pm
Location: Toronto, Canada
Contact:

Re: Pico W not working, even though it was

Post by scruss » Sat Aug 27, 2022 4:13 pm

Default frequency is around 400000. The actual frequency is all down to the CPU's clock dividers, and I typically see 399361 as the default.

You can find this out for yourself for your own board by entering the following in the REPL:

Code: Select all

import machine
i=machine.I2C(1)
i
I2C(1, freq=399361, scl=7, sda=6)

Rissy
Posts: 116
Joined: Sun Aug 14, 2022 8:15 am

Re: Pico W not working, even though it was

Post by Rissy » Sat Aug 27, 2022 4:33 pm

Roberthh wrote:
Sat Aug 27, 2022 3:57 pm
The default frequency is 400000. I2C is designed for short wires, like 30cm. If you use longer wires, you have either to lower the frequency, which you did, or use pull -up resistors with a smaller value, e.g
470 ohm instead of 4700 ohm. There are special transceiver chips which you could use, but that's additional hardware.
Strangely enough, the first frequency I tried was 1,000hz. That didn’t work either. Then I tried 10,000hz and that worked. So increased it to 50,000hz just to be certain, and left it at that.

I’m surprised now to read I’ve lowered the frequency compared to standard default. I guess now that 1,000hz was just too slow then?

Post Reply