Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Questions and discussion about The WiPy 1.0 board and CC3200 boards.
Target audience: Users with a WiPy 1.0 or CC3200 board.
sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Tue Oct 23, 2018 6:53 am

Trying to connect my WiPy 2.0 to a BME280 using this library: https://bitbucket.org/oscarBravo/wipy_bme280. I've updated the WiPy 2.0 firmware to the current latest version (currently reporting MicroPython 1.18.0.r1 [v1.8.6-849-9569a73]). When I try to run the code given in the README file provided at the address above, I get a 'TypeError: function missing 1 required positional arguments' when I run the 'bme = bme28.BME280(i2c=i2c)' line. I did update the 'i2c =' line to use the standard pins for SDA (P9) and SCL (P10) but other than that everything else is the same. Has anyone run this BME280 library lately on a WiPy 2.0? Is it still current? Appreciate any help.

User avatar
pythoncoder
Posts: 3241
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by pythoncoder » Tue Oct 23, 2018 7:03 am

The WiPy 2.0 is a Pycom product so this query is most likely to be answered if you raise it in their forum.
Peter Hinch

sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Tue Oct 23, 2018 1:27 pm

Yes, I know the WiPy is a Pycom product but I'm not having trouble with the WiPy itself just interfacing with the BME280 library. I'm posting in the WiPy area of the MicroPython forum, so I figured that would at least help to get my question in front of some WiPy users. And I'm also here because I originally found the info regarding the BME280 library I used on this MicroPython forum in this topic: viewtopic.php?t=1315. Actually, I believe you had some posts on that thread. So, I figured it was at least worth a shot asking here. I'll post the question on the Pycom forum too if I can't get any help here but hopefully I can get this resolved here. Any comments on what I'm seeing?? Could really use a little help from you guys with more experience in micropython than I have.

User avatar
pythoncoder
Posts: 3241
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by pythoncoder » Wed Oct 24, 2018 5:39 am

WiPy 1 and WiPy 2 use entirely different hardware, which is why I recommended posting in the PyCom forum. That said the BME280 uses I2C which should be hardware independent. A possible cause of problems is that I2C requires pullup resistors on the two I2C wires. I don't know whether PyCom provide these on their boards or whether you have to supply them. You could try fitting 4.7KΩ resistors to 3.3V.
Peter Hinch

sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Wed Oct 24, 2018 11:00 am

Understood. But don't believe that's the issue. Not seeing pull-ups used on any other I2C uses on WiPy 2.0. Connections to SDA and SCL should just be straight connections. Are you aware of any other libraries for micropython communication with the BME280?

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

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by Roberthh » Wed Oct 24, 2018 11:59 am

The WiPy2 has no on-board pullup resistors. The ports are set to internal pull-up, which will work for short cables and lowe speed. Most break-out boards with sensors have pullup resistors soldered on them. That's why it is normally no problem.
If I look at the code of bme280.py, it shows that the clas constructor requires two arguments, the i2c address and the o2c object.
According to the data sheet, the I2C address is 0x76 or 0x77, depending on the wiring. The example in the readme seems wrong. it should be
bme = bme280.BME280(0x76, i2c=i2c)
or
bme = bme280.BME280(0x77, i2c=i2c)

sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Wed Oct 24, 2018 12:38 pm

That would make some sense regarding the error I received. Did you base that on just looking at the source code? Do you have a WiPy 2.0 and a BME280 that you can actually try this with? I'd be interested to know if the problems I'm seeing are associated with my device(s) or are an issue with the library itself. Seems odd that the example code given in the readme would be wrong though but I do see that it does appear to not match the function definitions in the code. I do appreciate your help. I'm going to take a look at the Adafruit micropython library for the BME280 itself and see if maybe I can get that to work. Just figuring that someone must be using a BME280 with the WiPy 2.0 somewhere. Really was hoping to just use an existing working library and not have to put something together myself.

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

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by Roberthh » Wed Oct 24, 2018 12:50 pm

I just looked at the source code and the data sheet. I have no BME280 at hand, but an ESP32 module with the WiPy2 firmware. but since you have that available, you can easily try yourself.

sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Wed Oct 24, 2018 1:49 pm

I will try later today and report back what I find. From the source code, the library was ported from the original Adafruit BME280 micropython library (which has been deprecated & archived). They have replaced that with their CircuitPython BME280 library but I really haven't dug into the differences between straight micropython & circuitpython yet, so I'm not exactly sure what the differences are or if the new library has any possibility of being used. I may take a look if I get some time later. Just want to get this sensor running as easily as I can on the WiPy 2.0. Like I said earlier, I just figured someone must have already gone through this, and I was hoping I could just plug into an already working library and move on with developing my application. But, I can't seem to find any direct matches on my searches. I can piece it together if I have to but that wasn't what I was hoping to do. Again, thanks for your help.

Here's another newer micropython library for the BME280, https://github.com/triplepoint/micropython_bme280_i2c. But I think this was written for the pyboard. I haven't looked at the source code to see what it would take to make it compatible and usable with the WiPy 2.0 yet.

sealyons
Posts: 13
Joined: Tue Oct 23, 2018 6:33 am

Re: Attempting to read BME280 sensor from WiPy 2.0 but having trouble ...

Post by sealyons » Sun Oct 28, 2018 12:49 pm

Still having trouble with this. First, I'm just trying to verify communication with the BME280 sensor via I2C and that doesn't appear to be working. Can someone verify that I'm doing this correctly. I'm just trying to setup the I2C communication path and then scan for the sensor's address. It's the only sensor connected and its address should be 0x76 but the scan keeps hanging. Again, I'm using a WiPi 2.0 and the 2.0 Expansion Board. I'm also using the default SDA and SCL pins which I believe are pins G16 (P9) for SDA and G17 (P10) for SDL. This dual numbering system is quite a pain!

I'm new to setting up I2C communication, so please let me know if I'm doing something stupid (which I know I am). First, can someone please explain the baudrate setting and what the range of values are and what it should be set at for I2C. The docs don't give a range and show a bunch of different values but I keep seeing 100000, so that's what I'm using. What determines the value that you use? Is the value based on specific sensors?

Ok, here's the code I'm trying to use:

from machine import I2C
i2c = I2C(0, I2C.MASTER, baudrate = 100000)
i2c.scan()

When I run this, the WiPy just hangs with a flashing cursor in the REPL. I'm running on a COM connection through ATOM.

Appreciate any help with this.

Post Reply