Storing DHT22 data to plot temperature on gLCD

Hello, I need some guidance with my idea: I have a DHT22 connected to my Leonardo, and I want to plot the temperature history on my ST7565 gLCD. I thought about saving temp every 2-5 mins to EEPROM and then using u8glib somehow print that by connecting dots with lines.

[u]Questions:[/u] - how to obtain such a long period (2-5 minutes) in order to send a command "store data" if timers provide much, much smaller periods? - is EEPROM a good idea for this? - how to read data afterwards and pass it to u8glib functions?

Every form of help is highly appreciated!

What is the resolution of your plot? The whole screen is 128x64 so that is the maximum if you don't use any labels.

EEPROM has limited life and you probably don't need to display data gathered before a power failure anyway. I would scale the data to fit in a byte and store the data in a byte array in SRAM. Use the array as a circular buffer. Then you only need 128 (or fewer) bytes to store the entire plot.

To display the plot: Scan the array for Max and Min values. Erase the display. For each X position in the GLCD, scale that entry to the 0-63 range and plot a dot at that X,Y Somewhere on the screen print the Min and Max temperature values.

Thank you johnwasser! What about my first question. Is millis() function (and checking whether it is equal to eg. 300000 = 5 min) a correct way to temperature reading every x minutes?

Pole92:
I want to plot the temperature history on my ST7565 gLCD.
I thought about saving temp every 2-5 mins to EEPROM and then using u8glib somehow print that by connecting dots with lines.

Why don’t you send the data direct to the screen? The choice of using an EEPROM or not merely means - do you get some data now or do you wait to get the whole lot later? If you’ve got a good reason for waiting, you justify the eeprom, otherwise it’s redundant.

Rather similarly, connecting the dots with lines is a pointless waste of space. If you want to expand the x-axis scale, it is simpler to send the data more frequently.

Pole92: What about my first question. Is millis() function (and checking whether it is equal to eg. 300000 = 5 min) a correct way to temperature reading every x minutes?

Yes.

void loop() {
     unsigned long currentMillis = millis();
     static unsigned long lastMillis = 0;
     if (currentMillis - lastMillis >= (5*60*1000UL)) {
        lastMillis += (5*60*1000UL);
       // This code gets executed every 5 minutes
    }
    // The rest of loop() gets executed every time
}