Enviro+ readings unrealiable

I wonder if some of the newest updates by Bosch to their BME280 will improve the outputs?
https://github.com/BoschSensortec/BME280_driver

I have two boards, one works well, the other one doesn’t. I doubt a software update can fix that?
/Remco

I have two boards, one works well, the other one doesn’t. I doubt a software update can fix that?
/Remco
True

New to forum: I have two boards, and I have resolved the temperature and humidity issues in the same way as most of you - through an IDE type cable female male ends. Also through arranging sensors so that the enviro+ sits on one side, the Pi Zero on the other, and the air filter between them.
Returning raw_temp as opposed to compensated seems reasonably “okay”. My sense of what is okay is against two other physical one wire sensors, one 10cm beneath the ground, and one at 30cm. The temp was occasionally good, but plots would have the compensated value all over the place - no good at all.
Pressure seems good against data pulled from DarkSky (although this is SEA LEVEL as opposed to at station - something that took me too long to realise!).
Humidity - this seems consistently lower than where it should be on the two outside devices (BME280 and BME680) - but they compare well against each other.
My biggest gripe is with the gas sensor. Even when you assume its just a representative value that will scale - a mother in law on a bleaching spree appears to have little to no deflection for the Chlorine levels.

I noticed the O2 sensor goes up when we do gas cooking, so I think it detects NO2 but it also seems to mirror humidity, so very hard to get any meaningful results.

I don’t have the background to make sense of this one. Interesting data sheet, but I don’t see a useful application for me. CO is not relevant in my house, CO2 is interesting, but I have a NetAtmo for that and other values have no value to me. What would a practical application be?
/Remco

I find measuring NO2 interesting because it is caused by traffic pollution, gas boilers and gas cooking. I notice an increase in the house of particles and NO2 when I see neighbours parking their cars nearby on my cameras.

When I go outside in the UK I always have a runny nose. When I am in Tenerife I don’t, so I think the pollution in the UK is so bad it affects my mucus membranes. NO2 mixed with water makes nitric acid!

Where I live, we don’t have natural gas anymore and you see more and more hybrid and electric cars, but I get where you’re coming from. When I read that datasheet however, it’s all measured under controlled conditions, so I would have no idea how to interpret the data properly related to the RH and such. And to do so, we’re back to the start of this thread, having reliable RH readings in the first place ;-) I expect I’ll have a slimmed down version on my desk in the future and I’ll build something with separate sensors for outside.

Yes is looks nearly impossible to get absolute numbers from the gas sensors and also quite hard even to get relative readings unless it is indoors. This is what it looks like inside my home in the UK where it is relatively stable:

A peak in Oxi and particles. Not sure if it nearby traffic or perhaps a weather inversion as it is was cold in the morning.

In a shed with a louvred door in Tenerife, which is effective outside but sheltered, the gas sensors go berserk.

Monday, Tuesday and Wednesday we had a weather system called La Calima. A high pressure in the Sahara creates hot strong winds that bring lots of sand and dust that reduces visibility. The temperature goes up, humidity plummets and the particle count goes up. The winds were strong enough up uproot trees, bring down road signs and blow off our skylight.

Perhaps the particle peak in the UK the day after was also from the Sahara. We do occasionally get sand from there. Did anybody notice dust on the car this morning?

Thanks to nophead working me through it I now have his code working on my setup which a Zero WH ribbon cable and Enviro+. Currently it is indoors by a windowsill waiting for the addition of a fan.
The RH figures seem way off, the temperature a little high and I am still trying to understand the gas and particle numbers.
All the peaks in the particles on my graph coincide with cooking, the kitchen is next door and the hob is gas. With the big storm approaching us here in the UK the drop in pressure is also reflected, I am in the South West and we tend to get them first.

Enviro4

Cool! I’m a sucker for graphs, is there some tutorial to get that?
/Remco

Perhaps nophead can point you in the direction of a tutorial but if you can ‘teach yourself’ he posted this graphical solution in this thread where I got it from:
https://forums.pimoroni.com/t/enviro-ohms-to-ppm/12207
As a beginner I can just about read his code but I certainly couldn’t create it, it is a super piece of work.

Bookmarked, I can work with that, thanks 👍🏻

An update from my end with the Enviro+…I did a couple of physical changes which involved separating the Enviro+ and the Pi. I put the Pi in a neat little case that I originally recorded from Pimoroni but never used. I then used a 40-pin header extension block that effectively lifts the Enviro+ about 15mm above the top of the new Pi enclosure. Whatever heat that little CPU generates isn’t going to be effecting the Enviro+ now, that’s for sure, especially as it’s sitting the the breezeway of my little outdoor enclosure.

The results? Way more sensible temp and himidity readings, rendering the scaling factor in the example Luftdaten code redundant. Basically, the raw temp off the chip is a much better representation of the actual temp, and the same for the humidity values. The pressure readings have always been accurate regardless.

I say ‘realistic’ and not ‘spot on’. And I think I know what’s happening. The raw temp is about 2C too high, and the humidity is about 10% too low. The temp effect seems linear, so I just subtract 2C from the raw temp and I’m happy with it. I’ve scaled up the humidity to where it seems to be about +/- 2%. Pretty good for a hack job.

