Can someone explain how to get this character string to send over i2c in the Wire.write. It gives me the error "no matching function for call to 'I2CDriverWire::write(StringSumHelper&)". I am trying to send button status over i2c. Basically when I click a button, it serial prints bt5: 1 for pressed and when I release the button it sends bt5: 0 for released. I'm trying to send this info over i2c
#include <i2c_device.h>
#include <i2c_driver.h>
#include <i2c_driver_wire.h>
#include "i2c_register_slave.h"
int nbts[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 26};
int startpin = 0;
int bts[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 26};
boolean btgs[24];
void setup() {
Serial.begin(9600);
for (int i = 0; i < 24; i++) bts[i] = nbts[i];
for (int i = 0; i < 24; i++) btgs[i] = false;
for (int i = 0; i < 24; i++) pinMode(bts[i], INPUT_PULLUP);
Wire.begin(1);
// Wire.onRequest(requestEvent);
}
void loop() {
for (int i = 0; i < 24; i++) {
if (!btgs[i]) {
if (digitalRead(bts[i]) == LOW) {
Serial.print("bt" + String(i) + ":");
Serial.println(1);
btgs[i] = true;
}
}
else {
if (digitalRead(bts[i]) == HIGH) {
Serial.print("bt" + String(i) + ":");
Serial.println(0);
btgs[i] = false;
}
}
}
}
void requestEvent() {
for (int i = 0; i < 24; i++) {
if (!btgs[i]) {
if (digitalRead(bts[i]) == LOW) {
Wire.write("bt" + String(i) + ":");
Wire.write(1);
btgs[i] = true;
}
}
else {
if (digitalRead(bts[i]) == HIGH) {
Wire.write("bt" + String(i) + ":");
Wire.write(0);
btgs[i] = false;
}
}
}
delay(15);
}