tinyAVR microcontroller Archives - Blobhope Familyhttps://blobhope.biz/tag/tinyavr-microcontroller/Life lessonsSun, 12 Apr 2026 06:03:07 +0000en-UShourly1https://wordpress.org/?v=6.8.3New Part Day: ATtiny102 And 104https://blobhope.biz/new-part-day-attiny102-and-104/https://blobhope.biz/new-part-day-attiny102-and-104/#respondSun, 12 Apr 2026 06:03:07 +0000https://blobhope.biz/?p=12941ATtiny102 and ATtiny104 are tinyAVR 8-bit microcontrollers that pack a surprising amount of usefulness into 1 KB of Flash and a famously tiny 32 bytes of SRAM. This guide breaks down what makes them specialhardware USART, 10-bit ADC, a 16-bit timer with PWM, low-power modes, and compact SOIC/UDFN packageswhile explaining the real constraints you’ll face when building projects on such a small platform. You’ll learn how TPI programming differs from classic AVR ISP, what starter paths make setup painless, and which practical projects fit these chips best (PWM control, sensor-to-serial bridges, glue-logic controllers, and ultra-low-power nodes). Finish with a realistic, hands-on look at what it feels like to design within extreme memory limitswithout losing your sense of humor.

The post New Part Day: ATtiny102 And 104 appeared first on Blobhope Family.

]]>
.ap-toc{border:1px solid #e5e5e5;border-radius:8px;margin:14px 0;}.ap-toc summary{cursor:pointer;padding:12px;font-weight:700;list-style:none;}.ap-toc summary::-webkit-details-marker{display:none;}.ap-toc .ap-toc-body{padding:0 12px 12px 12px;}.ap-toc .ap-toc-toggle{font-weight:400;font-size:90%;opacity:.8;margin-left:6px;}.ap-toc .ap-toc-hide{display:none;}.ap-toc[open] .ap-toc-show{display:none;}.ap-toc[open] .ap-toc-hide{display:inline;}
Table of Contents >> Show >> Hide

New Part Day is the maker equivalent of adopting a tiny, needy pet: it looks adorable in the bag, it costs about a buck,
and within five minutes you’re reorganizing your entire weekend around it. That’s the vibe of the ATtiny102 and ATtiny104
two ultra-small AVR microcontrollers that sit in the delicious middle ground between “grain-of-rice minimalism” and “I can
actually build something with this without sacrificing my last two pins to programming.”

These chips are weird in the best way. They’re tiny, cheap, and surprisingly capable in a couple of very specific directions
(hello, hardware USART and a real 10-bit ADC), while being almost comically constrained in others (we’ll talk about the
32 bytes of SRAM… yes, bytes… with a straight face, I promise). If you enjoy solving puzzles with a soldering iron, you’re in
the right place.

Meet the Chips: What the ATtiny102 and ATtiny104 Actually Are

The ATtiny102 and ATtiny104 are 8-bit AVR microcontrollers designed for simple embedded jobs where cost, board space,
and power matter more than running a full-featured framework. Both parts share the same headline memory limits:
1 KB of Flash program memory and 32 bytes of SRAM, with no EEPROM. In other words, they’re not here to host your next
verbose logging system. They’re here to blink, sense, time, talk a little serial, and go back to sleep.

The big practical difference is pins. The ATtiny102 comes in an 8-pin package with 6 general-purpose I/O lines and a
10-bit ADC with 5 channels. The ATtiny104 comes in a 14-pin package with 12 general-purpose I/O lines and a 10-bit ADC
with 8 channels. Same core concept, different “how many things do you want to plug in before you start negotiating with reality?”

Quick spec snapshot (the stuff you’ll care about on day one)

  • Architecture: AVR enhanced RISC, designed for efficiency and low power.
  • Memory: 1 KB Flash, 32 B SRAM, no EEPROM.
  • Clocking: Internal calibrated oscillator (commonly 8 MHz), plus a 128 kHz internal oscillator option and an external clock option.
  • Peripherals: One 16-bit timer/counter with PWM, watchdog timer, analog comparator, 10-bit ADC, and a single USART.
  • Voltage range: Operates across roughly 1.8 V to 5.5 V depending on configuration.
  • Packages: ATtiny102 in 8-pin SOIC and 8-pin UDFN; ATtiny104 in 14-pin SOIC.

Why These Parts Exist (and Why You Might Actually Want Them)

Microcontrollers often feel like they come in two flavors: “so small it’s basically a silicon haiku” and “so capable it can run
a web server and judge you for your cable management.” The ATtiny102/104 are the rare middle snack: small enough to fit
in cramped designs, but with just enough real-world hardware to make you productive.

Two things make these parts especially interesting:

  • They give you a real hardware USART at the low end. That means dependable serial communication without
    bit-banging at awkward baud rates while your timing drifts like a shopping cart with one bad wheel.
  • They keep a proper 10-bit ADC and a 16-bit timer. That combination is gold for sensor reading, timing, PWM,
    and simple control loopsprovided you can do it without a luxurious pile of RAM.

The ATtiny104, in particular, feels like the “I want pins, but I don’t want the bill” chip. You get more I/O, more ADC channels,
and the same set of core peripheralsideal for small controllers, sensor hubs, or “glue logic with personality.”

The Catch (a.k.a. The 32-Byte Reality Check)

Let’s get the dramatic part out of the way: 32 bytes of SRAM is not “tight.” It’s “I can count it on my fingers and toes
if I had more toes” tight. With so little RAM, your design style changes:

  • Strings are basically a luxury item. Forget big text buffers. “OK” is fine. “Temperature is 23.7°C” is a negotiation.
  • Big libraries are not your friends. Many convenience layers assume you can allocate buffers. You cannot.
  • Interrupts and stacks matter more. Deep call stacks and large local variables are how you accidentally invent new failure modes.
  • You’ll learn to love bit-packing. Flags become bits. Counters become smaller. Ego becomes humble.

The good news? These constraints can make your code cleaner and your thinking sharper. The bad news? You may catch yourself
celebrating saving 6 bytes like you just negotiated world peace. Both can be true.

Programming the ATtiny102/104: TPI, Not the Usual ISP Story

If you’ve programmed classic AVR parts (like the ATtiny25/45/85 family), you might expect the familiar ISP (SPI) programming
dance. The ATtiny102/104 go a different direction: they use the Tiny Programming Interface (TPI) for external programming.
In practical terms, TPI uses a small set of pinsRESET as an enable, plus dedicated clock and data lines (TPICLK and TPIDATA).

Translation: you’ll want the right tool, and you’ll want to wire it correctly. The upside is that TPI is designed for compact devices.
The downside is that your random “old programmer drawer” might not support it unless it explicitly includes TPI capability.

The easy path: use an Xplained Nano board

If you want the smoothest first day, the ATtiny104 Xplained Nano evaluation kit (which can host ATtiny102/104 parts) is the
“no drama” option. It includes an on-board mini embedded debugger that handles programming and can provide a virtual COM port
for serial communication. Plug in USB, open the IDE, and you’re making progress before you can misplace your jumper wires.

The flexible path: an external programmer that supports TPI

If you’re working with bare chips on your own PCB (or on a breadboard adapter), you’ll need a programmer/debugger that supports
TPI and you’ll connect power/ground plus the TPI signals. The wiring is simple in concept, but it’s the kind of “simple” where swapping
two wires turns your afternoon into a quiet staring contest with Device Not Found.

What You Can Build (Without Pretending You Have More RAM Than You Do)

These chips shine in jobs where the firmware is small, the behavior is tight, and the hardware does most of the heavy lifting.
Here are practical, realistic projects that play to their strengths.

1) A “smart” PWM dimmer or fan controller

