Skip to content
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

Working with ESP8266 based boards #9

Open
Inq720 opened this issue May 10, 2020 · 2 comments
Open

Working with ESP8266 based boards #9

Inq720 opened this issue May 10, 2020 · 2 comments

Comments

@Inq720
Copy link

Inq720 commented May 10, 2020

I found your library from this (https://www.best-microcontroller-projects.com/bmp280.html) article and have found it to be perfect for my needs. However, it did not work on my chosen micro controller as-is. Some of the dependencies must be different when using ESP8266 based micro controllers. For my use, I have made the following changes that seem to be working for me. Since these changes are to one of you base classes, I don't know if there are any ramifications that should be noted.

`WirePlus::WirePlus()
{
Wire.begin(); // I2C as Master

#ifdef ESP8266
// DEC - TODO: I've added this as PORTC, TWBR were undefined
// when using on ESP8266 board. Arduino.cc pages state
// that PORTC has to do with analog pins. Why would this
// digital port library need to change these? Need to
// figure this out.
Wire.setClock(400000L);
#else
bitSet(PORTC, 4); // deactivate internal pull-ups for twi
bitSet(PORTC, 5); // as per note from atmega8 manual pg167
// switch to 400KHz I2C - eheheh
TWBR = ((F_CPU / 400000L) - 16) / 2; // see twi_init in Wire/utility/twi.c
#endif // ESP8266

};
`

@HelloTheBean
Copy link

HelloTheBean commented Jun 27, 2021

I think I just ran into exactly this problem with MAG 3110 and a Wemos D1 mini ESP8266 board. Conflicts over i2c library and then the portC and clock setting things. I got fed up of trying to fix it after an hour or so and ordered another magnetometer that has more libraries that support it.

I will try the code above and see if this helps. Thanks for sharing 👍

@HelloTheBean
Copy link

Oh man...what I wimp I was. All I had to do was comment out the bitSet lines and it worked. I already found the clock setting part elsewhere and thought that I was going to have to find out what the ESP8266 compatible way was to do whatever it is that bitSet does (the hour I mention above was mostly trying to remember/work out how to handle overlapping dependencies like the different versions of the i2c library).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants