i2c multiple bmp280 question

Status
Not open for further replies.

linuxgeek

Well-known member
I've been using onehorse's BNO-055 breakout board, which also has a BMP280 pressure sensor.
https://www.tindie.com/products/onehorse/bno-055-9-axis-motion-sensor-with-hardware-sensor-fusion/

I also have some BMP280 breakout boards from Adafruit, and wanted to try using the more teensy-focused code from the one above.
https://learn.adafruit.com/adafruit...ure-plus-temperature-sensor-breakout/overview

I removed the bno-055 code from onehorse's demo sketch, and used it to read values from the Adafruit breakout board. Works great w/T3.2 & TLC.

Although the adafruit bmp280 board works well with teensy, should I be using 4.7k pullups for it? If so, where do I put those?

Ultimately, I want to be able to read from multiple Adafruit BMP280 breakout boards. Do I just need to wire them each up to SCL/SDA. I assume that each BMP280 will report the same address, so what should I do for that?
Do I hook them up separately and figure out how to write the address to each so that they are different?
 
If the address pin of each BMP280 is broken out, the standard approach is to set them all LOW (choosing address 0x76 IIRC) except for the one you want to read, set this ADO HIGH so its address is 0x77 and you can just go down the list of BMP280s one at a time toggling the ADO HIGH, reading I2C address 0x77 and so on.

If the address pin is not broken out (rarely is for a peripheral sensor) then use an I2C multiplexer like this one. It already has 4K7 resistors on each line.

Unless you have really long lines (or a whole lot of sensors) a single pair of 2K or 4K7 or even 10 K pullups on the main board should suffice. 4K7 is good for up to about seven separate I2C devices on the bus. More than this and you will have to go to 2K pullups to preserve the selected I2C speed.

The easy way to tell if you need pullups is measure the voltage on the SDA and SCL pins. If it isn't 3 or 3.3 V, you need pullups.
 
Thanks.

Sometimes I get 0x77 i2c address when running my sketch, and sometimes I get 0x58, and sometimes the USB serial println's don't come through while initializing. I imagine that a lack of resistors might be making it difficult to communicate.
Will try the voltage readings soon to see, once I get everything connected again. I'll have to get some of those i2c multiplexers too for trial.
 
Sometimes I get 0x77 i2c address when running my sketch, and sometimes I get 0x58, and sometimes the USB serial println's don't come through while initializing.

Might be a silly question.. do you have a delay() in setup() ?
Those I2C chips are often too slow, and need a longer time to "boot", ehm, start, than the Teensy.
The "not working" println indicates the same, a missing delay(). As a start, try something like delay(1500) - if that works, try shorter delays.
 
Last edited:
Might be a silly question.. do you have a delay() in setup() ?
Those I2C chips ware often too slow, and need a longer time to "boot", ehm, start, than the Teensy.
The "not working" println indicates the same, a missing delay(). As a start, try something like delay(1500) - if that works, try shorter delays.

Yeah, I thought of that and peppered a bunch of delays within, but it's possible I missed a spot. Often the USB serial would stop transmitting at address 38 (out of 127). I did put a delay in the for loop that iterates over the address numbers. I know it would get past setup though and start sampling during the loop, cause I would blink the led and I could capture over bluetooth.
I tried putting in some Serial.flush() as well. It does seem likely that I'm stepping over something tho (maybe Serial vs Serial1?). I'll clean it up and post it if anyone wants to take a look.
 
Indeed the Teensy boots faster than most Arduino hardware - though the ESP8266 is online in just over 200ms after power up too. I had a race not getting a pin set fast enough in Teensy and ESP went into my ESTOP mode until I adjusted setup.

Similar timing on other things likely - sometimes a warm restart on devices gives a false impression versus unplugging and plugging in on battery when It seems to fail. Not having the conditional on millis() in the while() is in some sketches that 'never start' on a battery.

I like this selective wait in setup:
Code:
  while (!Serial && (millis () <= 3000))
    ;
  Serial.println("Hello!");

If you want serial and have a monitor program on the port it will leave sooner - if you need a second to connect it - it will wait. Some things you want to start before that - pin setup etc - but devices after that to give them wake time.
 
Yeah, that could have something to do with it. I recently added on a rechargeable battery with a power switch, so I probably tend to power-cycle the unit more than before.

I'll try your selective wait in setup.
 
Status
Not open for further replies.
Back
Top