-
Notifications
You must be signed in to change notification settings - Fork 1k
I2C Scanner examples #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I2C Scanner examples #303
Conversation
Tested on Bluepill for all three I2c (TWI 1 - TWI 1 alternative pin - TWI 2)
Thanks @Testato |
|
||
|
||
|
||
// Pinmap for Bluepill I2Cs (by Testato) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's really needed to add specific board pins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think it is very useful add at least one examples for a board, and the Bluepill is the most famous ST variant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
// I2C-1 alternative pins: PB9(sda) PB8(scl) | ||
// TwoWire Wire_alt(PB9,PB8); | ||
// | ||
// I2C-2: PB9(sda) PB8(scl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If kept, this line need to be updated:
// I2C-2: PB11(sda) PB10(scl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
void setup() { | ||
|
||
Serial.begin(9600); | ||
Wire.begin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other method to use another I2C pin or instance, it to update the Pins before call Begin().
This allow to kept Wire instance and declare a new one.
Example for the BP:
Wire.setSDA(PB9);
Wire.setSCL(PB8);
Wire.begin();
or
Wire.setSDA(PB11);
Wire.setSCL(PB10);
Wire.begin();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i also think is better, but you cannot use two I2c in the sametime, so the second must have a second declaration.
I will modifie the example, look if you like it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know :)
I only gave several example to use only one but with different pins possibilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
I2C Scanner examples
Tested on Bluepill for all three I2c (TWI 1 - TWI 1 alternative pin - TWI 2)