Qwiic Only Saving Two Characters

I am using a Qwiic OpenLog with a microcontroller, not with an Arduino board. I can communicate with OpenLog without trouble, creating files and reading the status, but when I attempt to write a string, like “Hello”, only the first two characters are saved to the file. I have a logic analyzer on the bus, so I can see all the characters are being transmitted, but only the first two characters are being saved. I sent single characters, H E L L O, and that worked fine, but there was a 10ms pause between writes while the clock stretching was honored. That seems a little slow, especially since I am using a Class 10 card, but it did prove that the communication is properly honoring clock stretching.

I duplicated all of the sketches, is there something that needs to be done in low-level communication to send multiple bytes to the logger? The characters being sent are; 0x54, 0x0C, 0x48, 0x65, 0x6c, 0x6c, and 0x6f terminated by a STOP (writes Hello). Everything was acknowledged. I then followed up with a 0x54, a 10ms clock stretch, and then a 0x11 (sync file).

I am trying to log data from the OpenScale, but no matter what I try it won’t save all of the data onto the SD Card. I am trying to create a .csv to store the data from the scale and time. I have the I2C bus running in fast mode and am saving to a custom named file that’s created at each startup instead of the created LOG***** files. I initially tried creating a string with the time (int), comma (str), and data (float) and send that at once, but it would drop the data part fairly often, so now I am sending each part one at a time with a delay in between them.

Here is how I am currently trying to save it:

void WriteToSDCard(float reading){
  //Writes data to patient file
  SDCard.append(fileName);
  int writeTime = (millis() - initTime) / 1000;
  //String data = String(writeTime) + ", " + String(reading);
  SDCard.print(writeTime);
  delay(10);
  SDCard.print(", ");
  delay(10);
  SDCard.println(reading);
  delay(10);
  SDCard.syncFile();
  //WriteToLog(data);
}

Here is what it creates in the file:

12, 26.07
12, 29.55
12, 29.63
13, 30.31
13, 30.63
14, 30.7114, 31.30
15, 31.30
15, 31.30
16, 31.30
16, 31.38
17, 31.49
17, 31.61
18, 31.79
18, 32.03
19, 32.20
19, 32.20
20, 32.20
20,32.20
21, 33.69
21, 38.54
22, 38
22, 38.65
23, 38.79
23,38.97
24, 39.26
24, 39.71
25, 40.04
25, 40.43
26, 40.98
26, 41.50
27, 42.30
27, 42.30
28, 42.30
28, 42.30
29, 42.36
29, 42.43
30, 42.50
30, 42.50
31, 42.74
31, 42.79
32, 42.93
32, 42.93
33, 42.93
33, 43.29
34, 43.29
63, 43.32
63, 43.38
64, 43.40
64, 4
65, 43.51
65, 43.60
66, 43.67
66, 43.84
67, 43.84
67, 59.85
68, 59.85
68, 59.85
69, 59.85
69, 59.85
70, 59.85
70, 59.85
71, 59.85
71, 59.85
72, 59.85
72, 59.84
73, 59.82
73, 59.82
74, 59.81
74,59.80
75, 59.80
75, 50.97
76, 40.95
76, 37.69
77, 37.69
77, 37.69
78, 37.69
78, 37.69
79, 37.69
79, 37.69
80, 37.69
80, 37.69
81, 37.69
81, 37.
82, 37.94
82, 38.04
83, 38.11
83, 38.19
84, 38.24
84, 38.29
85, 38.29
85, 38.29
86, 38.29
86, 38.29
87, 38.29
87, 38.29
88, 38.29
88, 38.29
89, 38.29
89, 38.28
90, 35.73
90, 35.73
91, 35.73
91, 35.73
92, 35.71
92, 35.65
93, 35.62
93, 35.55
94, 35.50
94, 35
95, 35.41
95, 35.41
96, 35.41
96, 34.27
97, 29.46
97, 28.44
98, 28.44
98, 28.44
99, 28.44
99, 28.44
100, 28.44
100, 28.44
101, 28.44

