Ok, not really scientific and kind of trivial in fact, but might help someone.
The aircon timer at the office is out of whack, so it only powers up at 12h48 on Mondays after being off the weekend. Nobody seems to know where the timer is located, to fix that. Nor do they care much about the office conditions and it's summer here. Pretty uncomfortable by the time it powers up.
So, I put together a data logger to provide some evidence to the H&S folks, not that they give a rat's. I start at 0600 so I'll have 7hr of readings by the time it kicks in.
- Uno with prototype shield and tiny breadboard
- DHT11
- Tiny adafruit oled I2C display
- DS1307 RTC module with battery backup
Screen shows current humidity and temp on top line, min and max since power up under that. I arbitrarily chose to log at XXh15, XXh35 and XXh55, capturing the time, humidity and temperature to the on-board EEPROM.
Here's the code, and Circuit schematic below.
UPDATED sketch in Reply #2, with thanks to Rob Tilliart.
/*
read h and t from dht
catch min and Max
Display on oled
Log temp and humidity to eeprom at specified minutes past hour.
reminder: sda a4, scl a5 on uno
*/
// libraries
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <dht11.h>
#include <EEPROM.h>
// screen
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
//dht
dht11 DHT;
#define DHT11_PIN 2
int dht_read;
int minTemp=50; //first actual reading will replace this
int maxTemp=0; //first actual reading will replace this
int curTemp;
int humid;
//logging
int logLed=A0;
int hourAddress=91; //just some random start point
boolean tempLogged = false;
//time
tmElements_t tm;
void setup()
{
Serial.begin(9600);
Serial.println("dht v2 14 dec");
pinMode(logLed, OUTPUT);
digitalWrite(logLed, LOW);
//oled screen initialise
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(2500);
// Clear the buffer.
display.clearDisplay();
}
void loop() {
// read the dht
dht_read = DHT.read(DHT11_PIN);
humid=DHT.humidity;
curTemp=DHT.temperature;
if (curTemp<minTemp) minTemp=curTemp;
if (curTemp>maxTemp) maxTemp=curTemp;
// text display
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
display.print("H");
display.print(humid);
display.print("% T");
display.print(curTemp);
display.print("C");
display.setCursor(0,16); // text line 2 = 16 pixels
display.print("m");
display.print(minTemp);
display.print("C M");
display.print(maxTemp);
display.print("C");
display.display();
//check if it's time to write to EEPROM
if (RTC.read(tm)) {
//Serial.println(tm.Minute);
if (tm.Minute==15 || tm.Minute==35 || tm.Minute==55)
{
if (tempLogged == false)
{
//Serial.println("led on");
digitalWrite(logLed, HIGH);
delay(100);
digitalWrite(logLed, LOW);
//Serial.println("led off");
doEEPROM();
tempLogged = true;
} //end of false if
} // end of right time if
}//end of if read time
if (tm.Minute!=15 && tm.Minute!=35 && tm.Minute!=55)
{
tempLogged = false;
} //end of wrong time if
delay(3000); //only read dht >2secs apart
}
void print2digits(int number) { //ala jim
if (number >= 0 && number < 10) {
display.print('0');
}
display.print(number);
}
void doEEPROM()
{
EEPROM.write(hourAddress, tm.Hour);
delay(5);
EEPROM.write(hourAddress+1, tm.Minute);
delay(5);
EEPROM.write(hourAddress+2, curTemp);
delay(5);
EEPROM.write(hourAddress+3, humid);
delay(5);
hourAddress=hourAddress+4; //for next time
}
Big challenge is to remember to take it to work tomorrow.....