void sendEvent() {
String test ="ab12";
if (Wire.available()) {
Wire.beginTransmission(8); // transmit to device #8 from #9
Wire.write(test); **// causes error**
Wire.endTransmission(); // stop transmitting
outputString = "";
}
}//end of sendEvent
I have tried both Wire.write and Wire.send both do not compile.
The error is
exit status 1
no matching function for call to 'TwoWire::write(String&)'
My IDE and AVR boards are up todate - using a Nano ATMega328P R3
Any assistance would be appreciated.
blh64
December 20, 2021, 12:49pm
3
void sendEvent() {
const char[] test ="ab12";
if (Wire.available()) {
Wire.beginTransmission(8); // transmit to device #8 from #9
Wire.write(test, sizeof(test)); **// causes error**
Wire.endTransmission(); // stop transmitting
//outputString = "";
}
}//end of sendEvent
why do you only transmit anything if something is waiting to be read? [Wire.available()]
Thank you for the correction - I thought that you needed to check if the receiver was available when sending as well as when receiving - if this is not correct -
please advise me.
blh64
December 20, 2021, 4:12pm
5
.available() indicates if bytes are available to be read, not if the receiver is ready or able to take bytes or anything else.
Look at the examples that come with the Wire library. (File->examples->Wire->....)