TCA9548a Multiplexer with multiple (qty 6) BME280's

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ViktorArmani
 
Posts: 6
Joined: Wed Jan 20, 2016 7:34 pm

TCA9548a Multiplexer with multiple (qty 6) BME280's

Post by ViktorArmani »

To whom it may concern,
I'm trying to connect multiple (Qty 6) BME280 sensors to a TCA9548a multiplexer and having some issues. The aim is to have the ability to output all the temperatures, humidity and pressures from each sensor simultaneous, with basic x-y graph/s. I've tried the adafruit tca9458a document, still have issues. I've tried other examples, with no success. Any help will be appreciated.
Regards,
Viktor

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: TCA9548a Multiplexer with multiple (qty 6) BME280's

Post by Franklin97355 »

What code are you using and what are you getting for results?

User avatar
ViktorArmani
 
Posts: 6
Joined: Wed Jan 20, 2016 7:34 pm

Re: TCA9548a Multiplexer with multiple (qty 6) BME280's

Post by ViktorArmani »

ok
Last edited by ViktorArmani on Mon Jan 30, 2017 5:39 pm, edited 3 times in total.

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: TCA9548a Multiplexer with multiple (qty 6) BME280's

Post by Franklin97355 »

That code has too many parts combined and would not compile. Please make sure that you post the exact code you are using

User avatar
ViktorArmani
 
Posts: 6
Joined: Wed Jan 20, 2016 7:34 pm

Re: TCA9548a Multiplexer with multiple (qty 6) BME280's

Post by ViktorArmani »

The following code was from georgeklinger forum page, added the humidity reading, however, when i run the i2cscanner it doesn't pick up the other sensor. At the moment i only have two sensors connected to the TCA9548a multiplexer (see image). I'm aiming to get up to 6 connected.

Code: Select all

/**
 * TCA9548 I2CScanner.pde -- I2C bus scanner for Arduino
 *
 * Based on code c. 2009, Tod E. Kurt, http://todbot.com/blog/
 *
 */

#include "Wire.h"
extern "C" { 
#include "utility/twi.h"  // from Wire library, so we can do bus scanning
}
#include <Wire.h>
#include <Adafruit_BME280.h>
#include <Adafruit_Sensor.h>

#define TCAADDR 0x70
Adafruit_BME280 bmp[8]; // I2C

boolean portarray[8] = {true, true, true, true, true, true, true, true};
float temperature[8];
float humidity [8];
float pressure[8];
uint8_t j;
void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}

void setup(void) 
{
    while (!Serial);
    Wire.begin();
    Serial.begin(9600);
    Serial.println("\nTCAScanner ready!");
    
    for (uint8_t t=0; t<8; t++) {
      tcaselect(t);
      Serial.print("TCA Port #"); Serial.println(t);

      for (uint8_t addr = 0; addr<=127; addr++) {
        if (addr == TCAADDR) continue;
      
        uint8_t data;
        if (! twi_writeTo(addr, &data, 0, 1, 1)) {
           Serial.print("Found I2C 0x");  Serial.println(addr, HEX);
        }
      }
    }
    Serial.println("\ndone");
    delay(2000);

    Serial.println("BMP280 Multiplex Initialization"); Serial.println("");
    for (uint8_t port = 0; port<=7; port++) {
      tcaselect(port);
      if(!bmp[port].begin()){
        Serial.print("No BMP280 detected at port ");Serial.println(port);
        portarray[port] = false;
      }
    }
}

void loop(void) 
{
  for (j = 0; j<=7; j++) {
    if (portarray[j]) {
      tcaselect(j);
      temperature[j] = bmp[j].readTemperature();
      humidity[j] = bmp[j].readHumidity();
      pressure[j] = bmp[j].readPressure();    
      Serial.print("Port "); Serial.print(j);
      Serial.print(" Temperature = ");
      Serial.print(temperature[j]);
      Serial.println(" C");
      Serial.print("Port "); Serial.print(j);
      Serial.print(" Humidity = ");
      Serial.print(humidity[j]);
      Serial.println(" %");
      Serial.print("Port "); Serial.print(j);
      Serial.print(" Pressure = ");
      Serial.print(pressure[j]);
      Serial.println(" Pa");
      Serial.println("");
      delay(1650);
    }
  }
}
Attachments
Untitled.gif
Untitled.gif (175.61 KiB) Viewed 866 times
Last edited by Franklin97355 on Tue Jan 24, 2017 9:00 pm, edited 1 time in total.
Reason: Please use [code] tags when posting code or logs to the forums by clicking the </> button above the reply box and pasting your code between the tags created.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”