Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 sample/minute? #23

Closed
swilsonnc opened this issue Apr 1, 2017 · 15 comments
Closed

1 sample/minute? #23

swilsonnc opened this issue Apr 1, 2017 · 15 comments

Comments

@swilsonnc
Copy link

Shouldn't this line in BME280_Modes.ino read 1 sample/second or is it really 1 minute? I am using this mode and seeing 1 sample/second.

//BME280I2C bme; // Weather Monitoring : forced mode, 1 sample/minute

@swilsonnc
Copy link
Author

swilsonnc commented Apr 1, 2017

To clarify. I understand that was based on the Bosch BME280 datasheet because this conflicts.

BME280I2C bme; // Default : forced mode, standby time = 1000 ms
// pressure ×1, temperature ×1, humidity ×1, filter off

/* Based on Bosch BME280I2C environmental sensor data sheet. */

//BME280I2C bme; // Weather Monitoring : forced mode, 1 sample/minute

I guess I am curious how to really get 1 sample/minute using this library.

@kvoit
Copy link

kvoit commented Apr 26, 2017

I guess I am curious how to really get 1 sample/minute using this library.

The BME280 starts in the suggested settings for weather monitoring, which is forced mode without filter and oversampling.
In forced mode it is your job to perform one measurement per minute (or e.g. per second for the following humidity sensing example). So, put one measurement per minute into your Arduino loop.
There is no register setting to give the BME a 60000ms standby time. Longest standby in normal mode is one second.

A new reading is triggered by enabling the forced mode again. After the reading, the sensor will go to sleep by itself. The read function of the library does enable forced mode by itself, reads the registers immediately afterwards, so I THINK if will return the values from the last reading. Might not be important when reading every 500ms, but for a sensor that reads once per hour, it certainly matters.

@whatsupskip
Copy link

