The project was successful, it ran for 3 days on 3 AA's with use of 8 second WDT. But, I wanted to make it even more battery friendly.
I transitioned the project to my ATTiny85's I've had stored away for such a project. (I've had these before Adafruit came out with the very cool Trinket!).
The trouble is the ATTiny85 and the DHT22 are not playing well with each other.
It simply reads 0.00C and 0.00 or Nan for humidity.
I think it has something to do with the clock rates of the Tiny. At 1mhz it updates a lot faster than at 8mhz. I checked this by also uploading a sketch to an Arduino telling the compiler it was a 3.3v micro @ 8mhz, had to slow its serial.begin to 4800 and run the viewer at 9600 to receive serial communication. Could the same thing be happening within the library for the micro? There are a few places with delay and delayMicroseconds. I have doubled, and played around with those values, but to no avail.
Does Adafruit have any trouble with the ATTiny running at 1 or 8mhz using the DHT22 sensor and provided library?
Code: Select all
/*
Tevis Cox =^;~;^=
Temp and humidity
*/
#include <TinyWireM.h> // I2C Master lib for ATTinys which use USI
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#include <stdio.h>
#define DHTPIN 3 // what pin we're connected to
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float fltTemperature, fltHumidity;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
delay(1000); //give some time for other components to wake up
//lcd setup
lcd.begin();
lcd.print("Temp RH");
dht.begin();
lcd.noBacklight();
}
void loop(){
ReadDHT();
updateDisplay();
delay(1000);
}
void updateDisplay(){
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(fltTemperature);
lcd.setCursor(5,1);
lcd.print("F");
lcd.setCursor(10,1);
lcd.print(fltHumidity);
lcd.setCursor(15,1);
lcd.print("%");
}
void ReadDHT(){
fltHumidity = dht.readHumidity();
fltTemperature = ((dht.readTemperature())* 9.0/5.0 + 32);
}