ESP32 I2C mapping
Re: ESP32 I2C mapping
Yes the hw support for 2 i2c can work with the right software tweaks which is what I said before
"only one is configured by default" means DIY
"only one is configured by default" means DIY
Re: ESP32 I2C mapping
where should these tweaks take place? In the arduino/esp libraries? Or in the joy example? Will the defines I made in pins Arduino work?
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Re: ESP32 I2C mapping
Could I please get some help on changing the pin assignments? ive googled "esp32 change pin out", "esp32 change pin assignment and every other way I could think of but I cant find any information on how to do so. What all do I need to do to add a second set of i2c ports?
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Re: ESP32 I2C mapping
You have to create a new twowire device for the second one
https://github.com/espressif/arduino-es ... e.cpp#L221
Then you have to make your libraries talk to the correct instance
https://github.com/espressif/arduino-es ... e.cpp#L221
Then you have to make your libraries talk to the correct instance
Re: ESP32 I2C mapping
I need to make a new two wire with the sda and scl pointing at the second set of pinouts I defined in pins_arduino?
I tried adding this to the wire.cpp but it just caused redefinition errors...
TwoWire Wire = TwoWire(1);
or should it be
TwoWire2 = TwoWire(1);
I tried adding this to the wire.cpp but it just caused redefinition errors...
TwoWire Wire = TwoWire(1);
or should it be
TwoWire2 = TwoWire(1);
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Re: ESP32 I2C mapping
Code: Select all
TwoWire Wire2 = TwoWire(1);
Re: ESP32 I2C mapping
Awesome thank you. Ok now how do I get that instance to point to the right pins? Or what is my next step?
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Re: ESP32 I2C mapping
Wire2.begin(SDA2, SCL2, freq)
Re: ESP32 I2C mapping
Awesome!!! You rock!!! Thank you!!! Ok this seems pretty simple so far. So now it point to the pins that I changed in pins_arduino? Now about those pins.... What basic functions must the pins have to use them as my secondary I2C? I would like to have one set on one side of the huzzah and the secondary set on the other side. This will make it easier to shorten the lines due to placement of the huzzah on the back of the screen.
the pins are described here..
can analog pins be used? I need to be able to use the bottom row pins.
Do I need to add the SDA2 and SCL2 to the begin and protected in wire .h?
the pins are described here..
Code: Select all
Bottom row:
A0 - this is an analog input A0 and also an analog output DAC2. It can also be used as a GPIO #26
A1 - this is an analog input A1 and also an analog output DAC1. It can also be used as a GPIO #25
A2 - this is an analog input A2 and also GPI #34. Note it is not an output-capable pin!
A3 - this is an analog input A3 and also GPI #39. Note it is not an output-capable pin!
A4 - this is an analog input A4 and also GPI #36. Note it is not an output-capable pin!
A5 - this is an analog input A5 and also GPIO #4
21 - General purpose IO pin #21
Top row:
13 - This is GPIO #13 and also an analog input A12. It's also connected to the red LED next to the USB port
12 - This is GPIO #12 and also an analog input A11. This pin has a pull-down resistor built into it, we recommend using it as an output only, or making sure that the pull-down is not affected during boot.
27 - This is GPIO #27 and also an analog input A10
33 - This is GPIO #33 and also an analog input A9. It can also be used to connect a 32 KHz crystal.
15 - This is GPIO #15 and also an analog input A8
32 - This is GPIO #32 and also an analog input A7. It can also be used to connect a 32 KHz crystal.
14 - This is GPIO #14 and also an analog input A6
Do I need to add the SDA2 and SCL2 to the begin and protected in wire .h?
Code: Select all
TwoWire::TwoWire(uint8_t bus_num)
:num(bus_num & 1)
,sda(-1)
,scl(-1)
,i2c(NULL)
,rxIndex(0)
,rxLength(0)
,txIndex(0)
,txLength(0)
,txAddress(0)
,transmitting(0)
{}
void TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
{
if(sdaPin < 0) {
if(num == 0) {
sdaPin = SDA;
} else {
return;
}
}
if(sclPin < 0) {
if(num == 0) {
sclPin = SCL;
} else {
return;
}
}
if(i2c == NULL) {
i2c = i2cInit(num, 0, false);
if(i2c == NULL) {
return;
}
}
i2cSetFrequency(i2c, frequency);
if(sda >= 0 && sda != sdaPin) {
i2cDetachSDA(i2c, sda);
}
if(scl >= 0 && scl != sclPin) {
i2cDetachSCL(i2c, scl);
}
sda = sdaPin;
scl = sclPin;
i2cAttachSDA(i2c, sda);
i2cAttachSCL(i2c, scl);
flush();
i2cInitFix(i2c);
}
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Re: ESP32 I2C mapping
Ok guys I'm almost there..... Whats the next step? any of the above?
Fear is the mind killer.......
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
GameR the DIY iot gaming device that does more......
https://github.com/Duhjoker/GameR-Iot_ESP
Who is online
Users browsing this forum: No registered users and 98 guests