Attiny85 DHT22 Temp/Humidity logger
Posted: Wed Oct 15, 2014 5:33 am
As a quick first project using the ESP8266, I've made a temperature and humidity logger controlled by an Attiny85 (using the arduino tiny core). Also works on a regular arduino (atmega328 based).
I wanted to make a sensor that would be cheap and last a long time when sporadically logging stuff.
Unfortunately I was only fully successful in the first part... but it does work!
If anybody is interested, the code and very simple schematic is on my github.
It logs the temperature, humidity and internal voltage every 5 minutes, and sends the message to an UDP port in my server. The received message (a JSON string) will be forwarded to my MQTT broker (and from there it's logged, displayed, etc).
When it's sleeping it should use very little power. The attiny85 plus the voltage regulator (MCP1700) use very little, just under 8uA. But the ESP8266 module, even with the CH_PD enable pin low will still draw about 30uA. Slightly annoying; I probably should have used a mosfet or something similar to source power to the module.
But what really uses up quite a bit of power is that it takes about 10 seconds for the module to fully wake up, connect to my wifi and send the data over UDP.
I'm using some quite long delays in my code... it's possible to do it faster, but I've ran into different issues when I rushed commands over when the module wasn't ready.
I would love if there was a better way to know when the module is ready... but then if the module used SPI, I probably woulnd't be able to use an attiny85..
The code will definitively not be useful out of the box for anybody, but it should be trivial to change the UDP server/message.
I developed the code in a regular Arduino (with the debug line uncommented in the code), then when I was sure it was working I just passed it over to attiny85. (notice the 2 sets of pinouts defined in the top of the code).
If you have any comments or question I would be glad to help!
I wanted to make a sensor that would be cheap and last a long time when sporadically logging stuff.
Unfortunately I was only fully successful in the first part... but it does work!
If anybody is interested, the code and very simple schematic is on my github.
It logs the temperature, humidity and internal voltage every 5 minutes, and sends the message to an UDP port in my server. The received message (a JSON string) will be forwarded to my MQTT broker (and from there it's logged, displayed, etc).
When it's sleeping it should use very little power. The attiny85 plus the voltage regulator (MCP1700) use very little, just under 8uA. But the ESP8266 module, even with the CH_PD enable pin low will still draw about 30uA. Slightly annoying; I probably should have used a mosfet or something similar to source power to the module.
But what really uses up quite a bit of power is that it takes about 10 seconds for the module to fully wake up, connect to my wifi and send the data over UDP.
I'm using some quite long delays in my code... it's possible to do it faster, but I've ran into different issues when I rushed commands over when the module wasn't ready.
I would love if there was a better way to know when the module is ready... but then if the module used SPI, I probably woulnd't be able to use an attiny85..
The code will definitively not be useful out of the box for anybody, but it should be trivial to change the UDP server/message.
I developed the code in a regular Arduino (with the debug line uncommented in the code), then when I was sure it was working I just passed it over to attiny85. (notice the 2 sets of pinouts defined in the top of the code).
If you have any comments or question I would be glad to help!