Hey Leute,
ich möchte gerne arraydaten mit ID in einer .csv datei auf meiner SD Karte speichern.
Dazu bekomm ich einen pointer *array_pointer auf die erste Zelle des arrays.
Hab schon viele Tutorials gesehen und auch schon nachgeschrieben. Da hat das speichern auch geklappt. Jetzt hab ich aber den Code mit zu dem kompletten Programm zugefügt (wir arbeiten zu dritt an dem Code) und jetzt klappt natürlich gar nichts.
Das Ding ist nur der header String wird gespeichert, aber nicht der datastring. Ist doch voll komisch? Wenn ich wieder auf meinen alten Code zurück ruder klappt natürlich alles.
Danke für die Hilfe schon mal
void setup() {
Serial.begin(115200);
p_EKG_state_1 = &EKG_state_1;
pinMode(CS_Pin, OUTPUT);
if(!SD.begin(CS_Pin))
{
Serial.println("Card failed or not present");
}
EKG_data_transmision.matrixData = SD.open("/data.csv", FILE_APPEND); //erstelle data.csv datei
if(EKG_data_transmision.matrixData)
{
String header = "ID; Value;";
EKG_data_transmision.matrixData.println(header);
EKG_data_transmision.matrixData.close();
Serial.println(header);
Serial.println("card init sucess");
}
else
{
Serial.println("Couldnt open vector data file");
}
}
Here is the function where everything should go down.
bool EKG_data_transmision::write_matrix_to_SD(unsigned short *array_pointer)
{
if(!SD.begin(CS_Pin))
{
Serial.println("Card failed or not present");
return 1;
}
matrixData = SD.open("/data.csv", FILE_APPEND); //erstelle data.csv datei
if(matrixData)
{
//sd karte immer noch da und schau ob data.csv exisitiert
while(matrix_coloum < 3070)
{
if(matrix_coloum == 1024 || matrix_coloum == 2048)
{
header = "ID; Value;\n";
matrixData.println(header);
}
dataString = String(matrix_coloum) + "; " + "\n"; // + String(*array_pointer)
matrixData.println(dataString);
//Serial.println("This is datastring:");
Serial.println(dataString);
array_pointer++;
matrix_coloum++;
}
}
else{
Serial.println("Error writing to file !");
}
matrixData.close(); // close the file
return 0;
}
Here is the class
#include "Arduino.h"
#include <WiFi.h>
#include "SD.h"
#include "SPI.h"
#include <vector>
#include <string>
class EKG_data_transmision
{
private:
String dataString;
String header;
unsigned short matrix_coloum = 0;
public:
EKG_data_transmision();
File matrixData;
//Def Funktions:
bool write_matrix_to_SD(unsigned short *array_pointer);
bool delete_matrix_from_SD(unsigned int record);
bool send_record_to_DB(unsigned int record);
bool connect_wifi(char* ssid, char *password);
unsigned int count_record_from_SD();
unsigned int get_last_record_from_SD();
void set_sendingprogress(unsigned int record);
unsigned int get_sendingprogress(unsigned int record);
void set_wifi_password(char* password);
char* get_wifi_password();
void set_wifi_ssid(char* ssid);
char* get_wifi_ssid();
};
Wenn ich anstatt matrixdata.println(), matrixdata.write() schreiben will bekomm ich diesen Fehler:
sketch\EKG_data_transimission.cpp: In member function 'bool EKG_data_transmision::write_matrix_to_SD(short unsigned int*)':
EKG_data_transimission.cpp:32:34: error: no matching function for call to 'fs::File::write(String&)'
matrixData.write(header);
^
In file included from C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD\src/SD.h:17:0,
from sketch\EKG_data_transmision.h:3,
from sketch\EKG_data_transimission.cpp:2:
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:54:12: note: candidate: virtual size_t fs::File::write(uint8_t)
size_t write(uint8_t) override;
^
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:54:12: note: no known conversion for argument 1 from 'String' to 'uint8_t {aka unsigned char}'
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:55:12: note: candidate: virtual size_t fs::File::write(const uint8_t*, size_t)
size_t write(const uint8_t *buf, size_t size) override;
^
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:55:12: note: candidate expects 2 arguments, 1 provided
EKG_data_transimission.cpp:35:34: error: no matching function for call to 'fs::File::write(String&)'
matrixData.write(dataString);
^
In file included from C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD\src/SD.h:17:0,
from sketch\EKG_data_transmision.h:3,
from sketch\EKG_data_transimission.cpp:2:
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:54:12: note: candidate: virtual size_t fs::File::write(uint8_t)
size_t write(uint8_t) override;
^
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:54:12: note: no known conversion for argument 1 from 'String' to 'uint8_t {aka unsigned char}'
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:55:12: note: candidate: virtual size_t fs::File::write(const uint8_t*, size_t)
size_t write(const uint8_t *buf, size_t size) override;
^
C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS\src/FS.h:55:12: note: candidate expects 2 arguments, 1 provided
Multiple libraries were found for "WiFi.h"
Used: C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Program
Multiple libraries were found for "SD.h"
Used: C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
Not used: C:\Program
Not used: C:\Users\Valentin\Documents\Arduino\libraries\SD
Multiple libraries were found for "FS.h"
Used: C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS
Multiple libraries were found for "SPI.h"
Used: C:\Users\Valentin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPI
exit status 1
no matching function for call to 'fs::File::write(String&)'
Ich hab anscheinend viele SD libraries, aber wenn ich die SD library von arduino benutzen will bekomm ich auch einen Fehler die architektur oder das esp32 board nicht supported wird