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

Possible to use TwoWire as software I2C #7

Closed
ScholliYT opened this issue Jul 2, 2019 · 12 comments
Closed

Possible to use TwoWire as software I2C #7

ScholliYT opened this issue Jul 2, 2019 · 12 comments
Assignees
Labels
question Further information is requested wontfix This will not be worked on

Comments

@ScholliYT
Copy link

ScholliYT commented Jul 2, 2019

Can you give an example on how to use your lib with software i2c? In my project I got the i2c blocked for other parts and want to use your lib to controll a mcp23017. I'm using an ESP32 Dev Board.

MCP23017::MCP23017(uint8_t address, TwoWire& bus = Wire) {

@blemasle blemasle self-assigned this Jul 4, 2019
@blemasle blemasle added the question Further information is requested label Jul 4, 2019
@blemasle
Copy link
Owner

blemasle commented Jul 4, 2019

Hi @ScholliYT
I never used SotwareI2C myself, but the tutorial at http://wiki.seeedstudio.com/Arduino_Software_I2C_user_guide/ should get you started.

Then simply pass your instance in the constructor. So my guess would be :

#include "SoftwareI2C.h"

SoftwareI2C softwarei2c;
MCP23017 mcp = MCP23017(0x24, softwarei2c);

void setup()
{
    softwarei2c.begin(3, 2);       // sda, scl
}

@ScholliYT
Copy link
Author

Thank you 👍 I've got my problem fixed without software serial but I will try it out anyway.

@blemasle
Copy link
Owner

Hi @ScholliYT . Have you had the opportunity to test the library with SoftwareI2C yet ?

@ScholliYT
Copy link
Author

Nope, sorry. Didn't have any time to test it. But it's still on my ToDo-List. Maybe you can give it a try yourself.

@blemasle
Copy link
Owner

I moved home recently and I haven't had the opportunity to do some devs/electronics since then. No rush though :)

Thanks

@SukkoPera
Copy link

Unfortunately this nice feature of this library cannot be used at the moment, due to a shortcoming of the original Wire.h library.

I have opened this issue on a Software I2C library to detail the exact issue, so please see there.

There is already an open issue on the Arduino Core. Everybody who is interested in this please add a thumbs up there.

@blemasle
Copy link
Owner

blemasle commented Mar 4, 2020

Arf, that's a shame ! This as s kinda strange cause I didn't came with this idea out of the blue of course. I actually took it from another library, but I can't remember which one.

I'm not sure, but wouldn't a templated version of the library solve this issue ?

@SukkoPera
Copy link

I've also realized it could be made to work using a template, but I see it more as a workaround rather than the proper solution.

So I would first try to get this solved in Wire.h by voting and commenting the issue I've linked above. Then, if we get nowhere with that, we can switch to a template. For my own needs, I have temporarily modified this library so that it uses that software implementation, and I can live with that for a while.

@Beerlesklopfer
Copy link

Wooldn‘t it be nice being more general. The chip also has a SPI interface in the mcp23S17 version. When we think about software serial there could be also the hardware and software SPI option too; either in different constructors or a special class.

@SukkoPera
Copy link

That could be interesting, but I think it should be filed as a different Feature Request. At the moment this is a library for the i2c version of the chip, you are asking to turn it into one for both the i2c and SPI versions. It's also quite a bit of work, actually :).

@Beerlesklopfer
Copy link

Sure, but if we talk about concepts, we should have that in focus...

@blemasle blemasle added the wontfix This will not be worked on label Apr 16, 2020
@blemasle
Copy link
Owner

blemasle commented Apr 16, 2020

Until ArduinoCore API #31 is solved, nothing can be done here. A templated class isn't a solution either cause Arduino C++ does not support type constraints based on concepts.

Feel free to reopen the day something new has occured about this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants