Wire Library
Implements I2C on Z-Uno pins 9–16. Default is 9 for SCL and 10 for SDA. Other pin range can be selected using ZUNO_REMAP_SPINS() This library allows you to communicate with I2C devices.- begin()
- requestFrom()
- beginTransmission()
- endTransmission()
- write()
- available()
- read()
- enableTS()
- Wire(Wire0) — i2c on SCL(9) and SDA(10) pins (default)
- Wire1 — i2c on SCL1(23) and SDA1(25) pins
Pinout
Compatibility pin table
| Z-Uno pin number | Wire0 SCL | Wire0 SDA | Wire1 SCL | Wire1 SDA |
|---|---|---|---|---|
| 0 | ✔ | ✔ | ✘ | ✘ |
| 1 | ✔ | ✔ | ✘ | ✘ |
| 2 | ✔ | ✔ | ✘ | ✘ | 3 | ✔ | ✔ | ✘ | ✘ |
| 4 | ✔ | ✔ | ✘ | ✘ |
| 5 | ✔ | ✔ | ✘ | ✘ |
| 6 | ✔ | ✔ | ✘ | ✘ |
| 7 | ✔ | ✔ | ✘ | ✘ |
| 8 | ✔ | ✔ | ✘ | ✘ | 9 | ✔ | ✔ | ✘ | ✘ |
| 10 | ✔ | ✔ | ✘ | ✘ |
| 11 | ✔ | ✔ | ✘ | ✘ |
| 12 | ✔ | ✔ | ✘ | ✘ |
| 13 | ✔ | ✔ | ✘ | ✘ |
| 14 | ✔ | ✔ | ✘ | ✘ | 15 | ✔ | ✔ | ✘ | ✘ |
| 16 | ✔ | ✔ | ✘ | ✘ |
| 17 | ✔ | ✔ | ✘ | ✘ |
| 18 | ✔ | ✔ | ✘ | ✘ |
| 19 | ✔ | ✔ | ✘ | ✘ |
| 20 | ✔ | ✔ | ✘ | ✘ | 21 | ✔ | ✔ | ✘ | ✘ |
| 22 | ✔ | ✔ | ✘ | ✘ |
| 23 | ✔ | ✔ | ✔ | ✔ |
| 24 | ✔ | ✔ | ✘ | ✘ |
| 25 | ✔ | ✔ | ✔ | ✔ |
- available()
- begin()
- beginTransmission()
- end()
- endTransmission()
- read()
- requestFrom()
- setClock()
- setWireTimeout()
- transfer()
- write()
#define SCL_PIN 11
#define SDA_PIN 12
I2CDriver alternative_I2C(SCL_PIN, SDA_PIN);
void setup() {
// …
Wire.bindDriver(&alternative_I2C); // This instructs to use other pins than default
// …
}
#include "Wire.h"
void setup() {
Wire.begin(0, 1, 2); // join i2c bus
// 0 - is a default master address,
// We use alternate SCL pin = 1, SDA pin =2
Serial.begin(115200); // start serial for debug output
}
void loop() {
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
while (Wire.available()) { // slave may send less than requested
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
}