Chat freely about anything...

User avatar
By scargill
#46753 I cannot get to the bottom of I2c using a modern version of the SDK. I am reasonably familiar with i2c so this isn't a noob question.

I have some legacy code whereby there is an i2c.h header - and an i2c.c file....never used it... but isn't this supposed to be part of the SDK itself.

So I guess my questions are:

1. Do you still need to use external files for I2c using a recent SDK - or is it all in the SDK.
2. If the former, do you need both a C file and an H file (suggesting there's nothing in the SDK itself)?
2. If the latter - how do you define which pins to use for i2c? I want to use 4 and 5. The Espressif i2c document doesn't even mention which pins?

Pete.
User avatar
By martinayotte
#46769 Hi Peter,
I2C is done by doing software bitbanging, so it is purely application code in case you are using SDK natively.
It will never be part of the SDK itself, but are present in older SDKs as a simple example, but seems to be gone in the 1.5.3 :

esp_iot_sdk_v1.5.2/examples/driver_lib/include/driver/i2c_master.h
esp_iot_sdk_v1.5.2/examples/driver_lib/driver/i2c_master.c

(some duplicates here too)
esp_iot_sdk_v1.5.2/examples/IoT_Demo/include/driver/i2c_master.h
esp_iot_sdk_v1.5.2/examples/IoT_Demo/driver/i2c_master.c

According to those files, it seems that the pins are define on 2 and 14, but I presume it could be easily changed.

Personally, I'm not doing any native code development since the Arduino framework came out more than a year ago. In this framework, the I2C pins are simply given in the Wire() constructor.
User avatar
By scargill
#46791 Thanks -at least that clarifies it - I'll over-write my files with the ones you mention... and indeed it should be possible to change the port assignments. I wonder indeed if it would be better to use EASYGPIO - when my little port expander turns up I'll have an experiment.
User avatar
By martinayotte
#46794 BTW, I've made a mistake saying that those files were gone in 1.5.3, they are there ...
I've simply forget to unzip this latest SDK 1.5.3 ;-)