Hi everyone!
*my english might be lacking so I'm sorry in advance
I'm really new to this and it's my first time posting here but I can't do it alone
please help me find the right way
So I have an Arduino Uno R3 /
Data logger shield from Elegantstunning bought on amazon (the RTC on it, is DS1307)
/ OLED SSD1315 ( from arduino-seeds)
I'm trying to display a text with differents variables ( my BPM, the time and date as shown in the screenshot below) from the Data logger shield SD card on the OLED BUT the issue is that it is showing on the serial monitor (moniteur série) and not on the OLED (all I see is BPM:430)
I suspect it the " int" part in the code, I've tried to change it (SD.open("BPM.txt", FILE_READ or text ...) but I don't know what to put instead
the Arduino Uno is at the bottom then in the middle the Base Shield to connect the OLED * from Arduino Sensor Kit - Bundle* and the datalogger shield on top
- here is the text in the serial monitor**
Initializing SD card...Writing to test.txt...testing 1, 2, 3.done.
BPM.txt:
Date,Time,BPM
2021/10/17,11:52:48,104,
2021/10/17,11:52:48,109,
2021/10/17,11:52:49,116,
2021/10/17,11:52:49,114,
Date,Time,BPM
2021/10/17,11:52:53,94,
2021/10/17,11:52:54,97,
2021/10/17,11:52:59,47,
Date,Time,BPM
2021/10/17,11:53:23,37,
2021/10/17,11:53:29,49,
2021/10/17,11:53:32,83,
2021/10/17,11:53:33,82,
2021/10/17,11:53:34,82,
2021/10/17,11:53:35,81,
2021/10/17,11:53:36,80,
2021/10/17,11:53:36,80,
2021/10/17,11:53:37,78,
2021/10/17,11:53:38,76,
here is the code (a mix of Arduino_SensorKit, SD library and from this forum [Getting text from an SDcard and printing it on an Oled display])
#include "Arduino_SensorKit.h"
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
String text;
const int chipSelect = 10;
File myFile;
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("BPM.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.print("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("BPM.txt", FILE_READ);
if (myFile) {
Serial.println("BPM.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
text = myFile.readString();
delay(100);
//Serial.println(text);
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
Serial.println(text);
// Oled.setFont(u8x8_font_chroma48medium8_r);
//Oled.setCursor(0, 3);
Oled.begin();
Oled.setFlipMode(true);
}
void loop() {
int BPM = "BPM.txt", FILE_READ; // read file
Oled.setFont(u8x8_font_chroma48medium8_r);
Oled.setCursor(0, 33);
Oled.print("BPM: ");
Oled.print(BPM);
Oled.refreshDisplay();
delay(1000);
}
Thank you!