Help with possible I2C interfarencde - Page 1
Forum section: electronics / projects

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 03:31:08 am
content: Hi there:I'm working on a simple project with an ESP8266 (Arduino) talking to a BME280 (Thermometer) via I2C. It works fine on a breadboard, but when I stuff it into it's 3D printed case, which is quite small, I start having problems. I get readings from the BME280, but the values are wildly incorrect. I suspect EMI is the cause. I have 2" un-shielded wires inside the case. Does it sound like EMI might be the cause? If so, any advice would be appreciated. thx.

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 03:44:15 am
content: Are you following the mounting recommendations (Section 5,https://www.bosch-sensortec.com/media/boschsensortec/downloads/handling_soldering_mounting_instructions/bst-bme280-hs006.pdfCan you provide a picture / schematic?

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 04:22:05 pm
content: I don't have a schematic, but it's pretty simple, 3.3v, GND, SDA and SDC to the sensor. Attached is the breadboard photo (where it always works 100% of the time - for days), and the case, where it can sometimes work. Things seem to work better if I pull the sensor away from the case with as much wire as possible (sort of like the Case.png photo). When I stuff the wires in then the values start getting wonky. I just plugged it in and got 7 readings that were good, and then the sensor starts reading bad values.temperature=76.69,humidity=45.5,altitude=241.50,pressure=1004.44temperature=76.69,humidity=45.2,altitude=242.24,pressure=1004.41temperature=76.60,humidity=45.1,altitude=241.39,pressure=1004.44temperature=76.60,humidity=45.0,altitude=242.92,pressure=1004.39temperature=76.60,humidity=44.9,altitude=241.68,pressure=1004.43temperature=76.68,humidity=45.0,altitude=242.57,pressure=1004.40temperature=76.71,humidity=44.8,altitude=242.72,pressure=1004.40temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 04:49:17 pm
content: I am wondering if you are getting self-heating. Seven good temps and then it goes bad. Can you use an extra long delay (a couple of seconds) between readings and see if that makes a difference?From the referenced data sheet with the smartphone mounting example...The sensor should be not more than 10% in the active state to avoid self heating, please check the datasheet for more details how to minimize the power consumption at a particular resolutionStill can't tell how the sensor is mounted. If it is inside the case, I am wondering how you get valid measurements for RH with no air circulation. Apart from that, no pullup resistors? Are they on the BME board? I have a couple of those boards (BME280) and can't remember, but they worked fine for me when I tested them - so these are just some thoughts.

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 06:13:50 pm
content: At present the sensor is pulled away about an inch (see attachment), and is being sampled once per minute: (seehttps://github.com/cmumford/EnvironSensor/blob/master/EnvironSensor.ino). The sensor is definitely cool to the touch, but haven't measured its surface temperature. Yesterday it ran correctly for 90 min. before returning bad values.

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 06:26:23 pm
content: Quote from: cmumford on July 13, 2020, 06:13:50 pmHmmm I can't imagine 1/min is going to produce self-heating. I wonder if your sensor board or connections is intermittently bad, even though it works on the breadboard . Do you have another that you can try. I would also, again, look into the pull ups. Beyond that...if the sensor is working, if your power supply is stable and sufficient, your code solid - I just don't know.

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 06:35:54 pm
content: I've got three boards/sensors, and two of them do this. I think I'm going to remove things from the case, reattach, and do some experimentation. Thanks a bunch for your help - much appreciated.

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 06:38:35 pm
content: Quote from: cmumford on July 13, 2020, 06:35:54 pmWell, you're welcome although I'm not sure it was of much help. Please let us know what happens / how it turns out.

author: Twoflower
author_rank: Frequent Contributor
timestamp: July 13, 2020, 06:40:23 pm
content: Do you use the mandatory pull-up resistors on SCL and SDA?

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 06:48:08 pm
content: I didn't add one. Would this be part of the developer board (https://smile.amazon.com/gp/product/B07KYJNFMD) or something I need to add myself?Edit: Looking on the schematic (on Amazon link) this is provided by the dev board.

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 07:03:06 pm
content: Quote from: cmumford on July 13, 2020, 06:48:08 pmThe schematic on your link shows 10K pullups.

author: Twoflower
author_rank: Frequent Contributor
timestamp: July 13, 2020, 07:18:25 pm
content: Yes, and also the LDO and level-shifting circuit should not be a problem.At which speed do you run the I2C? Have you tried to run it slower? Otherwise I would check the nature of the problem (HW or SW). That the sensor-readings seem to stuck at a max-level (225F) could indicate that the sensor I2C state-machine get's messed up. So can you just power-cycle the sensor-board after that happens (of course you might to configure the sensor)? Does the problem goes away? That could indicate to EMI issues.

author: mikerj
author_rank: Super Contributor
timestamp: July 13, 2020, 08:15:17 pm
content: Sounds like the BME280 is leaving SDA pin pulled low, which means the master can't even assert a stop condition on the bus. On many I2C slave devices this situation can be recovered by toggling the SCL pin until the SDA pin goes high (up to 9 clock cycles), but better to find the cause.IMO there is a strong possibility that you have some marginal timing, but you really need to scope to check this. Failing that my suggestion would be to try increasing the strength of the pullups (1k or so) and/or maybe reduce the I2C clock speed.

author: cmumford
author_rank: Contributor
timestamp: July 13, 2020, 09:40:57 pm
content: Thanks everyone. Arduino defaults to 100K bus speed, but can be changed (sometimes slower) depending on the chip. I'll try that first. I do have a DS1054Z, and will connect it once I have the board pulled from the case. Thanks again for the assistance.

author: DrG
author_rank: Super Contributor
timestamp: July 13, 2020, 09:49:20 pm
content: I am anxious to see what happens. If you read the comments on those boards, there are some that suggest that some were pretty low quality, including ones that were likely BMP rather than BME - something I have also seen on boards from the bay, although I don't think that particular situation is the case with the OP.That 1/3 work and sometimes the bad ones work for as long as 90 min smells bad as a product. Yeah maybe something marginal.One last thing. If you are primarily interested in ambient temperature or if ambient temperature is a main need, I would not use that sensor. If I remember correctly it is a die temperature and not advertised as being ambient temperature.