Use the 16-bit timer for PWM and the ADC to read a potentiometer (or a sensor). Add a simple smoothing strategylike a tiny
moving average with a 4-sample ring buffer (yes, you can afford 4 bytes). The ATtiny104’s extra pins make it easier to add a
status LED and a button without sacrificing the sensor input.

2) Sensor-to-serial bridge

Read an analog sensor (light, temperature, soil moisture, battery voltage) and send compact serial output over the hardware USART.
Keep the protocol minimal: fixed-width binary packets or short ASCII tokens. You’re not writing a novel; you’re sending a postcard.

3) “Glue logic” controller for a larger system

Need a tiny co-processor that watches a pin, times an event, and asserts an output? That’s ATtiny102/104 territory.
Example: debounce a switch properly, generate a clean pulse, measure frequency using input capture, or act as a watchdog supervisor
for another board.

4) SPI master (using the USART’s MSPIM mode)

The USART can be configured into Master SPI Mode (often called MSPIM). This lets you talk to SPI peripherals as a master,
which can be a clever workaround when you want SPI but don’t have a dedicated SPI module in the traditional sense.
It’s a little more “read the datasheet” than “copy a library,” but that’s the entire personality of these chips anyway.

5) Ultra-simple low-power periodic sensor node

Sleep most of the time, wake on a timer, sample a sensor, transmit briefly, and sleep again. The trick is being ruthless:
avoid big buffers, avoid floating point, and keep the power budget honest. If you need real-time logging, choose a bigger MCU.
If you need “wake, measure, chirp, nap,” you’re home.

Design Tips That Save You From Yourself

Be intentional about your “RAM budget”

  • Prefer global static variables over large local arrays.
  • Keep stack depth shallowavoid recursion and huge function call chains.
  • Use uint8_t and bitfields where it makes sense, but don’t turn your code into an unreadable crossword puzzle.

Serial output: keep it short

  • Avoid printf-style formatting unless you really know the cost.
  • Use short fixed messages or binary packets.
  • Consider a simple host-side decoder script if you need human-friendly logs.

ADC readings: treat them like a system, not a number

  • Use a stable reference when possible and understand your voltage range.
  • Take multiple samples and average lightly (2–4 samples can be plenty).
  • Use integer math; save floating point for chips that can afford it.

ATtiny102 vs. ATtiny104: Which One Should You Buy?

If you’re choosing between them, the question is mostly about pins.

  • Choose ATtiny102 when you need the smallest footprint, fewer I/O lines are fine, and your circuit is simple:
    one sensor, one output, maybe serial.
  • Choose ATtiny104 when you want more I/O flexibility, more ADC channels, and you’d like to avoid creative pin-sharing
    strategies that involve phrases like “well technically this LED can also be a button if we squint.”

Either way, buy a few extras. Not because they fail often, but because tiny chips have a mysterious talent for disappearing into carpet.
It’s not your fault. It’s quantum mechanics. Probably.

Common “New Part Day” Pitfalls (and How to Dodge Them)

Pitfall: “Why won’t it program?”

With TPI-based parts, wiring and tool support matter. Double-check that your programmer supports TPI, confirm RESET/TPICLK/TPIDATA,
verify your ground reference, and make sure you’re powering the target correctly. If you’re using an evaluation board, confirm the IDE
recognizes it and the drivers installed properly.

Pitfall: “My code compiled, but nothing works.”

On tiny parts, configuration bites harder. Make sure your clock configuration matches your assumptions, confirm pin directions,
and be careful with peripherals that steal pins (USART, PWM outputs, etc.). When you have 6–12 I/O pins total, every alternate pin
function is a plot twist.

Pitfall: “I ran out of memory and now I’m angry at the universe.”

Welcome. This is normal. Reduce feature creep, remove unused code paths, and keep your protocol simple. If you truly need larger
buffers or more complex logic, it’s not a personal failure to choose a bigger microcontroller. It’s just engineering.

Conclusion: Tiny Chips, Big Fun

The ATtiny102 and ATtiny104 are not “do everything” microcontrollers. They’re “do a few things extremely efficiently” microcontrollers.
If you lean into their strengthshardware USART, solid ADC, a 16-bit timer, low power modesand respect their limitsespecially that
famously tiny SRAMyou’ll get a lot of practical usefulness for very little money and board space.

Think of them as the espresso shot of embedded design: small, intense, and absolutely not the thing you casually chug in a 32-ounce cup.
Use them for tight, purposeful jobs, and they’ll reward you with elegant little projects that feel like magic… the kind of magic where you
can still explain every trick.

Hands-On Experiences: What It’s Like Living With ATtiny102/104

If you’re coming from roomier microcontrollers, the first experience with ATtiny102/104 often feels like moving from a studio apartment
into a perfectly organized backpack. Everything you need can fit, but only if you stop buying decorative throw pillows (a.k.a. unnecessary
variables) and commit to the essentials.

The “New Part Day” high usually starts with the packaging itself: these chips tend to show up in friendly, human-scale SOIC packages
that don’t require microscope-level life choices. That alone is a small joy. You can solder them by hand, you can rework them without
tears, and you can prototype without needing a custom PCB the size of a postage stamp.

Then you write the first programtypically a blinkand it’s deceptively easy. The pin toggles, your confidence rises, and your brain
immediately suggests a “small upgrade” like, “What if we also read a sensor and print it over serial and store settings and”
That’s when the chips teach their signature lesson: scope discipline.

Working within 32 bytes of SRAM changes your habits fast. You start noticing every buffer. You stop using big strings. You build
tiny message formats and feel oddly proud of them. Instead of printing “Temperature: 23.7 C” you send two bytes and decode them
on your laptop. You realize that making the host computer do the heavy lifting is not cheating; it’s teamwork.

Peripheral setup becomes part of the fun. The hardware USART feels like a luxury item hereit’s stable, predictable, and great for
quick feedback when you can’t afford elaborate debugging. The ADC is the other “daily driver” experience: with a little care around
references, sampling, and integer math, you can make surprisingly decent measurements in a tiny footprint. The 16-bit timer is the
quiet hero for PWM and timing tricks; it’s the difference between “close enough” and “actually correct.”

The learning curve most people feel isn’t about “hard code,” it’s about “tight code.” You’ll likely try something that feels normal
on bigger MCUslike adding a feature flag, then a second state machine, then a slightly nicer serial outputand discover you’ve turned
your firmware into a crowded elevator. The fix is usually simple: reduce, compress, reuse, and let hardware do what it does best.
By the end of a weekend, many makers find they’ve built not only a project, but also better instincts: smaller interfaces, clearer priorities,
and a sharper sense of what a system truly needs to do.

And the best part? When you finally ship a tiny, clean solution on an ATtiny104, it feels like winning a puzzle.
Not because it was impossiblebecause it was elegant.

The post New Part Day: ATtiny102 And 104 appeared first on Blobhope Family.

]]>
https://blobhope.biz/new-part-day-attiny102-and-104/feed/0