balenaSense + Pi3B+ + Sense Hat = no pressure readings

Hi, sensor offsets were only introduced on balenaSense version 1.5. Since you are running a version that is older (v1.0.4) they won’t work.

The code that handles offsets is quite simple though and I think can be added rather easily if you know your way around Python:

  • You can check the code that implements it here
  • And then you would need to add the offseting logic in here, after get_readings is called.

I have been trying to add the code back and it bombs constantly. I have deleted the git folder on my machine and cloned it again from source. This is not the first time I’ve coded (35 years of IT experience), but it is the first time I’ve used Python. The process of making changes and uploading to the cloud to have it download to the device is a bit cumbersome for development purposes. How can I test the code before deploying it?

You can see our local development workflow which is outlined here https://www.balena.io/docs/learn/develop/local-mode/. The steps are to enable local mode on the device then you can push your changes directly to the device. This should vastly improve your local development experience.

So I edited sense_hat_air_quality.py and added the following:
After line 16 I inserted current_pressure = sensor.get_pressure()
and on line 94 (formerly 93) I uncommented the line and modified it to read 'pressure': float(current_pressure),

Is there anything else I need to do?

Hi Carlos, the changes you made do not seem in line with what tmigone suggested earlier. What are you trying to achieve with these modifications ?

Have the Sense-Hat report barometric pressure using the current release of the balena-sense project.

@etrigan63 we understand that’s the overall aim here but as you’re starting to modify things we can get a bit more specific. :slight_smile:

There are a few options still available, as I put in my initial reply. To clarify, the current version (as of writing it’s v1.8.3) of balenaSense will not read the barometric pressure from the Sense-HAT. The reason for this is that we interface directly with the sensors on the board and do not use the full Sense-HAT library as it includes a lot of dependencies related to the other functions of that HAT which we don’t want to include in the project. This is especially true as the main focus of the project is not the Sense-HAT because it doesn’t have any sensors that allow us to give a reading for air quality.

I see you tried uncommenting the pressure reading line, which is a good start, but simply uncommenting that line will not work without going back and installing the full Sense-HAT library (as a mentioned a couple of times by my colleagues earlier in this thread) which was present in v1.0.4, otherwise there would be no reason for it to be commented in the first place. You’re making the changes which take the sensor reading and insert it into the database, which are kinda the more superficial changes which would be required after you solve the problem of actually retrieving the data from the sensor. As mentioned this either requires the Sense-HAT libraries to be installed (you can see how that was done in v1.0.4 here) or adding support for the LPS25H (I linked some possible ideas in my first reply).

As you found, going back to the older version worked, but then you won’t be able to use the features that were added after v1.0.4, such as the temperature offsets or altitude compensation for pressure.

I’d recommend that you focus your efforts on adding support for the LPS25H pressure sensor (the one that’s on the Sense-HAT board) rather than trying to backport new features to old versions, this approach will be a lot cleaner, involve less problem solving/conflict resolution and then we can add it to the project and support it going forward if you figure it out. We won’t be adding the full Sense-HAT libraries to the current version for the same reasons as they were taken out, so the only way the pressure sensor would be fully supported going forward is via this route. This is unless something has changed with the official libraries and that they can now be used to obtain the pressure reading without installing a lot of extra packages. If you do want to continue hacking at it, the replies in this thread have all the information you’d need. You can use the comparison tools on Github to show you what changed between the two versions as well as the local development mode on the device as linked above to make instantaneous changes without having to go via the cloud - be warned though, the Sense-HAT libraries do take a while to build (another reason why they were removed)!

If you’re not able to get it working, definitely head over to the Github repo and add an issue asking for it to be supported, and we can consider adding it in the future. If you do figure it out you’re welcome to submit a PR on Github and we can add it to the project so that it’s supported with all the new features. Right now though, add support for this sensor is not a priority as we have others we’d like to add first (notably the Pimoroni Enviro+ PHAT which has a particulate sensor option amongst others, which are more beneficial to the air quality monitoring purposes of the project).

OK, so I added the lps25.py and it says that there is no module called uctypes.

@etrigan63 that file is very unlikely to work out of the box as it’s MicroPython - you’ll need to modify this and/or resolve dependences to run in the Pi environment.

Again, kind of a noob with Python. A working lps25 example would be keen.

Hey @etrigan63 we don’t have a working LPS25H example as we haven’t added support for that sensor on the project. You can take a look at this repository which has some pointers on how you could implement it.

Cheers!

Nice find @ntzovanis!

Hi,

Were you able to get this sorted? If you’ve found a solution, please feel free to share it and let us know if there’s anything else we might do from our end.

Best regards,
John

Not yet. Ordered the Pimoroni EnviroHat to give that a shot.

So the Enviro+ Hat arrived and I soldered the GPIO pins onto a Pi Zero W (that was my second attempt at soldering - I am quite the lumberjack when it comes to soldering) and assembled the unit and deployed it. Everything works except the IAQ function and I am not sure why.

@etrigan63 the Enviro+ hat doesn’t have an IAQ sensor, which is why you’re not seeing the reading. However, it does have some other cool stuff you can monitor. Where the Grafana dashboard is set to ‘balenaSense’ on the top right of your screen, you can change this to ‘enviroPlus’ and you’ll get a lot more information.

Very cool. Is there a temperature offset for this panel as well or does the same one apply? My temps are a little high.

@etrigan63 yep the same 3 offsets that are available apply to this sensor too. I haven’t personally tried them with this board but they are applied at a high level so should work across all sensors. Let us know if you have any trouble.

Hi

The support for this sensor has been merged into the balenaSense project as of version 1.9.3