Skip to content

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

Merged
merged 3 commits into from
Sep 4, 2018
Merged

I2C Scanner examples #303

merged 3 commits into from
Sep 4, 2018

Conversation

Testato
Copy link
Contributor

@Testato Testato commented Aug 10, 2018

Tested on Bluepill for all three I2c (TWI 1 - TWI 1 alternative pin - TWI 2)

Tested on Bluepill for all three I2c (TWI 1 - TWI 1 alternative pin - TWI 2)
@fpistm
Copy link
Member

fpistm commented Aug 10, 2018

Thanks @Testato




// Pinmap for Bluepill I2Cs (by Testato)
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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)
Copy link
Member

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)

Copy link
Contributor Author

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();
Copy link
Member

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();

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@fpistm fpistm added the enhancement New feature or request label Sep 3, 2018
@fpistm fpistm merged commit 740d316 into stm32duino:master Sep 4, 2018
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this pull request Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants