USB Sensors with ATtiny Microcontrollers

Working with embedded electronics, you will eventually ends up with some sensor between your hands, here I’ll show how to make a graph out of it!
This project involves a light sensor, a tiny 8-pin AVR USB key with the V-USB stack, a GNU/Linux system and rrdtool.
USB Sensors with ATtiny Microcontrollers
If your are working with some digital sensor (like I2C or SPI ones) you just have to connect it to your system and write the protocol, but if you are using an analog sensor, you probably need to do some work on the signals before feeding it to the microcontroller’s ADC.
In case of the ATtiny45 and alike, you have a 10bit ADC with three possible voltage references: the external VCC, a 2.56V and a 1.1V internal bandgap.
If you are designing a signal adaption circuit and you want to make reliable measurements, don’t forget to include a low-pass filter and a high impedance buffer for the sensor signal, just in case the ADC input doesn’t satisfy your needs.
In this case, the light sensor I had works like a variable resistor, so it was just wired in series with a 10kOhm SMD resistor.
Also, the microcontroller includes an internal thermal diode which, when calibrated, can be used to make temperature measurements.
Of course, if you want to make real measurements out of the sensor, you also have to calibrate and linearize it, but that’s out of the scope of this post.
USB Sensors with ATtiny Microcontrollers circuit
USB Interface
When interfacing a sensor with a generic non-embedded GNU/Linux system, the easiest way is to use an USB interface. The free V-USB stack from is well suited or this kind of application, as it allows to implement a low-speed USB device with any AVR microcontroller.
The stack has a really low memory footprint, and there are many examples of how to use it for many different purposes.
To implement the sensor, I reused one of my avr-micro-usb boards, which had two SMD pads for GND and an analog inputs, and an easy solder point for the VCC supply.
For more detail: USB Sensors with ATtiny Microcontrollers

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top