Plugin stops without any output when using bme280 library

Hello friends,

First of all the obligatory thank-you for all the work I've consumed and used in this community, even without being active at all. I learned quite something already :slight_smile:

The tl'dr: When using bme280.load_calibration_params(..) the plugin stops running without warning. Same script works when called via source oprint / python __init__.

Now onto the long version of the challenge which I'n struggling with:

Goal:
Have a plugin which reads data from a bme280 sensor connected via I2c in the navbar.

What I did:
I created a standalone python script which pulled a bme280 sensor on a raspberry pi 3b running octopi correctly.
Then I basically went through the intro tutorial and some repositories* and created my very first plugin (github link). In the repo is an example log output (example_log.txt), too.

The problem:
In short, I'm out of ideas. I've put several debug warnings in the __init__.py - the plugin simply stops running, I don't get any errors, other warnings or anything. The magic part of the code is:

self._logger.warning("now I'm running ..")
(use bme280 library)
self._logger.warning("now I'm dead. This log info does not appear.")

Soon, I realized that I can't manage to pull data from the sensor - but only when running the plugin code through octoprint. As soon as I call the modules via console, everything works like a charm and I see the data:
source ~/oprint/bin/activate
python [path-to]/__init__.py

Versions Info:

Python:      2.7.16
OctoPrint    1.4.0rc3 
OctoPi       0.17
RPi.bme280   0.2.8

What I'm hoping for is a hint on how to continue debugging and/or how to fix my issue. I have simply no idea on what to even try, I've reduced it to one line of code - with it, it breaks and without it, it doesn't work.

Thanks in advance,
Georg

*The repos used (as a newbie I can't put enough links in the post, sorry!):

github . com /jneilliii/OctoPrint-M117NavBar

github . com /Renaud11232/OctoPrint-Resource-Monitor

Not sure where it's going, but (1) put some log statements the in get_bme function (including before the SMBus call), (2) call self.get_bme instead of the bare get_bme, (3) turn this print into a log statement.

You can see that (2) is different between the calls on line 23 and 53. It doesn't explain why you aren't seeling a crash or exception, but it should help us walk through it further. I bet either SMBus instantiation is failing or the exception on 39 is hit and not sending data to the logs indicating there is a problem.

Thanks a lot for the pointers!

for 1) The SMBus debug log I had already, updated both the log file and the code accordingly. Sorry for missing this.

for 2) I have literally no idea why but the change to self.pull_bme280() worked. Before I had everything in one function and only splitted it for readability. Now the only thing not working is the RepeatedTimer(..), but this is a completely different set of questions I assume! And I haven't started looking into it :smiley:

Make sure to fix (3). Really, if that fails, you need to exit in a same way, not simply print and carry on.

Done now! That was a leftover of my console shenaningans.

Nice plugin. I've been working on a replacement graphing tab for the Temperature tab and with some minor tweaks to your code you could also graph that data. More details listed over here. An example of what you need to do to add the data to the graph is in the plugin's repo here. Only drawback is that you'll need to install a patched version of OctoPrint and currently the data being passed to the graph must include an actual/target pair.

Thanks for the encouragement @jneilliii! I'll have to first improve my dev setup though ... debugging the JS and python part with vim via SSH directly on the Pi was a learning experience :smiley:

Yeah, I just recently setup my dev environment in windows using pycharm to make the changes to OctoPrint. Before that I was strictly reading console output and log files. Obviously, for this plugin you can't use windows since the pi is critical to the functionality.

1 Like