Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Help needed: Adafruit Multiplexor and 4 Sparkfun VEML6075s
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help needed: Adafruit Multiplexor and 4 Sparkfun VEML6075s

by coenhird on Tue Aug 11, 2020 1:44 am

Complete noob here, first time trying to use Arduino - I'm trying to make a UV data logger for a uni project and I'm way out in the deep end!

I am having trouble successfully finding/connecting to a few sparkfun VEML6075 UV sensor breakout's that I'm wanting to read values from.

I have the VEML6075s connected to SD/SC ports 0, 3, 5, and 7 on the Adafuit TCA9548A multiplexer, When plugged in all UV senors are lighting up and appear to be connected properly. However, upon running the code below, it prints:

Failed to communicate with VEML6075 sensor2, check wiring


The other sensors all read the same error message. I'm interested to know if this is likely a fault of my wiring, or if my code is incorrect. I noticed somebody else had literally the exact same problem (adafruit multiplexor and 4 sparkfun VEML6075s) in February but there was no solution. If anybody could offer some advice I would greatly appreciate it!

Here's my code:
Code: Select all | TOGGLE FULL SIZE
#include <SparkFun_VEML6075_Arduino_Library.h>
#include <Adafruit_Sensor.h>
#include "Wire.h"
#define TCAADDR 0x70

/* Assign a unique ID to the sensors*/
VEML6075 uv1 = VEML6075();
VEML6075 uv2 = VEML6075();
VEML6075 uv3 = VEML6075();
VEML6075 uv4 = VEML6075();

/* Set up the 8 ports on multiplexor */
void tcaselect(uint8_t i) {
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission(); 
}

void setup(void) 
 {
  Wire.begin();
  Serial.begin(9600);

    /* Initialise the 1st sensor */
  tcaselect(0);
if(! uv1.begin())
{
    // There was a problem detecting the VEML6075 ... check your connections
    Serial.println("Failed to communicate with VEML6075 sensor1, check wiring?");
    while(1);
  }
    /* Initialise the 2nd sensor */
  tcaselect(2);
  if(! uv2.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Failed to communicate with VEML6075 sensor2, check wiring?");
    while(1);
  }
   /* Initialise the 3rd sensor */
  tcaselect(4);
  if(! uv3.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Failed to communicate with VEML6075 sensor2, check wiring?");
    while(1);
  }
   /* Initialise the 4th sensor */
  tcaselect(6);
  if(! uv4.begin())
  {
    /* There was a problem detecting the HMC5883 ... check your connections */
    Serial.println("Failed to communicate with VEML6075 sensor2, check wiring?");
    while(1);
  }
}

void loop() {
  static unsigned int numReadings = 1;
  static boolean powerOnState = true;
  const unsigned int READINGS_BETWEEN_SHUTDOWN = 50; // take 50 readings before shutdown?
 
  if ((numReadings % READINGS_BETWEEN_SHUTDOWN) == 0) {
    if (powerOnState) {
      // Use shutdown to disable sensor readings. The sensor will consume less power in this state.
      uv1.shutdown();
      uv2.shutdown();
      uv3.shutdown();
      uv4.shutdown();
      Serial.println("Shut down");
      powerOnState = false;   
    } else {
      // Use powerOn to enable sensor readings.
      uv1.powerOn();
      uv2.powerOn();
      uv3.powerOn();
      uv4.powerOn();
      Serial.println("Power up!");
      powerOnState = true;
    }
  }

  /* Display the results */
tcaselect(0);
  Serial.print("Sensor #1 - ");
  Serial.print("Raw UVA reading:  "); Serial.println(uv1.rawUva());
  Serial.print("Raw UVB reading:  "); Serial.println(uv1.rawUvb());
tcaselect(2);
  Serial.print("Sensor #2 - ");
  Serial.print("Raw UVA reading:  "); Serial.println(uv2.rawUva());
  Serial.print("Raw UVB reading:  "); Serial.println(uv2.rawUvb());
tcaselect(4);
  Serial.print("Sensor #3 - ");
  Serial.print("Raw UVA reading:  "); Serial.println(uv3.rawUva());
  Serial.print("Raw UVB reading:  "); Serial.println(uv3.rawUvb());
tcaselect(6);
  Serial.print("Sensor #4 - ");
  Serial.print("Raw UVA reading:  "); Serial.println(uv4.rawUva());
  Serial.print("Raw UVB reading:  "); Serial.println(uv4.rawUvb());

  delay(100);
}

coenhird
 
Posts: 2
Joined: Thu Oct 03, 2019 7:00 pm

Re: Help needed: Adafruit Multiplexor and 4 Sparkfun VEML607

by adafruit_support_bill on Tue Aug 11, 2020 5:47 am

Please post some photos showing your soldering and connections.

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.