Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data logger on SPIFFS #8

Open
nicolasdb opened this issue Sep 19, 2022 · 5 comments
Open

data logger on SPIFFS #8

nicolasdb opened this issue Sep 19, 2022 · 5 comments
Assignees
Labels
⚔️ WIP ⚔️ work in progress

Comments

@nicolasdb
Copy link
Owner

https://github.com/fabianoriccardi/ESPLogger/

@nicolasdb
Copy link
Owner Author

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.

@nicolasdb nicolasdb self-assigned this Sep 25, 2022
@nicolasdb nicolasdb added the ⚔️ WIP ⚔️ work in progress label Sep 25, 2022
@nicolasdb
Copy link
Owner Author

I start to put different thing together like

  • wait for a timer1.refresh; then timer1.SetOnTimer(probe);
  • reading LDR sensor on pin3
  • reading AM2320 sensor on I2C
  • creating a string with the values
  • save the line on SPIFFS log.txt
  • if push button, read log.txt

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

@nicolasdb nicolasdb added bug Something isn't working help wanted Extra attention is needed and removed bug Something isn't working help wanted Extra attention is needed labels Sep 25, 2022
@nicolasdb
Copy link
Owner Author

bug solved,
I just did some crap on the code when aggregating data

@nicolasdb
Copy link
Owner Author

nicolasdb commented Sep 27, 2022

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();

@nicolasdb
Copy link
Owner Author

plot data on graph:
follow this one https://randomnerdtutorials.com/esp32-esp8266-plot-chart-web-server/

but first:

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/

then,

how to create a wifi access point? instead of connecting to local wifi.
ah!
https://randomnerdtutorials.com/esp32-access-point-ap-web-server/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚔️ WIP ⚔️ work in progress
Projects
None yet
Development

No branches or pull requests

1 participant