For Uno pins A4 (SDA) and A5 (SCL) is used, I need to change to pin A1 and A2 respectively. Can anybody help, need some coding or changes in library, I guess?
Fuksen:
For UNO pins A4 (SDA) and A5 (SCL) is used, I need to change to pin A1 and A2 respectively.
No, you don't. Simple as that.
(Before anyone else mentions it, yes you can implement I2C in software, but this is clearly an XY problem, simply no need to consider what is requested.)
Thanks Pauk for yr rply. Do you know why?
Why which?
A4 and A5 connect to a piece of hardware in the ATmegaxx8 chip which performs the I2C interface. It connects to A4 and A5 and no others because that is how it is designed. You can perform an I2C interface in software on (any) other pins but the code to do it is simply not worth the trouble.
I gather that the I2C interface on an ESP8266 is in fact, a software module which can therefore be applied to (almost) any pair of I/O pins. This would work adequately because the software module is provided with the firmware and the chip is at least four times as fast as the ATmegas and more heavily resourced overall.
The question for you is - why would you not want to use A4 and A5 as your I2C interface presuming you actually need an I2C interface?
Hello Fuksen,
Some micro controllers have the ability to specify which pins some or all hardware modules are presented on. I have had a (very) quick look at the ATmega328 data sheet but, as far as I can see in my very quick look, it does not have this capability. If you want to know if it can be done and how to do it for a specific chip then you need to read the data sheet for that chip.
The ATmega328 absolutely does not have any such flexibility; there is simply no dispute on that.
I am not at all sure that the ESP8266 actually has any hardware for I2C. Someone may care to research and comment on this with authority.
Many thanks Paul and Perry. I have a project where all pins except serial HW are used and it's already hard wired, hince I want flexibility, what appereantly is not the case with this binding to the A4- and A5 pins. Of Course I have to live with this.
Again many thanks for your helpfull comments.
Fuksen:
it's already hard wired, hence I want flexibility,
That is called an oxymoron!
Didn't plan it, eh? You will simply have to change the wiring then.