• Bug found

    Christoph Tack01/20/2022 at 20:48 0 comments

    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.

  • Oh no, they all died

    Christoph Tack09/03/2019 at 12:55 0 comments

    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?

    • Battery voltage (open clamp) is still about 3V.
    • The units can still happily be reprogrammed.
    • After programming the units with the functional test firmware, they still don't work.

    First signs of life

    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.

    Design mistakes

    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.

  • Ready for the party!

    Christoph Tack08/30/2018 at 19:12 0 comments

    10 pieces ready
    10 of the 20 pieces ready

    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.

  • Programming the application

    Christoph Tack06/19/2018 at 19:25 0 comments

    Charlieplexing LEDs

    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.

    Temperature/humidity sensor

    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.

    Supply voltage 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.  

    Sleep mode

    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.

    Operating mode

    Showing temperature & humidity isn't very complicated.  A simple state machine takes care of the program flow.

  • Debug interface

    Christoph Tack06/10/2018 at 12:59 0 comments

    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.

  • Bringing your board to life

    Christoph Tack06/08/2018 at 19:43 0 comments

    Software stack

    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.

    Blinky

    What "Hello world" is to software, is "Blinky" to firmware.  Let's get started:

    • Open Arduino IDE
    • Copy the following code to the IDE
      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
      }
    •  Select the correct board
      • Board: "ATtiny24/44/84"
      • Pin Mapping: Clockwise (like damellis core)
      • Chip: "ATtiny84"
      • Clock: "8MHz (internal)"
      • Save EEPROM: "EEPROM retained"
      • LTO : "disabled"
      • BOD : "BOD disabled"
      • Programmer : Select your programmer, "AVRISP MkII" in my case
    • "Burn Bootloader" to program the fuse settings
    • Upload your code

  • T & RH sensor

    Christoph Tack06/03/2018 at 20:02 0 comments

    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.

    Relative humidity

    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.

    Temperature

    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.

    Sensor

    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.

    Firmware

    The SI7021 has been implemented and tested on a STM32F103 Nucleo for ease of debugging.

  • Programming connector

    Christoph Tack05/31/2018 at 20:08 0 comments

    Choice

    There was a need for a programming connection to the devices.  The REDFIT IDC SKEDD has been chosen to that purpose.

    • It can be attached to the existing AVRISP MkII programmer
    • It's easy to attach & detach during debugging and "production"-programming.
    • It doesn't need a mating connector on the devices.  So it saves the cost of a connector on every device.
    • It doesn't need any extra adapter PCB, you just clip the connector onto your existing programmer
    • It's not an edge connector, so you could still connect when the PCB is mounted into an enclosure.

    Alternatives are : using push pogo-pins (which need some custom fixture), or using edge mounted DB9-connectors, which don't provide reliable connections.

    Mounting to the IDC

    To mount the SKEDD to the IDC, special tooling is "needed".  A cheaper way of mounting these connectors goes as follows:

    • Open the SKEDD and slide the IDC cable through
    • Make a stack of three devices (such as this konijntje-thermo-humi) and align them.
    • Mount the SKEDD connector on top of the stack of PCBs.  By using three PCBs, the plastic alignment pins of the SKEDD will no longer protrude on bottom side.  
    • Squeeze the SKEDD with the PCB-stack on a mini vise.
    • Use a multimeter to check the electrical connections of your mounted SKEDD connector to the IDC cable.
    Mounted SKEDD
    AVRISP MkII with mounted SKEDD connector