Gadget that shows room temperature & humidity on a LED-bar
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
After wake-up the software no longer ran correctly. The only thing I could do was force a software reset using the watchdog timer.
The issue was due to powering down internal peripherals of the ATTiny prior to entering power down mode. At wake-up these need to be re-enabled, which I forgot.
About 14 months now after creation, of all the boards I come across, none of them is still working. A few weeks ago they started to behave strangely. They immediately turned off on showing the humidity value.
What's going on?
The units appear to work well using a 3V lab power supply instead of the CR2032 cell. This confirms that the hardware is still working correctly. Only the power seems to be insufficient in some way.
Standard CR2032 coin cells use Lithium Manganese Dioxide. That's where the C in CR2032 stands for. These batteries are designed for a maximum load current for about 1-3mA. Drawing more current (e.g. to drive the single LED) will reveal the limitations of this battery chemistry. They typically have an internal resistance of about 400ohms.
The current consumption should be reduced drastically. Another option would be to change the battery chemistry to LiIon. The LIR2450 would be a good option. 120mA current draws are allowed. The battery is also rechargeable. Be aware that the battery voltage is 4.2V down to 3.3V. An LDO might be needed. Digikey has plenty of coin cell holders available.
20 pieces have been made. 10 of these are shown in the picture above. All of them have been hand soldered.
After soldering, the units underwent a functional test. For that a custom application is uploaded to the units, which reads the sensor, lights the LEDs and verifies if the button functions correctly.
After that, the final application has been uploaded.
The Sparkfun library was taken as a start. The memory footprint has been reduced. Functionality has been added to operate the LED array in single LED mode.
The sensor powerline has been connected to a GPIO. Experience with the Aiakos project learned me that it's the easiest way to save power when the sensor is not in use.
The 100ohm series resistors in the SCL & SDA lines are needed to make in-circuit-programming possible.
R7 together with C2 forms an RC-filter to stabilize the supply voltage for the temperature sensor.
The internal bandgap reference of the ATTINY is used here to measure the supply voltage. If it's lower than 2.5V, the temperature & humidity LEDs will be on for a short time.
As it's a battery powered device that should have a long lifetime, most of the time is spent in sleep mode. The deepest sleep mode is used, which results in a sleep current of close to 100nA for this device.
Showing temperature & humidity isn't very complicated. A simple state machine takes care of the program flow.
A simple debug interface is useful in any MCU project. Unluckily, the ATtiny doesn't provide one by default.
Serial communication would be most suitable. This communication however isn't very forgiving about large baudrate offsets. As we're using the internal oscillator, which has quite some frequency tolerance by default, we should check this.
The program "checkInternalRcOsc" outputs a close to 10KHz waveform on OC0A (pin 5). Using a frequency counter, we can tune OSCCAL so that the output waveform frequency is closer to 10KHz.
The default frequency on my device was 10.16KHz. After tuning, it's 10.02KHz. More than accurate enough for UART communication.
The SoftwareSerial-library can be used to configure the unused pin 10 (PA3) as TX-output.
Why write all the code from scratch if we can make use of the well documented Arduino core? There are libraries to read from I²C devices, libraries for serial communication, timer libraries, ...
The ATTINY series has been added to the list of supported devices. You can find the github repository here. Follow the instructions to install the library.
Details about the ATTINY84 Arduino implementation (pin mappings etc.) can be found here. Remark that the "clockwise pin mapping" is used.
What "Hello world" is to software, is "Blinky" to firmware. Let's get started:
const byte LED_PIN=10; // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(LED_PIN, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(LED_PIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_PIN, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
Temperature & relative humidity are key factors for climate control. That temperature is important, is evident, but how does relative humidity influence people's comfort in a room? Let's give an example: While increasing the relative humidity and keeping the temperature constant, most people will perceive this as "it's getting hotter". This is due to the fact that the human sweat, to cool the body, evaporates less easily when the relative humidity increases. As a result, the human body doesn't cool so efficiently and people will feel hot.
Extensive research has been done in the past to determine what temperature and relative humidity values people feel as comfortable. According to Wikipedia, relative humidity values should be between 50 & 60% ideally. 30-70% is acceptable.
Wikipedia has an article related to room temperature: "The World Health Organisation's standard for comfortable warmth is 18 °C (64 °F) for normal, healthy adults who are appropriately dressed." To be honest, that's rather cold, so it will be shown in red on this gadget. The maximum temperature is determined by the number of LEDs available.
In this project the SI7021 will be used as I had plenty of these lying around. If you're interested in a comparison of RH&T-sensors. You can have a look here.
The SI7021 has been implemented and tested on a STM32F103 Nucleo for ease of debugging.
There was a need for a programming connection to the devices. The REDFIT IDC SKEDD has been chosen to that purpose.
Alternatives are : using push pogo-pins (which need some custom fixture), or using edge mounted DB9-connectors, which don't provide reliable connections.
To mount the SKEDD to the IDC, special tooling is "needed". A cheaper way of mounting these connectors goes as follows:
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates