Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

My class is designing an experiment to measure UV radiation at high altitude. We need to use 3 UV sensors. We originally wired 3 LTR390 sensors we sourced from Waveshare to a TDA9548A mutiplexer and used the code included below to get readings from all 3 sensors. For logistical reasons, we had to switch to the Adafruit LTR390 sensors. Since we made the switch, none of our code executes. I am including links to the various components and our wiring diagram. Any advice would be appreciated.

TDA 9548A multiplexer https://learn.adafruit.com/adafruit-tca ... t/overview
new Adafruit sensor https://learn.adafruit.com/adafruit-ltr ... or/arduino
old Waveshare sensor https://www.waveshare.com/uv-sensor-c.htm
Wiring Diagram:
https://drive.google.com/open?id=1KysMp ... drive_copy
The Arduino code:

Code: Select all

//program to use the tda9485 multiplexer to use 3 I2C UV sensors


#include "Adafruit_LTR390.h"  //UV sensor Library


#include "Wire.h"


#define TCAADDR 0x70


Adafruit_LTR390 ltr_plastic = Adafruit_LTR390(); //The LTR 390 UV sensor variables
Adafruit_LTR390 ltr_paper = Adafruit_LTR390();
Adafruit_LTR390 ltr_mylar = Adafruit_LTR390();


void tcaselect(uint8_t i) {
  if (i > 7) return;
 
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();  
}
void setup() {
  Wire.begin();
 
  Serial.begin(115200); //date transfer rate
 
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;


        Wire.beginTransmission(addr);
        if (!Wire.endTransmission()) {
          Serial.print("Found I2C 0x");  Serial.println(addr,HEX);
        }
      }
    }
    Serial.println("\ndone");
 tcaselect(1);
  if ( ! ltr_plastic.begin() ) { //if the sensor is not found, report couldn't find
    Serial.println("Couldn't find LTR plastic sensor!");
   
  }
  
 tcaselect(2);
  if ( ! ltr_paper.begin() ) { //if the sensor is not found, report couldn't find
    Serial.println("Couldn't find LTR paper sensor!");
   
  }
  

tcaselect(7);
  if ( ! ltr_mylar.begin() ) { //if the sensor is not found, report couldn't find
    Serial.println("Couldn't find LTR mylar sensor!");
   
  }
  



tcaselect(2);
  ltr_paper.setMode(LTR390_MODE_UVS);  //sets the UV Sensor to UV mode
  if (ltr_paper.getMode() == LTR390_MODE_ALS) {
    Serial.println("LTR Paper In ALS mode");
  } else {
    Serial.println("LTR Paper In UVS mode");
  }

tcaselect(1);
ltr_plastic.setMode(LTR390_MODE_UVS);  //sets the UV Sensor to UV mode
  if (ltr_plastic.getMode() == LTR390_MODE_ALS) {
    Serial.println("LTR Plastic In ALS mode");
  } else {
    Serial.println("LTR Plastic In UVS mode");
  }  



tcaselect(7);
ltr_mylar.setMode(LTR390_MODE_UVS);  //sets the UV Sensor to UV mode
  if (ltr_mylar.getMode() == LTR390_MODE_ALS) {
    Serial.println("LTR Mylar In ALS mode");
  } else {
    Serial.println("LTR Mylar In UVS mode");
  }
 tcaselect(2);
  ltr_paper.setGain(LTR390_GAIN_3); // set gain for uv sensors
  Serial.print("LTR Paper Gain : ");
  switch (ltr_paper.getGain()) {
    case LTR390_GAIN_1: Serial.println(1); break;
    case LTR390_GAIN_3: Serial.println(3); break;
    case LTR390_GAIN_6: Serial.println(6); break;
    case LTR390_GAIN_9: Serial.println(9); break;
    case LTR390_GAIN_18: Serial.println(18); break;
  }

tcaselect(1);
 ltr_plastic.setGain(LTR390_GAIN_3); // set gain for uv sensors
  Serial.print("LTR Plastic Gain : ");
  switch (ltr_plastic.getGain()) {
    case LTR390_GAIN_1: Serial.println(1); break;
    case LTR390_GAIN_3: Serial.println(3); break;
    case LTR390_GAIN_6: Serial.println(6); break;
    case LTR390_GAIN_9: Serial.println(9); break;
    case LTR390_GAIN_18: Serial.println(18); break;
  }

