I2C String Send

I’ve built a drone using an STM32, I can’t get it to work with the SD library (which is a separate issue) and in order to debug the drone while flying I thought I could send the data over i2c to an Arduino Nano in a Master/Slave arrangement which would then be able to log it to an SD card.

The string is 9 floats separated by commas to create a CSV on the SD card.

What I’m not sure about doing is splitting the string up into byte chunks, perhaps within an array then sending them over 1 by 1 and recompiling then string at the other end.

Any guidance on how to approach this would be greatly received.

There is going to be a cable between the drone and the Nano?

Sorry yes I should have made myself a little clearer.

I can’t get the STM32 which is the flight computer to work with the SD library. So I thought about using an Arduino Nano on the drone that talks to the STM32 via i2c. The STM32 sends over ~40bytes of data at 50Hz which the onboard Nano then logs onto the SD card.

jaddion82052:
What I’m not sure about doing is splitting the string up into byte chunks, perhaps within an array then sending them over 1 by 1 and recompiling then string at the other end.

Any guidance on how to approach this would be greatly received.

I2C sends chunks of bits at a time. To use I2C the data is broken down into chunks of bits and reassembled at the other end. That's how it works. What's to be unsure of?

if (!myFile.open(filename, O_RDWR | O_CREAT | O_AT_END)) {}
    String dataString = String(ID) + ", " + String(timer) + ", " + String(altitude_ft) 
    + ", " + String(altitude_m) + ", " + String(dHdT) + ", " + String(g) + ", " + String(Accel_Vel) + 
    "," + String(phase); 
    myFile.println(dataString); 
    myFile.flush();

This is the code from a data logger I made, it logs from a Nano onto an SD card. This is the sort of CSV format I would like to send over i2c so that the data logging side of it can just dump these strings onto a SD card.

If I try sending a string in the Wire.write function I get errors such as
"no matching function for call to ‘TwoWire::write(String)’ "

https://www.arduino.cc/en/Reference/WireWrite

You might want to refer to the documentation of the STM core, some research is required on your part, you are using to confirm the 2 wire write method is the same as the Uno 2 wire write method.

Initially I’m just trying to get it to run on 2 Nanos before trying it on the STM32.

From what I’ve read you can’t send strings but arrays of chars. I’ve converted the string into a char array and will try sending that over.

jaddion82052:
Initially I’m just trying to get it to run on 2 Nanos before trying it on the STM32.

From what I’ve read you can’t send strings but arrays of chars. I’ve converted the string into a char array and will try sending that over.

Reads like your on the right track. Good job.

The string is 9 floats separated by commas to create a CSV on the SD card.

From what I've read you can't send strings but arrays of chars. I've converted the string into a char array and will try sending that over.

The wire library transmissions are limited to 32 bytes, so you may need to break the transmission into pieces.