wifwaf / tca9548a Goto Github PK
View Code? Open in Web Editor NEWTCA9548A library for Arduino devices (supports multiple channels).
License: Apache License 2.0
TCA9548A library for Arduino devices (supports multiple channels).
License: Apache License 2.0
If im trying to run your sample code I always get this error:
C:\Users\PC-Werkstatt\Documents\Arduino\libraries\TCA9548A\src\TCA9548A.cpp: In member function 'void TCA9548A::begin(uint8_t, uint8_t, TwoWire&)':
C:\Users\PC-Werkstatt\Documents\Arduino\libraries\TCA9548A\src\TCA9548A.cpp:18:34: error: no matching function for call to 'TwoWire::begin(uint8_t&, uint8_t&)'
this->myWire->begin(_sda,_sdl);
In file included from C:\Users\PC-Werkstatt\Documents\Arduino\libraries\TCA9548A\src\TCA9548A.h:13:0,
from C:\Users\PC-Werkstatt\Documents\Arduino\libraries\TCA9548A\src\TCA9548A.cpp:9:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:52:10: note: candidate: void TwoWire::begin()
void begin();
im using a arduino nano with the following pins:
#include "TCA9548A.h"
#define SCLPIN 5 // Your I2C pins
#define SDAPIN 4 // Your I2C pins
Do you have any idea?
Hi WifWaf, I am really sorry to bother you but how can I manage multiple TCA9548A?
It's written "Address can be passed into the constructor" but I don't know how to do that.
Please, if you could help, it would be very helpful for me. Thanks in advance.
the begin()
method accepts a TwoWire instance and then calls begin()
on that instance:
https://github.com/WifWaf/TCA9548A/blob/master/src/TCA9548A.cpp#L15
Instead it should call twowire.begin(sda, scl)
. Or this library should not call begin()
on the instance and let the user do this (so the custom sda/scl pins can be passed then).
I made this change to begin
and now it works:
void TCA9548A::begin(TwoWire &inWire, int sda_pin, int scl_pin)
{
this->myWire = &inWire;
this->myWire->begin(sda_pin, scl_pin);
}
Hi, incredibly new at this, but I'm having some issues even incorporating your library at all. When taking a blank script (setup and loop remaining empty) such that:
#include <TCA9548A.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
is the entirety of the script.
It's yielding an error upon verifying:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:66:13: note: candidate: uint8_t TwoWire::requestFrom(uint8_t, uint8_t, uint8_t)
uint8_t requestFrom(uint8_t, uint8_t, uint8_t);
^~~~~~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire\src/Wire.h:69:13: note: candidate: uint8_t TwoWire::requestFrom(int, int, int)
uint8_t requestFrom(int, int, int);
^~~~~~~~~~~
exit status 1
Error compiling for board Arduino Mega or Mega 2560.
Any ideas as to what's going on or how I might rectify this?
I'm trying to use multiple 0.91 inch OLED displays (128x32px) with an ESP32 board and a TCA9548A. I found this: https://gist.github.com/johnaboxall/653cc12aa66571b6490610c20ac3b7c8 and it seems like a good start but I'd rather use a library like this. Can you show how to port that example using this library?
Would be cool to have an example that scans each bus for devices in a slow loop. I made the thing below but it's hard-coded in my copy of the library:
void TCA9548A::scan() {
byte error, address;
int nDevices = 0;
for (address = 1; address < 127; address++ ) {
this->myWire->beginTransmission(address);
error = this->myWire->endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address, HEX);
nDevices++;
}
else if (error==4) {
Serial.print("Unknown error at address 0x");
if (address<16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
}
delay(5000);
}
And use it like this:
void loop() {
Serial.println();
Serial.println("Scanning channel 0...");
I2CMux.openChannel(0);
I2CMux.scan();
Serial.println();
Serial.println("Scanning channel 1...");
I2CMux.closeAll();
I2CMux.openChannel(1);
I2CMux.scan();
Serial.println();
Serial.println("Scanning channel 2...");
I2CMux.closeAll();
I2CMux.openChannel(2);
I2CMux.scan();
}
Output (only ssd1306 OLEDs connected to channel 0 and 1, both with address 0x3C
):
Scanning channel 0...
I2C device found at address 0x3C
I2C device found at address 0x70
Scanning channel 1...
I2C device found at address 0x3C
I2C device found at address 0x70
Scanning channel 2...
I2C device found at address 0x70
Hi,
I am trying ti set up a ArduinoMega-TCA9548A-MCP4725(DAC) chain
I am struggling a lot with the code of the chain.
I hope you will find my mistake
I know both devices are working because I can talk to them independently via ArduinoMega-I2C
I got inspiration fro; these two internet pages
https://forums.adafruit.com/viewtopic.php?f=22&t=93035
https://learn.sparkfun.com/tutorials/mcp4725-digital-to-analog-converter-hookup-guide/all
Thanks a lot
Sebastien
Here is my arduino code
byte Program = 64;
byte DAC_addr = 0x62; // This hardwired into the IC and the BoB, in other words, it is a given.
byte Multiplexer_addr = 0x70;
byte TargetID = 0;
byte b1 = 0;
byte b2 = 0;
int value = 0;
#include <Wire.h>
void setup()
{
value = 0
b1 = byte((value / 16));
b2 = byte(value % 16);
Wire.beginTransmission(TCAADDR);
Wire.write(1 << TargetID);
Wire.write(DAC_addr);
Wire.write(Program);
Wire.write(b1);
Wire.write(b2 << 4); // Needed twice, since the 4 lowest bits (of 12) are in the fourth byte
Wire.endTransmission();
}
void loop()
{
}
Delcasso Sebastien
Research Scientist
0033 5 5757 4062
NEUROCENTRE MAGENDIE - U1215
146, rue Léo saignat
33077 Bordeaux cedex,France
Arduino IDE Version 1.8.3
TCA9548A.h Version 1.1.1
It does not compile, but as it is an example, it should?!
.pio/libdeps/esp-wrover-kit/TCA9548A/src/TCA9548A.cpp: In member function 'uint8_t TCA9548A::read()':
.pio/libdeps/esp-wrover-kit/TCA9548A/src/TCA9548A.cpp:84:54: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
this->myWire->requestFrom(this->_address, 1, true);
Would be nice to have a clean build.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.