Author Topic: Help with possible I2C interfarencde  (Read 1114 times)

0 Members and 1 Guest are viewing this topic.

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Help with possible I2C interfarencde
« on: July 13, 2020, 03:31:08 am »
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.
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #1 on: July 13, 2020, 03:44:15 am »
Are you following the mounting recommendations (Section 5, https://www.bosch-sensortec.com/media/boschsensortec/downloads/handling_soldering_mounting_instructions/bst-bme280-hs006.pdf

Can you provide a picture / schematic?
- Invest in science - it pays big dividends. -
 

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #2 on: July 13, 2020, 04:22:05 pm »
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.44
temperature=76.69,humidity=45.2,altitude=242.24,pressure=1004.41
temperature=76.60,humidity=45.1,altitude=241.39,pressure=1004.44
temperature=76.60,humidity=45.0,altitude=242.92,pressure=1004.39
temperature=76.60,humidity=44.9,altitude=241.68,pressure=1004.43
temperature=76.68,humidity=45.0,altitude=242.57,pressure=1004.40
temperature=76.71,humidity=44.8,altitude=242.72,pressure=1004.40
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98
temperature=-225.24,humidity=100.0,altitude=-4277.97,pressure=1179.98

 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #3 on: July 13, 2020, 04:49:17 pm »
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 resolution

Still 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.
- Invest in science - it pays big dividends. -
 

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #4 on: July 13, 2020, 06:13:50 pm »
At present the sensor is pulled away about an inch (see attachment), and is being sampled once per minute: (see https://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.
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #5 on: July 13, 2020, 06:26:23 pm »
At present the sensor is pulled away about an inch (see attachment), and is being sampled once per minute: (see https://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.

Hmmm 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.
- Invest in science - it pays big dividends. -
 

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #6 on: July 13, 2020, 06:35:54 pm »
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.
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #7 on: July 13, 2020, 06:38:35 pm »
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.

Well, you're welcome although I'm not sure it was of much help. Please let us know what happens / how it turns out.
- Invest in science - it pays big dividends. -
 

Offline Twoflower

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: de
Re: Help with possible I2C interfarencde
« Reply #8 on: July 13, 2020, 06:40:23 pm »
Do you use the mandatory pull-up resistors on SCL and SDA?
 

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #9 on: July 13, 2020, 06:48:08 pm »
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.
« Last Edit: July 13, 2020, 06:59:00 pm by cmumford »
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #10 on: July 13, 2020, 07:03:06 pm »
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.

The schematic on your link shows 10K pullups.
- Invest in science - it pays big dividends. -
 

Offline Twoflower

  • Frequent Contributor
  • **
  • Posts: 742
  • Country: de
Re: Help with possible I2C interfarencde
« Reply #11 on: July 13, 2020, 07:18:25 pm »
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.
 

Online mikerj

  • Super Contributor
  • ***
  • Posts: 3318
  • Country: gb
Re: Help with possible I2C interfarencde
« Reply #12 on: July 13, 2020, 08:15:17 pm »
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.
 

Offline cmumfordTopic starter

  • Contributor
  • Posts: 44
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #13 on: July 13, 2020, 09:40:57 pm »
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.
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Help with possible I2C interfarencde
« Reply #14 on: July 13, 2020, 09:49:20 pm »
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.
- Invest in science - it pays big dividends. -
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf