Piidev could not communicate with module

Hi,
I’ve got a Piicodev base expansion board and a BME280 temperature/humidity/altitude module which has been working just fine. However, a few weeks ago it started coming up with an error “PiicoDev could not communicate with module at address 0x77, check wiring”.

I’ve tried the following, but the problem keeps coming up:

  • reseating the connector cable between the BME280 module and the Piicodev expansion board
  • replacing the same cable with a spare
  • bought a new BME280 module and Piicodev expansion board and connector cables
  • replaced the Pico WH with a new one

I’m at a lost as to what the problem could be. I’ve gone back to using the example python code provided by Core Electronics to read values from the BME280, and it still gives that error. I’ve also tried different versions of Micropython on the Pico, nothing seems to work.

However, occassionally it does just work, but mostly it doesn’t. I’m at a loss as to what else I can try - any ideas?

For reference, the full error is:

PiicoDev could not communicate with module at address 0x77, check wiring
Traceback (most recent call last):
** File "<stdin>", line 135, in **
** File "PiicoDev_BME280.py", line 32, in init**
** File "PiicoDev_BME280.py", line 29, in init**
** File "PiicoDev_BME280.py", line 64, in _read16**
OSError: [Errno 5] EIO

Thanks,
Dean

2 Likes

Hi Dean,

This means that MicroPython failed a communication over I2C, could you share your code surrounded by three backticks (```)? I’d like to take a look at it to check whether something is misconfigured there. Glad to hear you’ve ruled out hardware problems short of power supply, how are you powering your setup?

Keen to get to the bottom of this one!

Hi James, I’ve reverted to using the example code that you guys have provided, which is below. I’m powering the whole thing from the USB port on my PC (tower server) - the power supply to the Pico + Piicodev + BME280 is one thing that I haven’t tested. At the moment my actual program is assuming that there’s a console connected (like Thonny) to display output to, the next step will be to send the data over the WiFi to a server that I’ve written in Python, but I haven’t quite got that far yet. So I need a USB port on the PC so that I can use Thonny to see the output.

Code is as follows:

import machine
from PiicoDev_BME280 import PiicoDev_BME280
from PiicoDev_Unified import sleep_ms # cross-platform compatible sleep function

led = machine.Pin("LED", machine.Pin.OUT)
sensor = PiicoDev_BME280() # initialise the sensor
zeroAlt = sensor.altitude() # take an initial altitude reading

while True:
    # Print data
    tempC, presPa, humRH = sensor.values() # read all data from the sensor
    pres_hPa = presPa / 100 # convert air pressurr Pascals -> hPa (or mbar, if you prefer)
    print(str(tempC)+" °C  " + str(pres_hPa)+" hPa  " + str(humRH)+" %RH")
    
    # Altitude demo
    # print(sensor.altitude() - zeroAlt) # Print the pressure CHANGE since the script began
    sleep_ms(5000)
    led.toggle()

Hi Dean,

Apologies for the many replies, I forgot to ask - could you send a photo of how you’ve got everything connected? We may spot something.

EDIT: Checked your code with some gear from the shelf, it worked fine, so looks like it may be in the physical domain

Sure - see attached pics. I’ve tried both connector sockets on the BME280 but doesn’t seem to make a difference. I’m currently using the 100mm connector cable, but I’ve tried the 50mm cable that I originally bought too. Again, doesn’t seem to make any difference. The micro USB cable is the one I ordered from you guys originally.


1 Like

Hi Dean,

Thanks for sending those photos through!

It looks like the PiicoDev connectors might be a little loose, I’d give re-seating the connectors a go.

Also making sure that you have the latest libraries for the Atmospheric module: PiicoDev Atmospheric Sensor BME280 - Raspberry Pi Pico Guide - Tutorial Australia

And adding a delay so that your code looks like this:

import machine
from PiicoDev_BME280 import PiicoDev_BME280
from PiicoDev_Unified import sleep_ms # cross-platform compatible sleep function

led = machine.Pin("LED", machine.Pin.OUT)
sensor = PiicoDev_BME280() # initialise the sensor
zeroAlt = sensor.altitude() # take an initial altitude reading

sleep_ms(1000) # Adding a delay to ensure everything is initialised before reading

while True:
    # Print data
    tempC, presPa, humRH = sensor.values() # read all data from the sensor
    pres_hPa = presPa / 100 # convert air pressurr Pascals -> hPa (or mbar, if you prefer)
    print(str(tempC)+" °C  " + str(pres_hPa)+" hPa  " + str(humRH)+" %RH")
    
    # Altitude demo
    # print(sensor.altitude() - zeroAlt) # Print the pressure CHANGE since the script began
    sleep_ms(5000)
    led.toggle()

Let us know how you go!
Liam

Hi guys,
Problem solved! After a lot more testing, I’ve discovered that both USB ports on the front of my server can’t be outputting enough power to fully drive the Pico, Piicodev expansion board, and the BME280. Just enough for the Pico to run, but not enough to drive everything else.

I’d previously tried both USB ports and got the same error message, so I assumed that it couldn’t have been the USB ports. However, they both come off the same internal bus within the PC, so not surprisingly they probably have the same maximum power output. The PC is old, so could also be an internal power supply issue, or just old USB drivers.

Once I switched to the rear USB ports on the PC (they are bloody hard to get to, which is why I haven’t tried them before!), the code works as expected and the BME280 works just fine. I’ve since finished my own code which sends the data to a server over the Pico’s wifi, and that worked too.

So, problem solved! All those spare Piicodev parts that I bought as part of my fault finding exercise can now be turned into another weather monitoring station - bonus :grin:

Thanks for all of your help to diagnose this, it was greatly appreciated. You guys provide great support!

Thanks,
Dean

3 Likes

Hi Dean,

Thanks for circling back and updating everyone!

Thats a real gotcha!

Glad to hear you got it all working and keen to see how you implemented everything!
Liam

Hi All.
This highlights something I have been pushing for a long time.
When you have elusive hard to explain problems Check and make sure the power source is still OK or indeed up to the task. This really goes for any sort of problems. You would be surprised how many faults are rectified this way, and fairly quickly.

This technique has been working well for me for over 50yrs.
When starting a project or anything else for that matter I try to go for the most grunt I can find then whittle it down later if required. This gets one item out of the way that I don’t have to worry about. Not having enough capacity can mask everything and result in chasing problems which are not really there because there has not been enough power in the first place.

This post is a good example, 4 days. The up side is that I think Dean has learned some valuable lessons which in itself is a good thing as after all this is really a forum to learn.
Cheers Bob

Hi Bob,

Yes, I was quite conscious that the USB ports mightn’t have been up to the challenge. However, it’s difficult to measure actual voltage coming out of a USB unless you get yourself a USB power meter - which you can definitely buy, but I don’t have one. It’s only my IT background that made me think that there might be a different USB bus for the front USB ports and the rear USB ports - which is quite common in servers, not quite so much in desktop PCs which are usually configured with one USB controller.

Regards,
Dean