Open nicolasdb opened 1 year ago
The logSDCard() function concatenates all the information in the dataMessage String variable. Each reading is separated by commas.
dataMessage = String(readingID) + "," + String(dayStamp) + "," + String(timeStamp) + "," + String(temperature) + "\r\n"; Note: the “\r\n” at the end of the dataMessagevariable ensures the next reading is written on the next line.
Then, with the following line, we write all the information to the data.txt file in the microSD card.
appendFile(SD, "/data.txt", dataMessage.c_str()); Note: the appendFile() function only accepts variables of type const char for the message. So, use the c_str() method to convert the dataMessage variable.
writeFile() and appendFile() The last two functions: writeFile() and appendFile() are used to write and append data to the microSD card. They come with the SD card library examples and you shouldn’t modify them.
I start to put different thing together like
Code is here : https://github.com/nicolasdb/M5Stamp-C3U/blob/dataLoggerAll/src/main.cpp but I get a buffer error when push button:
Appending to file: /log.txt
- message appended
1021 , Temp: 20°C , 54%
Appending to file: /log.txt
- message appended
905 , Temp: 20°C , 54%
Button Pressed!
Reading file: /log.txt
- read from file:
Reading LDR, Temperature
%s:%u] %s(): Bus already started in Slave Mode.
20,54
%s:%u] %s(): Can't allocate memory for I2C_%d txBuffer
20,54
bug solved, I just did some crap on the code when aggregating data
Adding OLED printing, I notice that the AM2320 fell asleep automaticaly and values locked.
So, as I read here it's important to keep it awake before every reading.
Adding this before the reading did the trick.
int status = AM2320.read();
switch (status)
{
case AM232X_OK:
Serial.println(">>>>> sensor awake ᕙ(`▿´)ᕗ");
break;
default:
Serial.println(status);
break;
}
temp = AM2320.getTemperature();
hum = AM2320.getHumidity();
plot data on graph: follow this one https://randomnerdtutorials.com/esp32-esp8266-plot-chart-web-server/
note: this will request sensor reading from the html page.... donc pas de sauvegarde d'un log long terme.... sauf si le site tourne en background?? Mais ça serait plus logique d'écrire les données dans un log.txt
https://techexplorations.com/blog/esp32/blog-esp32-how-to-retrieve-a-file-from-the-spiffs/
how to create a wifi access point? instead of connecting to local wifi. ah! https://randomnerdtutorials.com/esp32-access-point-ap-web-server/
https://github.com/fabianoriccardi/ESPLogger/