robmarkcole / bme680-mqtt-micropython

Publish data from the bme680 sensor over MQTT using micropython
MIT License
15 stars 7 forks source link

Help? #1

Closed papics closed 6 years ago

papics commented 6 years ago

Dear Robin,

First of all, nice setup!

I am trying to use your libraries to make a similar project work, but I am having some difficulties. I have quite some experience in python, but this is the first time I am working with sensors and micropython, so maybe you can help (even though this is not an actual Issue in your code on github).

I have an Adafruit HUZZAH32 - ESP32 Feather Board to which I installed micropython (following https://www.rototron.info/raspberry-pi-esp32-micropython-tutorial/ and actually I already made this work with a DHT22 sensor on another ESP32, so I know that this part should be all right, and I have also made use of the MQTT protocol there before, so that part works too), to which I have wired a BME680 using the default scl/22 and sda/23 pins.

Using only

... import bme680 from i2c import I2CAdapter ...

... i2c_dev = I2CAdapter() sensor = bme680.BME680(i2c_device=i2c_dev) ...

my code gives an error: "TypeError: 'scl' argument required" on line "i2c_dev = I2CAdapter()"

So I tried with my basic understanding getting to the bottom of this, and I can get to the next line in the code at least if I do:

i2c_dev = I2CAdapter(scl=machine.Pin(22),sda=machine.Pin(23))

which results in an error: "OSError: [Errno 19] ENODEV" on line "sensor = bme680.BME680(i2c_device=i2c_dev)"

One more thing I tried is to see if this setting sees the connected sensor, by

i2c_dev.scan() [119]

So I think that should be fine, but I have no idea how to progress from here... I had no issues make this setup work with the DHT22 sensor, but I am pretty stuck with the BME680. I would appreciate any kind of suggestions, as based on my quite extensive google search, there are not many people who have experimented with this setup (or at least nobody have documented it online besides you).

Best regards, Peter

robmarkcole commented 6 years ago

Hi @papics you will see that I am using a fork of the i2c library by @gkluoe, which was required to get the BME680 working. You can see the discussion here. I recommend reaching out to one of the experts on that thread if you're not able to resolve this issue. Let me know how you get on. Cheers

papics commented 6 years ago

So the issue is solved as you might have seen it in the linked issue thread, so I will close this issue here. Thanks for the help!