How to send multiple 32 byte strings to I2C?

How to send multiple 32 byte strings to I2C?

– Stack Overflow How do I send multiple 32 byte strings to I2C master? I have multiple variable length strings which do not exceed 32 bytes each which need to be sent via I2C between 2 Arduino Nanos. I use # to terminate each string.

How to send strings via I2C between 2 Arduino Nanos?

I have multiple variable length strings which do not exceed 32 bytes each which need to be sent via I2C between 2 Arduino Nanos. I use # to terminate each string. I can successfully send and receive the first string, but for the life of me I can’t figure out how to send the succeeding strings. The samples I am testing with look like this:

Which is an example of sending multiple bytes?

The next example is where the master requests 1 byte and the slave responds with one number and everything works as it should. The real problem is when the master requests two or more bytes and the slave sends back that number of bytes when it is not a string. Here is example code that demonstrates this issue.

What kind of data can be transferred via I2C?

Basically we convert any value, string, number, text, float, you name it, and turn into a variable char, which can be transferred via I2C. Once transferred, you can convert back to a number although in my case below, I just wanted to display the data from the slave. Here is the code.

What is the problem with sending multiple bytes?

The real problem is when the master requests two or more bytes and the slave sends back that number of bytes when it is not a string. Here is example code that demonstrates this issue. If you run this code and open the serial monitor port associated with the master Arduino, you should see that it will print out a weird symbol and the number 2.

When to use and characters in Arduino I2C?

The & and | characters are used for bitwise addition. You can find more info with a quick google search but an example would be that 11111111 & 10101010 = 10101010 and 10101010 | 01010101 = 11111111. Finally, we will also be using << which shifts bits to the left and >> which shifts bits to the right.