tcaselect(7);
   ltr_mylar.setGain(LTR390_GAIN_3); // set gain for uv sensors
  Serial.print("LTR Mylar Gain : ");
  switch (ltr_mylar.getGain()) {
    case LTR390_GAIN_1: Serial.println(1); break;
    case LTR390_GAIN_3: Serial.println(3); break;
    case LTR390_GAIN_6: Serial.println(6); break;
    case LTR390_GAIN_9: Serial.println(9); break;
    case LTR390_GAIN_18: Serial.println(18); break;
  }
 tcaselect(2);
  ltr_paper.setResolution(LTR390_RESOLUTION_16BIT); //set selectivity for three sensors
  Serial.print("LTR Paper Resolution : ");
  switch (ltr_paper.getResolution()) {
    case LTR390_RESOLUTION_13BIT: Serial.println(13); break;
    case LTR390_RESOLUTION_16BIT: Serial.println(16); break;
    case LTR390_RESOLUTION_17BIT: Serial.println(17); break;
    case LTR390_RESOLUTION_18BIT: Serial.println(18); break;
    case LTR390_RESOLUTION_19BIT: Serial.println(19); break;
    case LTR390_RESOLUTION_20BIT: Serial.println(20); break;
  }

tcaselect(1);
ltr_plastic.setResolution(LTR390_RESOLUTION_16BIT); //set selectivity for three sensors
  Serial.print("LTR Plastic Resolution : ");
  switch (ltr_plastic.getResolution()) {
    case LTR390_RESOLUTION_13BIT: Serial.println(13); break;
    case LTR390_RESOLUTION_16BIT: Serial.println(16); break;
    case LTR390_RESOLUTION_17BIT: Serial.println(17); break;
    case LTR390_RESOLUTION_18BIT: Serial.println(18); break;
    case LTR390_RESOLUTION_19BIT: Serial.println(19); break;
    case LTR390_RESOLUTION_20BIT: Serial.println(20); break;
  }

tcaselect(7);
ltr_mylar.setResolution(LTR390_RESOLUTION_16BIT); //set selectivity for three sensors
  Serial.print("LTR Mylar Resolution : ");
  switch (ltr_mylar.getResolution()) {
    case LTR390_RESOLUTION_13BIT: Serial.println(13); break;
    case LTR390_RESOLUTION_16BIT: Serial.println(16); break;
    case LTR390_RESOLUTION_17BIT: Serial.println(17); break;
    case LTR390_RESOLUTION_18BIT: Serial.println(18); break;
    case LTR390_RESOLUTION_19BIT: Serial.println(19); break;
    case LTR390_RESOLUTION_20BIT: Serial.println(20); break;
  }  
 tcaselect(2);
  ltr_paper.setThresholds(100, 1000); //for all three sensors
  ltr_paper.configInterrupt(true, LTR390_MODE_UVS);

tcaselect(1);
  ltr_plastic.setThresholds(100, 1000); //for all three sensors
  ltr_plastic.configInterrupt(true, LTR390_MODE_UVS);

tcaselect(7);
  ltr_mylar.setThresholds(100, 1000); //for all three sensors
  ltr_mylar.configInterrupt(true, LTR390_MODE_UVS);
}


