Hi all, basically what I'd like to do is in the title. I'd like to display the high and low temperatures for the current day and when it is midnight have that part on the screen to reset.
Also, when logging to an SD card, I notice when I take out my SD card with the program running to get the data, that after I plug it back in if another reading has been taken before then, it won't log anymore. I have to unplug and replug or hit the reset button. This isn't a big deal to do of course, I was hoping you all had any tips that would allow the data to be logged to an SD card after putting it back in the module without having to reset Arduino. Below is my current code. It's making me split it up because of character limits. Thanks!
#include "Wire.h"
#define P0 1013.25
#include "DHT.h"
#include <SPI.h>
#include <SD.h>
#include <stdlib.h>
#include "Sodaq_DS3231.h"
#include <BME280_MOD-1022.h>
#include "Ucglib.h"
Ucglib_ST7735_18x128x160_SWSPI ucg(/*sclk=*/ A12, /*data=*/ A11, /*cd=*/ A10 , /*cs=*/ A9, /*reset=*/ A8);
void printFormattedFloat(float x, uint8_t precision) {
char buffer[10];
dtostrf(x, 7, precision, buffer);
Serial.print(buffer);
}
// print out the measurements
void printCompensatedMeasurements(void) {
float temp, humidity, pressure, pressureMoreAccurate;
double tempMostAccurate, humidityMostAccurate, pressureMostAccurate;
char buffer[80];
temp = BME280.getTemperature();
humidity = BME280.getHumidity();
pressure = BME280.getPressure();
pressureMoreAccurate = BME280.getPressureMoreAccurate(); // t_fine already calculated from getTemperaure() above
tempMostAccurate = BME280.getTemperatureMostAccurate();
humidityMostAccurate = BME280.getHumidityMostAccurate();
pressureMostAccurate = BME280.getPressureMostAccurate();
Serial.println(" Good Better Best");
Serial.print("Temperature ");
printFormattedFloat(temp, 2);
Serial.print(" ");
printFormattedFloat(tempMostAccurate, 2);
Serial.println();
Serial.print("Humidity ");
printFormattedFloat(humidity, 2);
Serial.print(" ");
printFormattedFloat(humidityMostAccurate, 2);
Serial.println();
Serial.print("Pressure ");
printFormattedFloat(pressure, 2);
Serial.print(" ");
printFormattedFloat(pressureMoreAccurate, 2);
Serial.print(" ");
printFormattedFloat(pressureMostAccurate, 2);
Serial.println();
}
const byte pink14 = A0;
const byte blue2 = A1; // wired output - R - Gnd High = illuminated all 3
const byte yellowgreen3 = A2;
const byte green4 = A3;
const byte yellow5 = A4;
const byte orange6 = A5;
const byte red7 = A6;
const byte white8 = A7;
#define DHTPIN 9 // what digital pin we're connected to
const int chipSelect = 53;
float time;
// Uncomment whatever type you're using!
#define DHTTYPE DHT22 // DHT 22
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
Wire.begin();
rtc.begin();
Serial.print("Initializing SD card...");
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
Serial.println("BMP DHT22 Measurement");
dht.begin();
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
//ucg.begin(UCG_FONT_MODE_SOLID);
ucg.clearScreen();
pinMode(pink14, OUTPUT);
pinMode(blue2, OUTPUT);
pinMode(yellowgreen3, OUTPUT);
pinMode(green4, OUTPUT);
pinMode(yellow5, OUTPUT);
pinMode(orange6, OUTPUT);
pinMode(red7, OUTPUT);
pinMode(white8, OUTPUT);
}
void loop()
{
delay(300000);
time = millis();
//ucg.setRotate270();
ucg.clearScreen();
ucg.setFont(ucg_font_7x14B_tf);
ucg.setColor(1, 0, 0, 255);
ucg.setColor(255, 255, 255);
//ucg.setColor(0, 255, 0);
ucg.setPrintPos(0, 15);
uint8_t chipID;