I2C Bus Setup function - SDA and SCL as variables
Posted: Mon Aug 01, 2016 2:42 am
Hello,
I want to start writing some more ESPBasic I2C related drivers and examples for widely used I2C compatible IC's, like ADC's, DAC's, Sensors, port expanders, etc but I really like to use other GPIO pins for the SDA/SCL lines. For this feature working we need a way to be able to define at the beginning of the program the allocated I2C pins like it is in Arduino IDE or even in LUA.
A simple way is to declare the desired SDA and SCL pins definitions to the start of the program:
I know that in ESPBasic we have hardcoded values for SDA and SCL as below:
If this can be changed to
I think this is a quite simple feature to add and will made many people to adopt ESPBasic for their I2C related projects. GPIO0/2 are not exactly the most used pins for I2C out in the wild and might vary a lot based on projects needs.
Thank you,
TJ.
I want to start writing some more ESPBasic I2C related drivers and examples for widely used I2C compatible IC's, like ADC's, DAC's, Sensors, port expanders, etc but I really like to use other GPIO pins for the SDA/SCL lines. For this feature working we need a way to be able to define at the beginning of the program the allocated I2C pins like it is in Arduino IDE or even in LUA.
A simple way is to declare the desired SDA and SCL pins definitions to the start of the program:
I know that in ESPBasic we have hardcoded values for SDA and SCL as below:
Code: Select all
Wire.begin(0, 2);
If this can be changed to
Code: Select all
and then in the program you can define the SDA and SCL pins as you want. Problem solved. Wire.begin(SDA, SCL);
I think this is a quite simple feature to add and will made many people to adopt ESPBasic for their I2C related projects. GPIO0/2 are not exactly the most used pins for I2C out in the wild and might vary a lot based on projects needs.
Thank you,
TJ.