void loop() {
 
    tcaselect(1);
      Serial.print("Plastic UV data: ");
      Serial.print(ltr_plastic.readUVS());
    tcaselect(2);
      Serial.print("  Paper UV data: ");
      Serial.print(ltr_paper.readUVS());   
      tcaselect(7); 
      Serial.print("  Mylar UV data: ");
      Serial.println(ltr_mylar.readUVS());


  delay(1000); //how long to wait for next data 

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

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by Franklin97355 »

Have you tested your connections using the code in the tutorial?

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

No sir, we haven't tried just that particular code snippet yet. It is included in our code, but it hadn't occurred to us to try just that little piece. We'll try that after lunch and post any results.

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

Franklin97355 wrote: Wed Mar 29, 2023 12:29 pm Have you tested your connections using the code in the tutorial?
This was the output from the serial monitor. We have LTR3902 plugged into ports 1, 2 and 7 on the multiplexer.

16:14:49.686 ->
16:14:49.686 -> TCAScanner ready!
16:14:50.902 -> TCA Port #0
16:14:54.369 -> Found I2C 0x0
16:14:58.873 -> Found I2C 0x1
16:14:58.873 -> TCA Port #1
16:14:58.873 -> TCA Port #2
16:14:58.873 -> TCA Port #3
16:14:58.873 -> TCA Port #4
16:14:58.873 -> TCA Port #5
16:14:58.873 -> TCA Port #6
16:14:58.873 -> TCA Port #7
16:14:58.873 ->
16:14:58.873 -> done

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

Franklin97355 wrote: Wed Mar 29, 2023 12:29 pm Have you tested your connections using the code in the tutorial?
I pulled the 3 Adafruit LTR390s off the multiplexer and just used the 1 remaining Waveshare LTR390. This was the output from the serial monitor.:

16:33:26.114 ->
16:33:26.114 -> TCAScanner ready!
16:34:28.238 -> TCA Port #0
16:34:28.281 -> TCA Port #1
16:34:28.281 -> TCA Port #2
16:34:28.281 -> TCA Port #3
16:34:28.313 -> TCA Port #4
16:34:28.313 -> TCA Port #5
16:34:28.356 -> TCA Port #6
16:34:28.356 -> TCA Port #7
16:34:28.356 -> Found I2C 0x53
16:34:28.356 ->
16:34:28.356 -> done

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

We attached one adafruit LTR390 directly to our microcontroller to eliminate any issues with the multiplexer. We ran this code :

Code: Select all

/*************************************************** 
  This is an example for the LTR390 UV Sensor

  Designed specifically to work with the LTR390 UV sensor from Adafruit
  ----> https://www.adafruit.com

  These sensors use I2C to communicate, 2 pins are required to  
  interface
 ****************************************************/
 
#include "Adafruit_LTR390.h"

Adafruit_LTR390 ltr = Adafruit_LTR390();

void setup() {
  delay(5000);
  Serial.begin(115200);
  Serial.println("Adafruit LTR-390 test");

  if ( ! ltr.begin() ) {
    Serial.println("Couldn't find LTR sensor!");
    while (1) delay(10);
  }
  Serial.println("Found LTR sensor!");

  ltr.setMode(LTR390_MODE_UVS);
  if (ltr.getMode() == LTR390_MODE_ALS) {
    Serial.println("In ALS mode");
  } else {
    Serial.println("In UVS mode");
  }

  ltr.setGain(LTR390_GAIN_3);
  Serial.print("Gain : ");
  switch (ltr.getGain()) {
    case LTR390_GAIN_1: Serial.println(1); break;
    case LTR390_GAIN_3: Serial.println(3); break;
    case LTR390_GAIN_6: Serial.println(6); break;
    case LTR390_GAIN_9: Serial.println(9); break;
    case LTR390_GAIN_18: Serial.println(18); break;
  }

  ltr.setResolution(LTR390_RESOLUTION_16BIT);
  Serial.print("Resolution : ");
  switch (ltr.getResolution()) {
    case LTR390_RESOLUTION_13BIT: Serial.println(13); break;
    case LTR390_RESOLUTION_16BIT: Serial.println(16); break;
    case LTR390_RESOLUTION_17BIT: Serial.println(17); break;
    case LTR390_RESOLUTION_18BIT: Serial.println(18); break;
    case LTR390_RESOLUTION_19BIT: Serial.println(19); break;
    case LTR390_RESOLUTION_20BIT: Serial.println(20); break;
  }

  ltr.setThresholds(100, 1000);
  ltr.configInterrupt(true, LTR390_MODE_UVS);
}

void loop() {
  if (ltr.newDataAvailable()) {
      Serial.print("UV data: "); 
      Serial.print(ltr.readUVS());
  }
  
  delay(100);
}
The output stopped at 16:13:45.378 -> Adafruit LTR-390 test

User avatar
adafruit_support_carter
 
Posts: 29177
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by adafruit_support_carter »

The wiring diagram link above did not work for some reason. Can you post a photo of your actual setup (not a diagram) showing how everything is being connected.

As a basic check - do the Adafruit LTR390 sensors work without the muxer? Just connect one LTR390 directly to your Arduino board per the guide here:
https://learn.adafruit.com/adafruit-ltr ... or/arduino
and try the example code on that same page.

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

<img src="blob:chrome-untrusted://media-app/d4efd8d5-8237-4d28-a5d4-a49720169ac3" alt="20230331_123845.jpg"/>
<img src="blob:chrome-untrusted://media-app/e67c2749-aed4-451e-a7be-38c8f6f7d152" alt="20230331_123828.jpg"/>

These photos show how 1 LRT390 is wired for the test I ran with just 1 sensor, using the code are the link provided. The sketch stopped outputting at "Adafruit LTR390 test" as indicated above.

User avatar
adafruit_support_carter
 
Posts: 29177
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by adafruit_support_carter »

Try adding the images directly to the post.

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

I'm having trouble adding pictures directly and editing older posts.

This is the single sensor.
https://drive.google.com/file/d/15QGqBa ... share_link
https://drive.google.com/file/d/15UNbYt ... share_link

This is 3 sensors wired through the multiplexer. We try to color code for simplicity.
Red - 5v
Back - Ground
Orange - SCL
Blue - SDA
Green _ Interrupt
https://drive.google.com/file/d/1DRoAe0 ... sp=sharing
https://drive.google.com/file/d/1g_GhuF ... sp=sharing
https://drive.google.com/file/d/1nSiPjN ... sp=sharing
https://drive.google.com/file/d/1ECl7w1 ... sp=sharing
https://drive.google.com/file/d/1X5mjn9 ... sp=sharing

Does this help any?

User avatar
adafruit_support_carter
 
Posts: 29177
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by adafruit_support_carter »

Inlining photos for reference:
wiring1.jpg
wiring1.jpg (385.3 KiB) Viewed 8987 times
wiring2.jpg
wiring2.jpg (398 KiB) Viewed 8987 times

User avatar
adafruit_support_carter
 
Posts: 29177
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by adafruit_support_carter »

Thanks. Yep, can access the photos now.

For the single LTR390 setup shown above, now try running this I2C scanner sketch:
https://learn.adafruit.com/scanning-i2c ... es/arduino

If the expected LTR390 I2C address of 0x53 does not show up in the scan, then please add another photo showing the soldering job on the header pins here:
headers.png
headers.png (769.15 KiB) Viewed 8986 times

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

I tested all three sensors separately. One sensor retuned the i2c address of 0x53, one returned no i2c device found and the third stopped outputting at scanning. I am including pictures of all 3 for comparison. They are labeled in the pictures.

No i2c device found
https://drive.google.com/file/d/1jUQCi2 ... sp=sharing
https://drive.google.com/file/d/1I1Zkcn ... sp=sharing

Scanning
https://drive.google.com/file/d/1vEmFA0 ... sp=sharing
https://drive.google.com/file/d/1Dfarp2 ... sp=sharing

i2c found at 0x53 (for comparison, if it helps)
https://drive.google.com/file/d/1dVij7p ... sp=sharing
https://drive.google.com/file/d/1mQl3ge ... sp=sharing

Is there anything I'm missing? Thank you in advance.

User avatar
adafruit_support_carter
 
Posts: 29177
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by adafruit_support_carter »

Thanks for the photos. There's a chance this could be soldering related. Both the photo of the LTR390 that was not found and the one that was found look like they may have some cold soldered pins not wetted out on the pads. So it's probably random as to which ones are working/not working.

Address not found, possible cold soldered pin:
soldering_addr_not_found.png
soldering_addr_not_found.png (509.17 KiB) Viewed 8940 times
Address found, but pins still look possibly cold soldered:
soldering_addr_found.png
soldering_addr_found.png (462.72 KiB) Viewed 8940 times
See here for info on the general issue:
https://learn.adafruit.com/adafruit-gui ... n-problems

Try touching up the soldering on the pins, don't add any more solder, but try reheating/reflowing what is there, concentrating on heating both the pin and pad so it wetts out better.

It looks like the original Waveshare device did not require any soldering? The Adafruit LTR390 breakout can be used in a similar way with STEMMA QT cables like this:
https://www.adafruit.com/product/4209

Note that the INT pin can be initially left disconnect. It is not a required connection:
https://learn.adafruit.com/adafruit-ltr ... or/arduino

Multiple LTR390's can also be chained without soldering with muxers that have STEMMA QT connectors:
https://www.adafruit.com/product/5664
https://www.adafruit.com/product/5626

User avatar
mark_reed
 
Posts: 10
Joined: Wed Mar 29, 2023 9:53 am

Re: Trouble useing 3 LTR390 sensors with TDA9548A multiplexer in Arduino

Post by mark_reed »

Thank you. Will attempt to re flow those pins this afternoon of tomorrow and get back to you.

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

Return to “For Educators”