I’ve really beat myself up on this. I’ve tried different cards, different logger boards, adding delays, syncing the file, not syncing the file, different I2C clock speeds, you name it. The result is always the same; when sending a string of characters using address 0x0C (Write File), only the first two characters are saved to the card. Multiple writes always save to the card, but only the first two characters are saved to the card. I have no communication issues and send strings to create files, etc., only the Write command refuses to utilize more than two characters.

I am stuck.

Hi tekochip and gbazarian,

It looks like you both are running into the same problem with the Qwiic OpenLog. It might be a problem with the firmware but I will need to test this to confirm the issue or find what you and the other user may be missing. You both have covered most of the troubleshooting tips I would have recommended already (adding delays, increasing the I2C clock speed, separating strings, etc.) so I will have to test this myself as I am not sure what would be causing this issue yet.

I have merged both topics together to keep everything together for faster troubleshooting and I will get one of these pulled for testing and will update both of you on what I find out.

After testing, I was not able to replicate the issue of dropping characters using the Arduino Library. Now, for your respective issues:

First, gbazarian, try sending the data as a complete string with at least a 15ms delay in between prints. Most likely, the intermittent drops are when a new log is being triggered while the log buffer is not clear, causing “gaps” in your data. If that does not work, check the firmware version and please report what it prints when you run that sketch.

Next, tekochip, I have a feeling your issue may be related to using a previous version of the firmware. Please check which version of the firmware your Qwiic OpenLog reports and let me know what it is.

It’s reporting revision 2.

Thanks for checking that, tekochip. That would explain why the SyncFile command does not work since that was implemented in v3.0 of the firmware. It looks like there was some miscommunication between the public repository for the firmware and the programmers we use in our Production department so the shipped firmware is currently v2.0. That should be fixed soon but what might help with your issue is to try upgrading the firmware on your Qwiic OpenLog. We outline the steps to do that in [this section of the Hookup Guide if you would like to try that option.

If updating to v3.0 of the firmware still does not resolve the issue, we can try troubleshooting further but since it is working just fine using the Arduino library, I am not sure what other steps we could try to fix your problem.](Qwiic OpenLog Hookup Guide - SparkFun Learn)

I don’t use Arduino, so it would be a bit of a process to get all the tools up and going to flash the board.

All other commands are working properly, it just won’t save a string of characters. It saves one byte at a time (or even two) with a 10ms write cycle after each byte. Is there no way to save a string of characters on v2.0?

Hi again tekochip,

I spoke with one of our Engineers about this and, as it turns out if you’re just sending I2C commands directly, v2.0 of the firmware does not work with sending strings with the 0x0C command, only individual characters. It might work with a couple of characters like you have seen but in order to use the Sync File to write characters to the file, you would need to update to v3.0. The library handles this by sending that write command for each character, which is why gbazarian was seeing characters dropping without a large-enough delay in between each write.

Thanks.

I just checked my firmware as well, and both of mine say 2.0 as well. I don’t have an ftdi cable to flash the new firmware, but is it possible to flash it by using another arduino?

A short answer is no, you cannot use another Arduino to upload code to another microcontroller. Theoretically, it is possible with modifying the board, but most likely you’ll just end up uploading the Qwiic OpenLog firmware to your other Arduino since when you upload code, it will trigger the bootloader on your Arduino.

The best option would be to use a USB to Serial adapter like an FTDI cable or another USB-to-Serial device. Just make sure it is a 3.3V device since the Qwiic OpenLog runs at 3.3V.

It may not apply to you folks, but i did get the same symptoms (partial saves).

After slowing the I2C bus using

Wire.setClock(100000);

After which, some of the whacky behaviors stopped.

Was using the RedBoardTurbo with a few other Qwiic sensors in the line. The OpenLog was version 2.0. SO i gotta go shopping for a 3.3V FTDI.

FWIW.