I think I know a path to spot-on figures but I haven’t had time to start playing. There’s a lot on info that suggests different ‘modes’ of the BME280 depending on the application. Weather, indoor, etc etc. Lots of variables, including the read mode (continuous, forced, etc) and how often you read from it. The more you use it, the more it warms up… So, calling the chip in a tight loop is asking it to do more work, so it heats up, and having it in ‘normal’ mode means it’s sampling all the time, basically. Again, more heat. I need to figure out how to set the chip in to the ‘weather configuration’ and see what happens. Here looks promising…

2 Likes

I think I’ve at least partially solved the problem of heat transfer from the RPi to the BME280 as pictured below.
I had a BitScope Uno RPi Blade and an RPI-4 from another project. Mounted the Pi and the Enviro+ hat separately on the blade with a small exhaust fan pulling outside air through a screened inlet across the BME 280 and adjacent to the particulate sensor. The 5VDC fan was fast and loud so I slowed and quieted it using a PWM controller (Green Knob). The unit is mounted outdoors on a wall in a 2L Sistema sandwich box from New Zealand (available at Amazon).
The setup is more expensive than using the downspout material and the hat mounted on an RPi Zero, but better protected from weather and with a more robust power supply (12VDC in/5V regulated out). Better wifi power too, I think. I calibrated it with an analog thermometer by changing the software compensation value and it has been stable and accurate for a week.

Comments welcome.

I tried a ribbon cable and very literally smoked the hat. Obviously, the ribbon cable challenged my ability to visualize the header orientation. Think 3.3V got traded for 5V or GND!

Yes, I triple checked it and took a reference pic with my phone haha
Your setup is indeed beefier. A RPI4 is way more computing power that you need for this, possibly you can use that for some local visualization with Grafana or something en clip a webcam to it to stream to YouTube?
Same goes for the 32gb card, those I’d save for projects that need local storage? 🤔
/Remco

I successfully corrected the temperature and humidity errors by doing two things. Firstly, I separated the Raspberry Pi Zero and the Pimoroni Enviro+ boards, placed the PMS 5003 between the two boards and used ribbon cable to interconnect them. I’ve designed and built a 3D printed case to hold them. I’ve included a photo of the case.

![20200214-IMG_1811|690x479]

Secondly, I logged the Enviro+ temperature and humidity readings, along with the temperature and humidity readings from a closely located Aeotec Multisensor. Those logs allowed me to undertake some machine learning using regression analysis, to develop some correction algorithms. I tried polynomial regression but found that linear regression was sufficiently accurate.

I also implemented an algorithm that adjusts the relative humidity to align with the adjusted temperature. I implemented that algorithm using August-Roche-Magnus approximation using https://bmcnoldy.rsmas.miami.edu/Humidity.html

I’m now getting temperature readings with a ±0.4 degree C accuracy and relative humidity readings with ±2% accuracy. I plan to run the ML training on a much larger sample size, with a wider variety of temperature and humidity values to fully verify the algorithms, but the early results are promising. I’ll post the final code, case design and regression analysis when I’ve completed that larger sample size.

In the meantime, here is an extract of the correction code. The corrected temperature is comp_temp and the corrected humidity is comp_hum. It’s possible that the regression compensation variables might need some adjustment if a case that differs from mine is used.

Hope that’s of use to those of you struggling to get some temperature and humidity accuracy.

Set up the regression compensation variables
cpu_temp_factor_slope = 1.038 # Linear Regression to minimise impact of CPU temp on Raw Temp
cpu_temp_factor_intercept = 12.503
comp_temp_slope = 0.623 # Linear Regression to adjust Raw Temp (with impact of CPU Temp removed) to provide compensated temp
comp_temp_intercept = 23.519
comp_hum_slope = 0.966 # Linear Regression to adjust temperature-adjusted raw relative humidity to provide compensated relative humidity
comp_hum_intercept = 15.686

cpu_temp = get_cpu_temperature()
cpu_temps = cpu_temps[1:] + [cpu_temp] # Smooth out with some averaging to decrease jitter
avg_cpu_temp = sum(cpu_temps) / float(len(cpu_temps))
raw_temp = bme280.get_temperature()
cpu_temp_factor = cpu_temp_factor_slope * (avg_cpu_temp - raw_temp) + cpu_temp_factor_intercept
raw_temp_without_cpu_impact = raw_temp - cpu_temp_factor
comp_temp = comp_temp_slope * raw_temp_without_cpu_impact + comp_temp_intercept
raw_hum = bme280.get_humidity()
dew_point = (243.04 * (math.log(raw_hum / 100) + ((17.625 * raw_temp) / (243.04 + raw_temp)))) / (17.625 - math.log(raw_hum / 100) - (17.625 * raw_temp / (243.04 + raw_temp)))
temp_adjusted_hum = 100 * (math.exp((17.625 * dew_point)/(243.04 + dew_point)) / math.exp((17.625 * comp_temp) / (243.04 + comp_temp)))
comp_hum = comp_hum_slope * temp_adjusted_hum + comp_hum_intercept

1 Like

Here’s another photo of the case, this time showing the underside ventilation.

… and with the cover in place.

1 Like