Using the ATtiny 45 to drive a sensor and measure something.
I decited to use a temperature/humidity sensor called DHT 11. It is a very economic sensor, but not extremely reliable. Some sources claim that it has up to 10% deviation up to 100°C max. The sensor that I got seems to be decent though.
First of I needed to be sure that the model I got was working. So I used an arduino with a test program to test the sensor. The results were found within the Serial Monitor. The library I used was the adafruit DHT unified and the tester example. It can be found within the arduino library manager in the arduino 1.6.8 version.
Headed to eagle. Using the schematic that Niel had already designed for a different sensor I built of of that my own design.
At this point a few problems came up. To begin with, the usb mini cable broke, both the Arduino IDE and AVRdude responded with "avrdude: Error: Could not find USBtiny device (0x1781/0x9f)". Efter further investigation the driver didint show up within device manager. I spent some time analyzing the freshly milled out board, but it just so happened that it was a-ok, so after switching out the cable I was back on track. I uploaded the basic blink program to the chip, which at first was no problem. Then I uploaded a testing program to try out the serial Rx with SoftwareSerial example with the SoftwareSerial.h library. At that time I did get some feedback, but bunch of gibberish. In hindsight it might have been the baudrate, but we tryed to burn bootloader (to configure the fuses) within the arduino IDE and after that we stoped getting feedback and furthermore we got "avrdude: verifying ... avrdude: verification error, first mismatch at byte 0x0240 0xea != 0x10 avrdude: verification error; content mismatch". So, in order to verify if it was a problem with the IDE, the programmer or the ATtiny 45, we did a few tests. First of, we ruled out the programmer with a different one borrowed from a friend. So that left us with the ATtiny 45 or the arduino environment. We went into the makefile and the the AVRdude commands to upload the hex file, which was already produced by the arduino IDE. By going into the arduino "preferences" we checked the "Show verbose output during ..." and checked both "compilation" and "upload". In the comilation window, scrolling a bit up, we found where the IDE stores the hex files. Then we found that folder, opened it up in CMD and ran the command "avrdude -p t45 -P usb -c usbtiny -U flash:w:"+"the name of the hexfile". That compiled the program beautifully onto the ATtiny 45. So the arduino environment proved to be the faulty party.
After that we used an oscilloscope to check if the board was responding with a routine signal, which it was.
Ok, so after the thing was made, I realized that all the mainstream libraries out there were like a few kilobites too big for the AT45. So, a few smart people would give up on the AT45 and go onto a microcontroller that had bigger memory. I decided to hang in there, for days, and find the holy grail. Like I said somewhere else, all the libraries that I had found included the option of the DHT 11, the DHT 12 and the DHT 22. I only needed the functions of the DHT 11. I found a library that was just a tiny touch too big for my AT45 so I modified it a little bit and also used ints instead of floats (as can be seen in the example).
DHT11.h library