sparkfun / Qwiic_OpenLog

Open source I2C based datalogger. The bigger, better cousin to the original serial OpenLog.
Other
24 stars 6 forks source link

Characters dropped on Teensy 4.0 #6

Open robertstuart opened 4 years ago

robertstuart commented 4 years ago

When I compile and run the code below for a Teensy 4.0, many characters are dropped. A typical output is also shown below. The errors seem to be random. Adding delay(20) lines in the code seems to have no effect. When I run the same code on an Arduino Mini Pro, the output is perfect. I really, really would like to get this fixed. Any ideas?

Just as a side note, I should mention that there is a compile error when compiling for a Teensy 3.2. I don't need this but I thought someone should know.


#include <Wire.h>
#include "SparkFun_Qwiic_OpenLog_Arduino_Library.h"
OpenLog myLog; //Create instance

int ledPin = 13; //Status LED connected to digital pin 13
char message[100] = "";

void setup() {
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
  Wire.begin(); //Initialize I2C
  myLog.begin(); //Open connection to OpenLog (no pun intended)
  for (float i = 0.0; i < 9.1; i += 0.5) {
    Serial.print(i); Serial.print(",");
    myLog.print(i); myLog.print(",");
    Serial.print(sqrt(i)); Serial.print(",");
    myLog.print(sqrt(i)); myLog.print(",");
    Serial.print(i / 0.99); Serial.print(","); 
    myLog.print(i / 0.99); myLog.print(","); 
    Serial.print(i * 1.1), Serial.print(",");
    myLog.print(i * 1.1), myLog.print(",");
    Serial.println(i);
    myLog.println(i);
  }
  myLog.syncFile();
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(1000);
}
0.00,0.00,0.00,0.00,0.00
0.50,0.710.51,0.55,0.50
1.00,1.00,1.01,1.10,1.00
1.50,1.22,1.52,1.65,1.50
2.00,1.41,2.02,2.20,2.00
2.50,1.58,2.53,2.75,2.50
3.00,1.73,3.03,3.30,3.00
3.50,1.87,3.5,3.85,3.50
4.00,2.00,4.04,4.40,4.00
4.50,2.12,4.55,4.95,4.50
5.00,2.24,5.05,5.50,5.00
5.0,2.35,5.56,6.05,5.50
6.00,2.45,6.06,6.60,6.00
6.50,2.55,6.57,7.15,6.50
7.00,2.65,7.07,7.0,7.00
7.50,2.74,7.58,8.25,7.50
8.00,2.83,8.08,8.80,8.00
8.50,2.92,8.59,9.35,8.50
9.00,3.00,9.09,9.90,9.0
Gambit120 commented 3 years ago

I am having the same issue on the teensy 4.0. I read some ware that there need to be a short delay between each character not between each write. I thought the library would have done this for you but it looks like you need to do it in your code.