Tagged: i2c, multiplexing
-
AuthorPosts
-
September 30, 2018 at 9:01 PM #9880thomasvergoteParticipant
I am reading sensor data by the Mini Ultra Pro v3 and send it over LoRa. This works great for one sensor but I want to use several (identical) sensors for one set-up (which have a fixed address of 0x76). I can accomplish this easily on an arduini pro mini with Adafruit’s TCA9548A. I only need to call the TCA9548A and select the channel:
void tcaselect(uint8_t i) { if (i > 7) return; Wire.beginTransmission(TCAADDR); Wire.write(1 << i); Wire.endTransmission(); }
Sadly, this does not work so easily on the Mini Ultra Pro v3, once I include the Wire.beginTransmission(TCAADDR) statement (TCAADDR being 0x70) I don’t get any response any more. Any clue why this happens? If this cannot be easily resolved, is there another way to use several i2c sensors at 0x76 with the Mini Ultra Pro v3?
Thanks!
October 7, 2018 at 12:25 AM #9967LIM PHANG MOHKeymasterHi,
I personally have never use this I2C multiplexer chip before. But looking through the code and the library usage, I can’t see anything that could prevent this from working on the V3. The EUI-64 memory chip has a 0x50 I2C address, so that could be rule out. Do you have a more complete code that works on the Pro Mini?October 7, 2018 at 8:14 PM #9975thomasvergoteParticipantHi Phang Moh,
Here is the simplest code working on a Pro Mini but not on the v3. It does work if I do not use the tcaselect. As you can see, it simply uses the wire library so I guess that is where the issue is, somehow.
#define TCAADDR 0x70 #include <Wire.h> #include <MS5803_14.h> #define Serial SerialUSB \\ for Ultra Pro v3 MS_5803 sensor1 = MS_5803(4096); MS_5803 sensor2 = MS_5803(512); void tcaselect(uint8_t i) { if (i > 7) return; Wire.beginTransmission(TCAADDR); Wire.write(1 << i); Wire.endTransmission(); } void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); Serial.println("Sensor 1:"); tcaselect(0); sensor1.initializeMS_5803(false); tcaselect(1); sensor2.initializeMS_5803(false); } void loop() { tcaselect(0); sensor1.readSensor(); Serial.println("Sensor 1: "+String(sensor1.pressure() / 10)+','+String(sensor1.temperature())); tcaselect(1); sensor2.readSensor(); Serial.println("Sensor 2: "+String(sensor2.pressure() / 10)+','+String(sensor2.temperature())); delay(1000); }
October 8, 2018 at 12:14 AM #9977LIM PHANG MOHKeymasterHi Thomas,
I think you might need to call
Wire.begin()
insetup()
?October 8, 2018 at 11:01 AM #9983thomasvergoteParticipantI believe I have tried this already. I will try again once a field test is finished.
Do you have any alternative to use multiple I2Cs on the same address that is verified with the v3?
Also how is the backorder lead time on the v3 at this moment?
Thanks!
October 10, 2018 at 1:21 PM #9990LIM PHANG MOHKeymasterI think Wire.begin() is needed because if you look at the Wire library for SAMD21 core:
void TwoWire::begin(void) { //Master Mode sercom->initMasterWIRE(TWI_CLOCK); sercom->enableWIRE(); pinPeripheral(_uc_pinSDA, g_APinDescription[_uc_pinSDA].ulPinType); pinPeripheral(_uc_pinSCL, g_APinDescription[_uc_pinSCL].ulPinType); }
Do you have any alternative to use multiple I2Cs on the same address that is verified with the v3?
Unfortunately no for now.
Also how is the backorder lead time on the v3 at this moment?
Usually 1-2 days after order. Time is tight now due to parenting task at day time. I have just gotten a pick and place machine but haven’t set it up yet. Things will improve once it’s up and running.
October 23, 2018 at 7:48 AM #10076thomasvergoteParticipantI got it working!
The Wire.begin() is indeed necessary, but if I put it at the start of my setup(), it must be conflicting as nothing happens any more. If I put it at the end, it works. I am starting to finish up on full system now. Really like how it is working!
-
AuthorPosts
- You must be logged in to reply to this topic.