I2c only works with pin 18,19....

ysw0145
Posts: 3
Joined: Sat Aug 13, 2016 9:28 am

I2c only works with pin 18,19....

Postby ysw0145 » Wed Jul 12, 2017 3:37 am

I change the i2c scanner program (from https://github.com/nkolban/esp32-snippe ... cscanner.c) 's I2C pin map.

Code: Select all

	i2c_config_t conf;
	conf.mode = I2C_MODE_MASTER;
[b]	conf.sda_io_num = 25;
	conf.scl_io_num = 27;[/b]
	conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
	conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
	conf.master.clk_speed = 100000;
	
And connect SDA & SCL to 18,19.
Image

Then,it still works without any error.
Image

As a result,I can not map the i2c pins to whatever I want.....

What's wrong?

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: I2c only works with pin 18,19....

Postby ESP_Sprite » Wed Jul 12, 2017 9:38 am

Are you sure you correctly re-flashed the code? I used I2C a while ago and I'm pretty sure I did not use pin 18 and 19. Can you try to do a `make erase_flash` and reflash?

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: I2c only works with pin 18,19....

Postby rudi ;-) » Wed Jul 12, 2017 11:02 am

ysw0145 wrote:I change the i2c scanner program (from https://github.com/nkolban/esp32-snippe ... cscanner.c) 's I2C pin map.

Code: Select all

	i2c_config_t conf;
	conf.mode = I2C_MODE_MASTER;
[b]	conf.sda_io_num = 25;
	conf.scl_io_num = 27;[/b]
	conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
	conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
	conf.master.clk_speed = 100000;
	
And connect SDA & SCL to 18,19.

Then,it still works without any error.
As a result,I can not map the i2c pins to whatever I want.....

What's wrong?

first: why you set up the pins 25, 27 directly and not use the nice define for it

Code: Select all

#define SDA_PIN 25
#define SCL_PIN 27
second,
like jeroen mentioned, make clean -
cause looks like if you do this:

Code: Select all

conf.sda_io_num = 25;
conf.scl_io_num = 27;
"but" you connect
SDA & SCL to 18,19.
and your hardware runs without problem with this setup ( connected on 18,19 )

then it looks like you work with "old" .o and .a file for your main or what ever you do
on code with I2C, with a preview compile on 18,19 and your project was not updated.

if you work in eclipes example
be sure you "save your changes on the .c file where you make this change
example by STRG + S
then compile.

if you forget this, then it compiles too, but your changes on the code was not updated.

FYI: if you change a file in eclipse, there is a * in begin of file name
like this:

your file is up2date
1.png
1.png (32.48 KiB) Viewed 8166 times
you did a change on it - if you compile - this change is not supported in the compilation
2.png
2.png (46.75 KiB) Viewed 8166 times
save your changes first - then compile
3.png
3.png (39.95 KiB) Viewed 8166 times

and use the define for the pins
you never need change then in the main and on each other place if you work
moretimes on this pins, simple then change only in the top of the file
and on one and only place.

hope this helps
best wishes
rudi ;-)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

ysw0145
Posts: 3
Joined: Sat Aug 13, 2016 9:28 am

Re: I2c only works with pin 18,19....

Postby ysw0145 » Wed Jul 12, 2017 12:28 pm

I saved the .c files.
Oh......... make clean :roll: .

It works.
Thank you.

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: I2c only works with pin 18,19....

Postby ESP_Sprite » Thu Jul 13, 2017 1:26 am

Good to hear it works! But in theory, unless you did weird things that mess with the modification date of your files, you shouldn't have to run 'make clean' in order for esp-idf to pick up on this change. If you run into issues that get fixed when you run 'make clean' more often, and you manage to reproduce them, I'd highly advise you to create an issue on Github so we can fix that.

Who is online

Users browsing this forum: tahseenabbas52 and 83 guests