Tuning the oscillator of your OpenHumidor sensor - sharst/OpenHumidor GitHub Wiki

The OpenHumidor sensor board runs on an Attiny84A processor. It has an internal oscillator that runs at 8MHz. The exact speed of the oscillator is however affected by the supply voltage and temperature in the room. Using the OSCCAL register, we can compensate for these deviations and "tune" the oscillator. If you have acquired a fully assembled board, it has already be tuned and the calibration value was stored to the internal EEPROM of the Attiny and can be restored each time it is powered on (even if in the meantime the battery was removed). If you have however for some reason overwritten this value or the board is out of sync for some other reason, here's how to do the tuning process.

How do I know that my OpenHumidor board needs tuning?

  • When you attach the debug output reader, it shows only or mostly unreadable signs
  • The sensor board doesn't transmit / receive any messages although the transfer LED (blue) is flashing

Step 1: Attach serial debugger

Buy a USB-to-TTL-adapter an attach it to the Sensor Board as described in the debugging section

Step 2: Install the Arduino IDE and Attiny core

If you haven't done so, install the Arduino IDE and build a programming device which will enable you to upload code to your OpenHumidor sensor board. The process is described in [Programming the sensor board]

Step 3: Download TinyTuner

TinyTuner is a helpful sketch which can be used to tune the Attiny's oscillator. Download the library from here (file name TinyTuner-0003.zip) and place the folder TinyTuner inside your sketchbook/library folder.

Step 4: Upload the TinyTuner sketch to the sensor board

In the Arduino IDE, browse to File --> Examples --> TinyTuner --> Interactive to Serial, connect your programmer to the sensor board and upload the sketch.

Step 5: Run the tuning script

If you haven't done so, clone the OpenHumidor python source files:

git clone https://github.com/sharst/OpenHumidor/

and run

python tuner.py

The script should output messages that it has found your USB to TTL adapter and that it is tuning the oscillator. Once it has finished successfully, the script will stop.

Step 6: Be happy and stay tuned..!

There's no need to do anything more. The value has been safely stored in the devices EEPROM. Upload a sketch of your choice to the sensor board and it should run perfectly in tune!