Giter Site home page Giter Site logo

Comments (9)

stevemarple avatar stevemarple commented on May 30, 2024

Wiring is the forerunner to the Arduino environment. The Wire class which you reference is also available in the Arduino environment. Both of these classes use the built-in microcontroller hardware to communicate over I2C, using dedicated pins. SoftWire was created to allow multiple, independent I2C buses by emulating the correct behaviour in software on arbitrary pins. Unless you know that you need a software implementation SoftWire is probably not what you are looking for. I'm not familiar with the PCA9685 but I think what you probably need is https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library

from softwire.

Amajad avatar Amajad commented on May 30, 2024

Dear Steve, Could you provide documentation on Softwire library which demonstrate use for multiple i2c bus for reference? any example for multiple i2c bus on different pins?

from softwire.

stevemarple avatar stevemarple commented on May 30, 2024

@Amajad take a look at the example at https://github.com/stevemarple/SoftWire/blob/master/examples/ListDevices/ListDevices.ino

For the second bus (let's call it sw2) using pins 10 and 11 then you'd add

SoftWire sw2(SDA, SCL);

Then just duplicate all the functions calls on sw to be called on sw2 also.

from softwire.

Amajad avatar Amajad commented on May 30, 2024

Thank you sir.

from softwire.

Koepel avatar Koepel commented on May 30, 2024

Does your library support multiple I2C busses with shared SCL, to reduce pins ?
(if there are not too many sensors or too long wires or too many pullup resistors for SCL).

Software sw1( 9, 8);   // sda, scl
Software sw2( 10, 8);
Software sw3( 11, 8);
Software sw4( 12, 8);

from softwire.

stevemarple avatar stevemarple commented on May 30, 2024

@Koepel I don't think you can share SCL across I2C busses regardless of the implementation (you'd be sending data to all busses). I think it should be possible to share SDA across I2C busses if all devices are fully compliant. The library wasn't written with that mode of operation in mind but I can't think of anything which would prevent it working.

from softwire.

Koepel avatar Koepel commented on May 30, 2024

I also could not found something that would prevent it to work.

The SCL should be shared, not SDA. When the SDA goes low, it is the beginning of a start condition. As long as the SDA stays high, the SCL can become high and low, it doesn't matter. The hardware start logic in the slave is never activated when the SDA stays high.

When there are for example ten I2C busses with a single SCL. Then nine of them keep the SDA high, and only one SDA works together with SCL for a start condition, data transfer and stop.

from softwire.

stevemarple avatar stevemarple commented on May 30, 2024

@Koepel It's a while since I wrote the library so I don't remember all the details of I2C but the stop() function does set SDA high so I think it will probably work. Please try and let me know how you get on.

from softwire.

Koepel avatar Koepel commented on May 30, 2024

Sorry, I don't have the time to try it with your library. The shared SCL is a normal thing to do as far as I know.

from softwire.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.