I am trying to understand how this relates to the self heating issue the BME280 suffers from. This is mentioned here (http://www.esp8266.com/viewtopic.php?f=13&t=8030&start=28) and here (https://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_many.html).

I have been trying to adjust the code in this project (https://www.hackster.io/s-wilson/nodemcu-home-weather-station-with-websocket-7c77a3) to solve the problem with the self heating, but I am having no luck.

@swilsonnc
Copy link
Author

The chip itself takes a sample every second when you use BME280I2C bme; in your code. If you choose 1 minute in your loop it doesn't change the fact that the chip is still sampling every second. What we are trying to accomplish here is to have the chip sample slower than every 1 second to combat overheating. So far with this library I don't know how that can be done and that is what I am trying to figure out.

@whatsupskip
Copy link

Thanks for clarifying.

Are the suggested changes made to the ADAFruit code of any assistance?
(http://www.esp8266.com/viewtopic.php?f=13&t=8030&start=28)

@swilsonnc
Copy link
Author

Looking at the library in bme280.h I saw this.

public:
/* ==== Constructor used to create the class. All parameters have default values. ==== */
BME280(uint8_t tosr = 0x1, uint8_t hosr = 0x1, uint8_t posr = 0x1, uint8_t mode = 0x1,
uint8_t st = 0x5, uint8_t filter = 0x0, bool spiEnable = false); // Oversampling = 1, mode = forced, standby time = 1000ms, filter = none.

The uint8_t St = 0x5 could actually mean 5ms. Wonder if we change it to say 0x5000 if it would change the rate to 5 sec for example. Won't get a chance to try it for a few days.

@kvoit
Copy link

kvoit commented May 1, 2017

The datasheet says in section 5.3.2 that sleep mode is the default mode. So
BME280I2C bme; should NOT cause a update every second in the chip. Rather, the function of this library set the chip to forced mode, which takes one sample and then goes back to sleep mode.

The uint8_t St = 0x5 could actually mean 5ms. Wonder if we change it to say 0x5000 if it would change the rate to 5 sec for example. Won't get a chance to try it for a few days.

0x5 is HEX for b101 (BIN). It doesn't make any sense to change this to 0x5000, which would be 20480 in decimal. Rather, looking at the datasheet b101 means 1000ms sleep time according to table 27. This is the highest standby time offered by the sensor. If you want to sample more often, you need to do it by setting forced mode manually in that interval, I think.

I don't really understand what your issue is. This library directly passes the values to the register, which are very clearly documented in the datasheet.

I ran this directly next to a DHT22 with one sampling per hour, and the values are read identical to .1°C.

@finitespace
Copy link
Owner

finitespace commented May 1, 2017

The library starts the sensor in forced mode. These issues are only valid in normal mode. Standby time is only used in normal mode. In forced mode, the sensor takes a measurement when the command is sent to the sensor. Any overheating in forced mode would be a result of how often you, the user, issue the read command.

For further clarification, here is what the datasheet says on this matter:

5.3.3 Forced mode
In forced mode, a single measurement is performed in accordance to the selected measurement and filter options. When the measurement is finished, the sensor returns to sleep mode and the measurement results can be obtained from the data registers. For a next measurement, forced mode needs to be selected again. This is similar to BMP180 operation. Using forced mode is recommended for applications which require low sampling rate or host- based synchronization.

5.3.4 Normal mode
Normal mode comprises an automated perpetual cycling between an (active) measurement period and an (inactive) standby period.
The measurements are performed in accordance to the selected measurement and filter options. The standby time is determined by the setting t_sb[2:0] and can be set to between 0.5 and 1000 ms according to Table 27.
The total cycle time depends on the sum of the active time (see chapter 11) and standby time tstandby. The current in the standby period (IDDSB) is slightly higher than in sleep mode. After setting the measurement and filter options and enabling normal mode, the last measurement results can always be obtained at the data registers without the need of further write accesses. Using normal mode is recommended when using the IIR filter. This is useful for applications in which short-term disturbances (e.g. blowing into the sensor) should be filtered.

Tyler

@swilsonnc
Copy link
Author

swilsonnc commented May 1, 2017 via email

@whatsupskip
Copy link

whatsupskip commented May 3, 2017

I have done some more testing. I found one major factor with the heating problem was not the BME280 itself, but heating or interference from the NodeMCU ESP8266. The BME280 was about 15 to 20mm horizontally from the antenna of the ESP8266. I have relocated it around 100mm from the ESP8266.

I was having major heating problems with more than 2°C.

I have now increased the sampling time on the BME280 to 15 seconds. With these two changes have now have the BME280 reading within 0.5°C of a AM2302 module. The testing conditions for this are far from ideal, so the result might be even better.

@kvoit
Copy link

kvoit commented May 3, 2017

I can confirm this. An ESP8266 has massive influence on temperature in direct vicinity to the sensor. I don't think it has to do with the antenna. It just gets quite warm.

@whatsupskip
Copy link

I was just very surprised it would have such an impact when it was on the same plane (horizontal) from the ESP8266. I can understand if it was vertically above or in an enclosed space. That is why I was wondering if the were some induced currents. I will need to do more testing.

@kvoit
Copy link

kvoit commented May 3, 2017

I had the exact same issues with a DHT22, AFAIR horizontally next to a Wemos D1 Mini, mounted vertically on a wall without enclosure.

@idesignstuff
Copy link

idesignstuff commented May 3, 2017 via email

@kvoit
Copy link

kvoit commented May 3, 2017

Sure. If your ESP is doing nothing else. In my case, however, the device also reacts to MQTT messages to control the lighting.
If you are JUST measuring, you can turn of the whole ESP. I have one of those running in the wine cellar, taking a measurement once an hour, powered by a 18650 LiPo with about 2000mAh. From the voltage curve, I expect between 6 and 12 MONTH runtime. (It has been running for 1 month now, and the tendency of the voltage is quite clear.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants