No, the I2C interface is lazy. Once 32 bytes have been sent out, the port becomes completely inoperative and no more data can be sent. That is why only devices that use less than 32 bytes, like LCD displays, can be used...
NOT! Of course you can send multiple messages of 32 bytes!!!! Just use the null terminator (or a designated symbol) as an end of message marker.
For variable length strings, you're probably better off sending individual bytes. Just for simplicity.
We don't have godlike powers that would allow us to see everything that you did... do not post snippets of code, they do not provide sufficient context and do not support third party testing. Post entire, compilable sketches. In this particular case, you need to provide the code for both sending and receiving.
I have not submitted a sketch. It is hoped that the concerned poster will insert the codes at the appropriate place of the Master Sketch and then will report the functionality of the codes to establish the validity of the following excerpt of post #4.
Why do you want to use the I2C bus ? Using the I2C bus to communicate between microcontrollers is a bad idea. Can you use a Serial port ?
The newer Arduino boards have a maximum data size of 256 bytes, only the basic Arduino boards have a maximum of 32 bytes for the I2C bus. Perhaps you can solve the problem with a newer board, such as the MKR Zero.
It is possible to split the data into chunks of maximum 32 bytes, but they have to be glued together in the Slave. That means you have to add extra code for the administration.
Can you tell more about your project ?
If you can do your whole project with a single Arduino board, then it will be easier. Maybe you have to buy a new Arduino board, but the goal is to have a working project.
No one uses a variable text over I2C (well, almost no one). Using fixed sized packages of binary data is more suitable for the I2C bus.
Splitting a project over two Arduino boards with a I2C bus in between makes it ten times harder (just kidding, it is more than ten times). It might not even work if you use a library in the Slave that disables the interrupts (Neopixel, FastLED, OneWire, DHT, SoftwareSerial, and so on).
The ESP8266 runs at 3.3V and the Arduino Uno runs at 5V. That means you are connecting a 3.3V I2C bus to a 5V I2C bus. It is better if you use a I2C level shifter between them.
If you are going to add motors to your project, then things get very nasty and you might have to redesign your whole project.
no, that's only one transaction you need multiple blocks like this
Wire.beginTransmission();
Wire.write(); ... // less than 32
Wire.endTransmission();
and so a small protocol around it that says "I'll be sending 150 bytes in 5 transactions so make a note that the next 5 data transfer are actually just one big payload delivered in packets"
I am expecting to have (yes/no) answers of the following two questions without doing any experiments in the context of your this statement of post #4:"For variable length strings, you're probably better off sending individual bytes. Just for simplicity".
1. Do you think that the following Master and Slave sketches will exchange 35-byte data? 2. Do you think that the variable howMany in the Slave sketch will hold 35?
Now, you connect two Arduinos, upload the sketches of post #14, and verify your above answers by printing the value of the variable howMany at the Slave's Serial Monitor. The Slave knowns how many bytes it has received from Master (in one transaction bounded by beginTransmission()/endTransmission()) and then copies it into variable howMany.
You need to add codes with Slave Sketch (shown below) to transfer the value of howMany into a global variable and then print it in the loop() function testing the true state of a flag activated in the receiveEvent() routine.
volatile bool flag = false;
int count;
void loop()
{
if (flag == true)
{
Serial.println(count);
flag = false;
}
}
void receiveEvent(int howMany)
{
count = howMany;
for (int i = 0; i < howMany; i++)
{
myData[i] = Wire.read();
}
flag = true;
}