The Indoor Well-Being Logger captures environmental conditions throughout the day using temperature, humidity, light, and sound sensors connected to an Arduino Uno with real-time clock backup. Data is logged to EEPROM at regular intervals and can be exported for analysis of how indoor conditions affect comfort and productivity.
This guide provides a complete wiring diagram, parts list, and step-by-step assembly instructions to build the logger from common components. The included firmware handles sensor sampling, time-stamped data storage, and serial export functionality, with a red LED indicator showing when data has been recorded.
Wiring diagram

Gather all the parts
Assemble it in 6 steps
1. Simplify the circuit with power disconnected
Remove the LCD, four buttons, buzzer, and green and blue LED resistors and their wires. Leave the RGB green and blue pins disconnected. Keep the existing sensor pins unchanged.
2. Connect power and clock
Connect UNO 5V and GND to breadboard rails. Bridge split rails. DS1302 VCC to 5V, GND to ground, CLK to D7, DAT to D8, and RST or CE to D9. Use the power bank through the UNO USB socket; disconnect it before connecting PC USB.
- Never connect 9V to the 5V rail. Check the power bank stays on with this load.
- Firmware disables RTC trickle charging. Do not use a non-rechargeable coin cell with a separate always-on charger.
3. Connect temperature sensors
DHT11 module VCC to 5V, GND to ground, DATA to D2. Module must include its data pull-up. LM35DZ flat face toward you with leads downward has left supply to 5V, middle output to A0, right ground to GND. Keep it away from the UNO regulator.
4. Connect light and sound
Photoresistor between 5V and A1. Connect the 10 kiloohm resistor from A1 to ground. The microphone that heated up must remain completely disconnected, including its signal wires. Ignore the sound column while it is disconnected; do not reconnect a possibly damaged module. Light and sound readings are relative indices, not lux or decibels.
5. Connect the export indicator
Common-cathode RGB common pin to GND. Connect D11 through one 220 ohm resistor to the red pin. Leave green and blue disconnected. Solid red means 96 readings collected or memory full; blinking red means set the clock; off means normal logging.
- This wiring requires a common-cathode RGB module. Do not omit the series resistor.
6. Set time and export daily
Deploy with PC USB. At 9600 baud send TIME yyyy-mm-dd hh:mm:ss with your actual local time and a newline. Test mode logs every 15 seconds. After testing, change LOG_INTERVAL_SECONDS from 15UL to 3600UL and redeploy for hourly logging. Solid red comes on after 96 stored readings (about 24 minutes in test mode); empty memory fills in about 28 minutes. Connect PC USB and send DUMP, save CSV, then send CLEAR only after checking your saved data. CLEAR turns off the reminder. Memory holds 113 readings and then stops, without overwriting. Existing records remain compatible but CSV no longer includes ratings. Track well-being separately using matching local timestamps.
Review all connections
1. Connections between "dht" and "Arduino"
2. Connections between "rtc" and "Arduino"
3. Connections between "lm35" and "Arduino"
4. Connections between "light" and "Arduino"
5. Connections between "divider" and "Arduino"
6. Connections between "mic" and "Arduino"
7. Connections between "redR" and "Arduino"
8. Connections between "rgb" and "Arduino"
9. Connections between "powerbank" and "Arduino"
Deploy the firmware
#include <Arduino.h>
#include <EEPROM.h>
#include <ThreeWire.h>
#include <RtcDS1302.h>
#include <DHT.h>
// Environmental logger. Only the red channel of the kit RGB LED is used.
ThreeWire bus(8,7,9); // DAT, CLK, CE
RtcDS1302<ThreeWire> rtc(bus);
DHT dht(2,DHT11);
// Short test interval. Use 3600UL for hourly logging after testing.
const uint32_t LOG_INTERVAL_SECONDS=15UL;
const uint16_t CAPACITY=113; // retain existing 9-byte EEPROM format
uint16_t count=0;
uint32_t lastSlot=0xffffffffUL, lastClock=0;
bool clockOK=false;
uint8_t lm=255,dt=255,hum=255,lightLevel=0,soundLevel=0;
char command[40]; uint8_t commandLen=0;
// Temperature byte = (degrees C + 40) * 2. 255 means unavailable.
uint8_t packTemp(float t){
if(isnan(t)||t < -40 || t > 87) return 255;
return (uint8_t)lroundf((t+40)*2);
}
void sample(){
analogRead(A0); // discard first ADC reading after channel change
unsigned long sum=0; for(uint8_t i=0;i<16;i++) sum+=analogRead(A0);
lm=packTemp((sum/16.0f)*500.0f/1023.0f); // nominal 5.000 V ADC reference
dt=packTemp(dht.readTemperature());
float h=dht.readHumidity(); hum=isnan(h)?255:(uint8_t)round(h);
analogRead(A1); lightLevel=analogRead(A1)/4;
analogRead(A2);
int lo=1023,hi=0; uint32_t start=millis();
while(millis()-start<40){int x=analogRead(A2);lo=min(lo,x);hi=max(hi,x);}
soundLevel=min(31,(hi-lo+16)/33); // 5-bit peak-to-peak index, NOT dBA
}
bool valid(uint16_t n){return EEPROM.read(n*9+3)!=255;}
void recover(){
count=0; lastSlot=0xffffffffUL;
while(count<CAPACITY && valid(count)){
uint32_t t=0; for(uint8_t j=0;j<4;j++) t|=(uint32_t)EEPROM.read(count*9+j)<<(8*j);
if((EEPROM.read(count*9+8)&7)==0) lastSlot=t/LOG_INTERVAL_SECONDS;
count++;
}
}
bool save(uint8_t score,const RtcDateTime& now){
if(count>=CAPACITY) return false;
uint16_t a=count*9; uint32_t t=now.TotalSeconds();
// Invalidate first; commit timestamp MSB last. Completed records survive reset.
// Removing power during a write can lose the current record; no atomicity guarantee.
EEPROM.update(a+3,255);
EEPROM.update(a+4,lm); EEPROM.update(a+5,dt); EEPROM.update(a+6,hum);
EEPROM.update(a+7,lightLevel); EEPROM.update(a+8,(soundLevel<<3)|score);
for(uint8_t j=0;j<3;j++) EEPROM.update(a+j,(t>>(j*8))&255);
EEPROM.update(a+3,(t>>24)&255); count++; return true;
}
void printTemp(uint8_t v){if(v!=255) Serial.print(v/2.0f-40,1);}
void dump(){
Serial.println(F("timestamp,temp_lm35,temp_dht11,humidity,light,sound"));
for(uint16_t n=0;n<count;n++){
uint8_t b[9];for(uint8_t j=0;j<9;j++)b[j]=EEPROM.read(n*9+j);
uint32_t t=0;for(uint8_t j=0;j<4;j++)t|=(uint32_t)b[j]<<(8*j);
RtcDateTime d(t);char date[21];
snprintf(date,sizeof(date),"%04u-%02u-%02uT%02u:%02u:%02u",d.Year(),d.Month(),d.Day(),d.Hour(),d.Minute(),d.Second());
Serial.print(date);Serial.print(',');printTemp(b[4]);Serial.print(',');printTemp(b[5]);
Serial.print(',');if(b[6]!=255)Serial.print(b[6]);Serial.print(',');Serial.print(b[7]);
Serial.print(',');Serial.println(b[8]>>3);
}
}
// Read-only diagnostic command: no EEPROM writes and no microphone test.
void checkAnalog(uint8_t pin, const __FlashStringHelper* name){
analogRead(pin);
uint16_t lo=1023, hi=0; uint32_t sum=0;
for(uint8_t i=0;i<64;i++){
uint16_t v=analogRead(pin); lo=min(lo,v); hi=max(hi,v); sum+=v;
delay(2);
}
float mean=sum/64.0f;
Serial.print(name); Serial.print(F(" raw min/avg/max="));
Serial.print(lo); Serial.print('/'); Serial.print(mean,1);
Serial.print('/'); Serial.print(hi);
Serial.print(F(" volts~=")); Serial.print(mean*5.0f/1023.0f,3);
if(pin==A0){
Serial.print(F(" LM35_C~=")); Serial.print(mean*500.0f/1023.0f,1);
}
Serial.println();
if(lo>=1018) Serial.println(F("WARNING: signal near supply rail; cannot distinguish wiring from sensor failure."));
if(hi<=5) Serial.println(F("WARNING: signal near ground; may be real or a circuit fault."));
if(hi-lo>10) Serial.println(F("WARNING: varying signal; compare repeated CHECK results."));
}
void checkSensors(){
Serial.println(F("CHECK: read-only; saved data unchanged. Voltages assume 5.000V supply."));
Serial.print(F("Stored records: ")); Serial.print(count);
Serial.print('/'); Serial.println(CAPACITY);
Serial.println(F("At 15 seconds, storage holds about 28 minutes. Export before CLEAR."));
checkAnalog(A0,F("LM35 A0"));
checkAnalog(A1,F("LIGHT A1"));
float t=dht.readTemperature(), h=dht.readHumidity();
Serial.print(F("DHT11 temperature=")); Serial.print(t,1);
Serial.print(F(" humidity=")); Serial.println(h,1);
if(isnan(t)||isnan(h)) Serial.println(F("WARNING: DHT11 read failed."));
Serial.println(F("MIC: not tested. Keep overheated module fully disconnected."));
Serial.println(F("Repeat CHECK with light covered, then uncovered; compare LIGHT raw readings."));
}
void processCommand(){
command[commandLen]=0;
if(!strcmp(command,"CHECK"))checkSensors();
else if(!strcmp(command,"DUMP"))dump();
else if(!strcmp(command,"CLEAR")){
for(uint16_t i=0;i<CAPACITY;i++) EEPROM.update(i*9+3,255);
count=0;lastSlot=clockOK?rtc.GetDateTime().TotalSeconds()/LOG_INTERVAL_SECONDS:0xffffffffUL;
Serial.println(F("OK CLEARED"));
}else if(!strncmp(command,"TIME ",5)){
int y,m,d,h,mi,s;
if(sscanf(command+5,"%d-%d-%d %d:%d:%d",&y,&m,&d,&h,&mi,&s)==6 && y>=2020 && y<=2099 && m>=1 && m<=12 && d>=1 && d<=31 && h>=0 && h<24 && mi>=0 && mi<60 && s>=0 && s<60){
RtcDateTime t(y,m,d,h,mi,s);
if(t.IsValid()){rtc.SetDateTime(t);rtc.SetIsRunning(true);clockOK=true;Serial.println(F("OK TIME"));}
else Serial.println(F("ERROR DATE"));
}else Serial.println(F("ERROR TIME yyyy-mm-dd hh:mm:ss"));
}else if(commandLen)Serial.println(F("Commands: CHECK DUMP CLEAR TIME yyyy-mm-dd hh:mm:ss"));
commandLen=0;
}
void setup(){
Serial.begin(9600);
pinMode(11,OUTPUT);
rtc.Begin();rtc.SetIsWriteProtected(false);rtc.SetTrickleChargeSettings(0);
clockOK=rtc.IsDateTimeValid()&&rtc.GetIsRunning()&&rtc.GetDateTime().Year()>=2020;
recover();dht.begin();
Serial.println(F("READY: CHECK / DUMP / CLEAR / TIME yyyy-mm-dd hh:mm:ss"));
}
void loop(){
uint32_t ms=millis();
while(Serial.available()){
char c=Serial.read();if(c=='\n'||c=='\r')processCommand();
else if(commandLen<sizeof(command)-1)command[commandLen++]=c;
else {commandLen=0;Serial.println(F("ERROR command too long"));}
}
if(ms-lastClock>=1000){
lastClock=ms;
clockOK=rtc.IsDateTimeValid()&&rtc.GetIsRunning()&&rtc.GetDateTime().Year()>=2020;
if(clockOK){
RtcDateTime now=rtc.GetDateTime();uint32_t t=now.TotalSeconds();
if(count<CAPACITY && t/LOG_INTERVAL_SECONDS!=lastSlot){
sample();if(save(0,now))lastSlot=t/LOG_INTERVAL_SECONDS;
}
}
}
// Steady red: export due (96 readings) or storage full.
// Blinking red: RTC needs setting. Off: normal collection.
digitalWrite(11,clockOK ? count>=96 : ((ms/500)%2));
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




