I currently use the TCA9548A board to two BME280 sensors with one ESP8266. In the near future I will be saying ‘use to use a TCA9548A board....”. This is the first video or web site that demonstrates how to change the address on the generic BME280. Thank you.
Thanks for taking the time to share this. I'd been playing with a BME280 breakout board for a few months on and off and just hooked it up from the pinout, never bothering to look at the datasheet (in a effort to just get something working, aka no patience). Now I'm reviewing the code and looking to introduce power saving, I'd never have thought to sleep the BME - I've the datasheet downloaded now. Lesson learned :)
A note about the sample code you used at 0:55. You are doing two reads to take an average. The sensor can do that for you by adjusting the oversampling parameters. Oversampling makes it possible to reduce the noise in the measurements, section 3.4 of the data sheet.
Hi, l I think you missed that one reading is bme1.readtemperature and the other bme2.readtemperature, the example shows how to take a reading from two different devices at different addresses.
Gracias capo de la vida! Me solucionaste la existencia diciendome que hay que conectar SDO-VCC para obtener la adress 0x77 en el BME280. En todos lados leia que habia que conectar SDO a GND y no me funcionaba. Perdí muchas horas hasta que encontré tu video y ya tengo funcionando 2 BME280: uno en 0x76 y el otro en 0x77. Buena vida bro
I updated one of my outdoor temperature sensors with a BMP280, and as you predicted, power usage is noticeably less. As I monitor the voltage of the LiFePO4 battery, I can tell from the graph the slope downward is not even enough to imagine a sled to move on it's own downhill, where before your suggested force to sleep it was steep, especially when the battery was freshly charged. Like many people I just believed the datasheet ( i.e. that the module would go into sleep mode automatically), the facts prove otherwise. Thanks!
Yes, the data sheet says when in forced mode the normal setting it returns to sleep when in fact it returns to some quiescent state that is not sleep, when set to sleep it definitely sleeps, the savings are worth it for battery powered operation. Good to hear it works for you.
@@G6EJD Hi please see batteryusage graph of one of my BMP280 temperature sensors. I added the sleepmode on June 20th. It looks like power usage is reduced by an order of magnitude: See this graph: 1drv.ms/u/s!AmouwiVw2cl-dFin_9cVlVDhoi0?e=MSpMiZ
The two most popular BME280 libraries are from Adafruit and Sparkfun. Both these libraries try to be generic enough for all possible use cases. Being generic, they are not very optimized for various things. For example in the Sparkfun library, registers are read one at at time vs instead of burst as recommended in the data sheet on page 23, section "4 Data read out". The Adafruit library will call readTemperature in both readPressure and read readHumidity because the latter two depend on the temperature. So in the sample sketch above, in each loop, the temperature is read 6 times. In a battery operated temperature sensor running on a super low power micro controller, you want to spend as little time awake. Awake the microcontroller, take a reading as fast as possible, determine if it should be sent (serial / RF / etc) and get back to sleep as soon as possible. Typically you will wake every 60 seconds. To be clear, the quality of the Adafruit and Sparkfun libraries are really great and they are designed to allow the user to fall into the pit of success. I have been working on an optimized BME280 library for only weather sensing (60 second forced read samples, 1x temperature, 1x humdity, 1x presssure over sample, no filter) as recommended in section "3.5 Recommended modes of operation" in the data sheet. I hope to have the code up on github later this summer once I have tested it against multiple of my BME280 boards.
Phil, hopefully you will include a specific sleep mode or ensure in forced mode it does indeed return to sleep, the Adafruit implementation of forced mode does not return to sleep mode, maybe because of over reading or simplification. Over-writing of the F4 register could easily be resolved by just clearing bits 0 and 1, I suppose I could have implemented it that way, but as long as the library initialises the device it does not matter how sleep is achieved. I look forward to seeing your library. When all said, I do side with Adafruit’s approach to coding the library if it enables the majority of readers to quickly understand what’s going on, since the Arduino (est) community is mainly about learning just enough to get something working. I’m reminded of my university tutor teaching not to over use Karnaugh map ‘simplification’ as it makes future reading or understanding near impossible, he was mainly referring to the future maintenance of the design, they were wise words.
@@G6EJD I just pushed my work "in progress" code to my github account, pbolduc/bme280-for-weather. Like I said, it is very opinionated. One area I dont like is that I have observed it takes between 8 - 9.3 milliseconds to complete the read. I dont like that I have to sleep / block for the entire time. I dont think on the Motieno micro controller I am using I can deep sleep the processor during that time. Maybe it doesn't matter?
Be aware that writing 0b00000000 to the ctrl_meas (0xF4) also over writes the temperature and pressure over sampling bits. You will have to reset those bits if you want to get any readings (humidity depends on temperature reading) when using a forced read. If you are using the BME280 for weather sampling and using the recommended over sampling settings from the data sheet, 1x temp and 1x pressure, you would set 0x00100100 to set to sleep, and 0x00100101 for forced read. You do not need to write sleep after a forced read as the state transitions back to sleep automatically, see page 15 of the data sheet.
Yes agreed, I’m relying on the Adafruit library to set the device into the correct conditions for reading or indeed any other library, as I’ve yet to see any library that can enable the device to be explicitly set to sleep. Forced mode says it returns to sleep but that’s not my experience and power demands stays relatively high.
@@pbolduc, I'd be interested in your validation of my results. Also if your into minimising power consumption, I'm surprised your don't already know what your getting in sleep mode power consumption, I would not be surprised if your getting ~500uA as I have yet to see a driver that achieves sleep mode after a read, most leave the device in forced read mode and hence the ~500uA consumption level. Despite what the data sheet says, the BME280 does not go back to sleep in that mode.
Excellent video David, I was searching your videos to see if you covered this very topic yesterday... What do you think of powering the BME280 with a GPIO and turning that off during sleep - I think GPIOs turn off anyway during sleep? I'm experimenting with that and a 5ms power up delay before I take readings.
Yes it’s a good idea, never tried it, but it should work, the only doubt I have is the gpio output impedance which might be too high for the bme280 to start correctly, but I notice it’s power supply rejection ratio is very high, so should be ok, maximum ESP32 gpio pin source current is 40mA, so swell within range, maximum power requirement is 0.714mA. Startup delay can be 2mS before taking a reading. Yes when the ESP32 goes to sleep all the gpio pins are released and go tri-state, but if required you can enable the pins in sleep mode, lots to experiment with😀
Thank you for this information! I want to create a simple weather station powered by batterie and solar panel and this bits of precise informations help a lot!
Hi, i have 2 unbranded i2c modules, i can't change the address, i can't see the bridge but tried to cut anyway, the first 2 contacts tested for continuity with gnd always beeps, if i solder the center and last one the modules (i tried both) overheats beyound being touchable and does not show if scanned, i also tried to power it via 3,3v instead of 5v and it gets less hot, barely touchable without burning a finger, but it does not show up, maybe is a defective batch?
But why is the sleep mode 'better' than the force mode? As I understand the datasheet, the BME goes into sleep mode after taking one measurement in force mode anyway.
Very nice sir I have a question that although bme28 is most popular sensor but which sensor would you recommend for commercial product development from project to final product release because as we know BME 280 sensor having self heating issue which gives unreliable readings . May I use HDC1080 sensor for iot product development or go for something else???
Well self-heating is caused by the sensor being left in continuous reading mode although in terms of heating energy it’s only 1.6mW so not much and very much less than the ambient heat, so should be negligible. I’ve never experienced self heating because I only use the 3.3v sensor with no regulator. If your using the smaller unbranded board or any carrier board with a regulator then it will dissipate (5 - 3.3)x0.5= 3.35mW which can get conducted down pcb tracks to the device. Now if you were referring to the BME680 where self heating is a definite problem because the sensor for gas has to be heated to 220°C and this can affect temperature reading accuracy, the solution is to not read temperature at the same time as gas and separate the readings by many minutes and by placing the device into sleep mode during readings, so wake take a temperature and humidity reading then sleep them take a gas reading then sleep and repeat is how I do it. Adding another sensor adds to cost.
@@G6EJD thank you sir for guidance and how I can improve or get accurate temperature and humidity readings because ds18b20 gives verry accurate reading when i compared with BME 280 unbranded 3.3 sensor module. Bme 280 gives 2-3 ° degrees more readings so should I correct at programming side or which approach would you recommend for accuracy
Unfortunately that device does not support a specific sleep mode, but in standby (no reading taking place) it consumes just 50uA so with a Lolin D32 taking 77uA plus 50uA a total of 127uA isn’t too bad for battery use. Other ESP32 boards won’t be anywhere near as good though.
Thanks David for nice instructions. Been playing with BME280 for more than a year, never been able to get IAQ readings to be accurate as well as temperature. (Usually temperature indicates about 2 - 2.5C° higher to actual). Maybe sleep mode can sort it, will try. Thanks again!
You really need to use the device at 3.3v meaning a device with no on-board regulator and if it has an on-board regulator it should still work at 3.3v, so I recommend checking the supply voltage is well within specification (3.65v max) and yes sleep mode will help, but at 3.3x0.5mA=1.65mW it’s just not enough energy to hear the device and ambient conditions will always control its temperature. Is there any conduction down pcb tracks from say a cpu / regulator that is causing the temperature skewing - its much more likely to be the cause.
@@G6EJD Sorry, David, my bad, you are about BME280, but I wasn't awake enough and my brain did a trick - I thought it's about BME680. You are absolutely right, no issues with BME280, been using avail ago successfully.
Dear Mr David, thanks very much for the note, very useful indeed. In my project I also have an Adafruit_SSD1306 display. Is there a similar way to put it to sleep? Thanks.
Using adafruit lib you can turn it off using display.ssd1306_command(SSD1306_DISPLAYOFF); and back on display.ssd1306_command(SSD1306_DISPLAYON); I don't know how will it affect power consumption, thou
You have to send the wire.begin command, so copy the function and write the defaults value back then end with a wire.end command. If the library is reset it will reinitiate the correct conditions, bme.begin etc.
@@G6EJD I wrote function: void BME280_Wake(int device_address){ Wire.beginTransmission(device_address); Wire.write((uint8_t)0xF4); // Select Control Measurement Register Wire.write((uint8_t)0b00000011); Wire.endTransmission(); } after waking arduino can not read any data
@@G6EJD Thanks for help. I have found the solution: bits 2-7 of 0xF4 register are responsible for oversampling of temperature and pressure so in BME280_Wake function we shouldn't fill them with zero. Right filling of register for x1 oversampling: Wire.write((uint8_t)0b00100111);
@@elpavlo1666, if your cpu is in sleep mode then at wake the bme280 would be reset anyway, it seems your not pms I g the cpu into sleep mode. Good to hear you have a solution. The data sheet is your friend.
If your supplying the board with 5v then the on-board regulator dissipates heat that warms the sensor via conduction down pcb tracks, try powering the board from 3.3v and don’t run the gas sensor heater for too long as that has the effect of heating the temperature sensor or take a temperature reading before a gas reading
Yes thank you for asking, my voice is still croaky, but slowly getting better, thankfully my oral graft-versus-host disease is now abating and I barely notice it's still there. Still in lock-down as I have no immune system, likely to be like this for the next 3-4 months, but I'm used to it now, best regards
Only thought of putting the MCU into sleep mode, never thought of the sensors. Thank you for posting. Bob
Yeah, with sensors that use heaters (like gas sensors) it's an obvious thing to think about, but I had never thought to do it with BME280s.
I currently use the TCA9548A board to two BME280 sensors with one ESP8266. In the near future I will be saying ‘use to use a TCA9548A board....”. This is the first video or web site that demonstrates how to change the address on the generic BME280. Thank you.
Getting blood out of a BME280 stone!
This is very useful, thanks David.
Once again you provide extremely useful piece of information. Thank you.
Cheers mate! I remember reading something about sleep in the BME280 datasheet but I never bothered to implement it. Now I will :D
Thanks for taking the time to share this.
I'd been playing with a BME280 breakout board for a few months on and off and just hooked it up from the pinout, never bothering to look at the datasheet (in a effort to just get something working, aka no patience).
Now I'm reviewing the code and looking to introduce power saving, I'd never have thought to sleep the BME - I've the datasheet downloaded now. Lesson learned :)
A note about the sample code you used at 0:55. You are doing two reads to take an average. The sensor can do that for you by adjusting the oversampling parameters. Oversampling makes it possible to reduce the noise in the measurements, section 3.4 of the data sheet.
Hi, l I think you missed that one reading is bme1.readtemperature and the other bme2.readtemperature, the example shows how to take a reading from two different devices at different addresses.
@@G6EJD Ah yes. Sorry about that.
Gracias capo de la vida! Me solucionaste la existencia diciendome que hay que conectar SDO-VCC para obtener la adress 0x77 en el BME280. En todos lados leia que habia que conectar SDO a GND y no me funcionaba. Perdí muchas horas hasta que encontré tu video y ya tengo funcionando 2 BME280: uno en 0x76 y el otro en 0x77. Buena vida bro
I updated one of my outdoor temperature sensors with a BMP280, and as you predicted, power usage is noticeably less. As I monitor the voltage of the LiFePO4 battery, I can tell from the graph the slope downward is not even enough to imagine a sled to move on it's own downhill, where before your suggested force to sleep it was steep, especially when the battery was freshly charged. Like many people I just believed the datasheet ( i.e. that the module would go into sleep mode automatically), the facts prove otherwise. Thanks!
Yes, the data sheet says when in forced mode the normal setting it returns to sleep when in fact it returns to some quiescent state that is not sleep, when set to sleep it definitely sleeps, the savings are worth it for battery powered operation. Good to hear it works for you.
@@G6EJD Hi please see batteryusage graph of one of my BMP280 temperature sensors. I added the sleepmode on June 20th. It looks like power usage is reduced by an order of magnitude: See this graph: 1drv.ms/u/s!AmouwiVw2cl-dFin_9cVlVDhoi0?e=MSpMiZ
@@peut yes a definite improvement which makes a significant difference when using batteries
The two most popular BME280 libraries are from Adafruit and Sparkfun. Both these libraries try to be generic enough for all possible use cases. Being generic, they are not very optimized for various things. For example in the Sparkfun library, registers are read one at at time vs instead of burst as recommended in the data sheet on page 23, section "4 Data read out". The Adafruit library will call readTemperature in both readPressure and read readHumidity because the latter two depend on the temperature. So in the sample sketch above, in each loop, the temperature is read 6 times. In a battery operated temperature sensor running on a super low power micro controller, you want to spend as little time awake. Awake the microcontroller, take a reading as fast as possible, determine if it should be sent (serial / RF / etc) and get back to sleep as soon as possible. Typically you will wake every 60 seconds. To be clear, the quality of the Adafruit and Sparkfun libraries are really great and they are designed to allow the user to fall into the pit of success. I have been working on an optimized BME280 library for only weather sensing (60 second forced read samples, 1x temperature, 1x humdity, 1x presssure over sample, no filter) as recommended in section "3.5 Recommended modes of operation" in the data sheet. I hope to have the code up on github later this summer once I have tested it against multiple of my BME280 boards.
Phil, hopefully you will include a specific sleep mode or ensure in forced mode it does indeed return to sleep, the Adafruit implementation of forced mode does not return to sleep mode, maybe because of over reading or simplification. Over-writing of the F4 register could easily be resolved by just clearing bits 0 and 1, I suppose I could have implemented it that way, but as long as the library initialises the device it does not matter how sleep is achieved. I look forward to seeing your library. When all said, I do side with Adafruit’s approach to coding the library if it enables the majority of readers to quickly understand what’s going on, since the Arduino (est) community is mainly about learning just enough to get something working. I’m reminded of my university tutor teaching not to over use Karnaugh map ‘simplification’ as it makes future reading or understanding near impossible, he was mainly referring to the future maintenance of the design, they were wise words.
@@G6EJD I just pushed my work "in progress" code to my github account, pbolduc/bme280-for-weather. Like I said, it is very opinionated. One area I dont like is that I have observed it takes between 8 - 9.3 milliseconds to complete the read. I dont like that I have to sleep / block for the entire time. I dont think on the Motieno micro controller I am using I can deep sleep the processor during that time. Maybe it doesn't matter?
Thank you for sharing, excellent and to the point
As usual great info Dave, thanks.
Be aware that writing 0b00000000 to the ctrl_meas (0xF4) also over writes the temperature and pressure over sampling bits. You will have to reset those bits if you want to get any readings (humidity depends on temperature reading) when using a forced read. If you are using the BME280 for weather sampling and using the recommended over sampling settings from the data sheet, 1x temp and 1x pressure, you would set 0x00100100 to set to sleep, and 0x00100101 for forced read. You do not need to write sleep after a forced read as the state transitions back to sleep automatically, see page 15 of the data sheet.
Yes agreed, I’m relying on the Adafruit library to set the device into the correct conditions for reading or indeed any other library, as I’ve yet to see any library that can enable the device to be explicitly set to sleep. Forced mode says it returns to sleep but that’s not my experience and power demands stays relatively high.
@@G6EJD Interesting about the power usage in your testing. I will have try using my Current Ranger to verify your observations.
@@pbolduc Looking forward to your results.
@@pbolduc, I'd be interested in your validation of my results. Also if your into minimising power consumption, I'm surprised your don't already know what your getting in sleep mode power consumption, I would not be surprised if your getting ~500uA as I have yet to see a driver that achieves sleep mode after a read, most leave the device in forced read mode and hence the ~500uA consumption level. Despite what the data sheet says, the BME280 does not go back to sleep in that mode.
It works very well! Thanks David. Tried and implemented in my code!
Excellent video David, I was searching your videos to see if you covered this very topic yesterday... What do you think of powering the BME280 with a GPIO and turning that off during sleep - I think GPIOs turn off anyway during sleep? I'm experimenting with that and a 5ms power up delay before I take readings.
Yes it’s a good idea, never tried it, but it should work, the only doubt I have is the gpio output impedance which might be too high for the bme280 to start correctly, but I notice it’s power supply rejection ratio is very high, so should be ok, maximum ESP32 gpio pin source current is 40mA, so swell within range, maximum power requirement is 0.714mA. Startup delay can be 2mS before taking a reading. Yes when the ESP32 goes to sleep all the gpio pins are released and go tri-state, but if required you can enable the pins in sleep mode, lots to experiment with😀
It's working fine on an ESP8266 (One GPIO for sensor VCC, another one for GND)
Thank you for this information! I want to create a simple weather station powered by batterie and solar panel and this bits of precise informations help a lot!
This helps but it’s your cpu awake time that really matters, the shorter the better
Hi, i have 2 unbranded i2c modules, i can't change the address, i can't see the bridge but tried to cut anyway, the first 2 contacts tested for continuity with gnd always beeps, if i solder the center and last one the modules (i tried both) overheats beyound being touchable and does not show if scanned, i also tried to power it via 3,3v instead of 5v and it gets less hot, barely touchable without burning a finger, but it does not show up, maybe is a defective batch?
Sounds like erroneous devices, the track is very fine.
But why is the sleep mode 'better' than the force mode? As I understand the datasheet, the BME goes into sleep mode after taking one measurement in force mode anyway.
Try and see! You will find a significant drop in power consumption by doing what I suggest, it does not enter sleep.
Very nice sir I have a question that although bme28 is most popular sensor but which sensor would you recommend for commercial product development from project to final product release because as we know BME 280 sensor having self heating issue which gives unreliable readings . May I use HDC1080 sensor for iot product development or go for something else???
Well self-heating is caused by the sensor being left in continuous reading mode although in terms of heating energy it’s only 1.6mW so not much and very much less than the ambient heat, so should be negligible. I’ve never experienced self heating because I only use the 3.3v sensor with no regulator. If your using the smaller unbranded board or any carrier board with a regulator then it will dissipate (5 - 3.3)x0.5= 3.35mW which can get conducted down pcb tracks to the device.
Now if you were referring to the BME680 where self heating is a definite problem because the sensor for gas has to be heated to 220°C and this can affect temperature reading accuracy, the solution is to not read temperature at the same time as gas and separate the readings by many minutes and by placing the device into sleep mode during readings, so wake take a temperature and humidity reading then sleep them take a gas reading then sleep and repeat is how I do it. Adding another sensor adds to cost.
I’d still recommend the bme280 just change it’s use case
@@G6EJD thank you sir for guidance and how I can improve or get accurate temperature and humidity readings because ds18b20 gives verry accurate reading when i compared with BME 280 unbranded 3.3 sensor module. Bme 280 gives 2-3 ° degrees more readings so should I correct at programming side or which approach would you recommend for accuracy
Hello Dave. Is it possible to make sleep DHT22 also? And can we achieve that?
Many thanks.
Marc :)
Unfortunately that device does not support a specific sleep mode, but in standby (no reading taking place) it consumes just 50uA so with a Lolin D32 taking 77uA plus 50uA a total of 127uA isn’t too bad for battery use. Other ESP32 boards won’t be anywhere near as good though.
Thanks David for nice instructions. Been playing with BME280 for more than a year, never been able to get IAQ readings to be accurate as well as temperature. (Usually temperature indicates about 2 - 2.5C° higher to actual). Maybe sleep mode can sort it, will try. Thanks again!
You really need to use the device at 3.3v meaning a device with no on-board regulator and if it has an on-board regulator it should still work at 3.3v, so I recommend checking the supply voltage is well within specification (3.65v max) and yes sleep mode will help, but at 3.3x0.5mA=1.65mW it’s just not enough energy to hear the device and ambient conditions will always control its temperature. Is there any conduction down pcb tracks from say a cpu / regulator that is causing the temperature skewing - its much more likely to be the cause.
@@G6EJD Sorry, David, my bad, you are about BME280, but I wasn't awake enough and my brain did a trick - I thought it's about BME680. You are absolutely right, no issues with BME280, been using avail ago successfully.
Same problems with the bme680 take a temperature reading before a gas reading and power the board with 3.3v
@@G6EJD , I am using lua and there is no options in a library to read "temperature only" - it takes readings automatically each couple of seconds.
hi can u help me do a video review for 2021 new upgraded digital multimeter ,it is multi functional and like a cellphone
Dear Mr David, thanks very much for the note, very useful indeed. In my project I also have an Adafruit_SSD1306 display. Is there a similar way to put it to sleep? Thanks.
IF you mean the display, no, but if you clear the display (to all black) then that will make a big difference to power consumption.
Using adafruit lib you can turn it off using
display.ssd1306_command(SSD1306_DISPLAYOFF);
and back on
display.ssd1306_command(SSD1306_DISPLAYON);
I don't know how will it affect power consumption, thou
Hello. How can I switch back to normal mode? " Wire.write((uint8_t)0b00000011); " does not work. Thanks.
You have to send the wire.begin command, so copy the function and write the defaults value back then end with a wire.end command. If the library is reset it will reinitiate the correct conditions, bme.begin etc.
@@G6EJD I wrote function:
void BME280_Wake(int device_address){
Wire.beginTransmission(device_address);
Wire.write((uint8_t)0xF4); // Select Control Measurement Register
Wire.write((uint8_t)0b00000011);
Wire.endTransmission();
}
after waking arduino can not read any data
@@elpavlo1666 try looking at the Adafruit bme280 library on github they use
write8(BME280_REGISTER_SOFTRESET, 0xB6);
To reset the device
@@G6EJD Thanks for help. I have found the solution: bits 2-7 of 0xF4 register are responsible for oversampling of temperature and pressure so in BME280_Wake function we shouldn't fill them with zero. Right filling of register for x1 oversampling:
Wire.write((uint8_t)0b00100111);
@@elpavlo1666, if your cpu is in sleep mode then at wake the bme280 would be reset anyway, it seems your not pms I g the cpu into sleep mode. Good to hear you have a solution. The data sheet is your friend.
I have the red unbranded board and the adafruit's bme680 board. I think that those sensors reads a bit too high temps. Anyone else with this problem?
If your supplying the board with 5v then the on-board regulator dissipates heat that warms the sensor via conduction down pcb tracks, try powering the board from 3.3v and don’t run the gas sensor heater for too long as that has the effect of heating the temperature sensor or take a temperature reading before a gas reading
Thanks Dave, everything ok with yourself too?
Yes thank you for asking, my voice is still croaky, but slowly getting better, thankfully my oral graft-versus-host disease is now abating and I barely notice it's still there. Still in lock-down as I have no immune system, likely to be like this for the next 3-4 months, but I'm used to it now, best regards
@@G6EJD Good to hear more and more improvement. Not easy in lock-down for so long time , it's the same overhear, but stay safe.