Drawing On an OLED with an ATtiny85, No RAM Buffers Allowed

Small I2C OLED displays are common nowadays, and thanks to the work of helpful developers, there are also a variety of graphics libraries for using them. Most of them work by using a RAM buffer, which means that anything one wants to draw gets written to a buffer representing the screen, and the contents of that buffer are copied out to the display whenever it is updated. The drawback is that for some microcontrollers, there simply isn’t enough RAM for this approach to work. For example, a 128×64 monochrome OLED requires a 1024 byte buffer, but that’s bad news if a microcontroller has only 512 bytes of RAM in total like the ATtiny85. [David Johnson-Davies] has two solutions: a Tiny Graphics Library that needs no RAM buffer and an even slimmer Tiny Function Plotter, which we’ll discuss in order.

Tiny Function Plotter works on both SSD1306 and SH1106-based displays.

[David]’s Tiny Graphics Library works by taking advantage of a feature of SH1106 driver-based displays: the ability to read the display over I2C as well as write to it. With the ability to perform read-modify-write on a section at a time, using a large RAM buffer can be avoided. The only catch is that the library only works with OLEDs using the SH1106, but the good news is that these are very common at the usual Chinese resellers. ([David] notes that SH1106 is sometimes misspelled as “SSH1106”, so keep that in mind when searching.)

What about all those other SSD1306-based OLED displays out there? Are they out of luck? Not quite. [David] has one more trick up his sleeve: his Tiny Function Plotter works on the SSD1306 and also requires no RAM buffer. It’s unable to write text, but it can easily handle drawing graphs plotting things like values over time while needing very little overhead.

Another approach we’ve seen for using OLEDs driven by microcontrollers with limited memory is the solution [Michael] used in Tiny Sideways Tetris, which was done in part by realizing the smallest screen element he needed was a 4×4 block, and using that premise as the basis of a simple compression scheme.

I2C Bootloader for ATtiny85 Lets Other Micros Push Firmware Updates

There are a few different ways of getting firmware onto one of AVR’s ATtiny85 microcontrollers, including bootloaders that allow for firmware to be updated without the need to plug the chip into a programmer. However, [casanovg] wasn’t satisfied with those so he sent us a tip letting us know he wrote an I2C bootloader for the ATtiny85 called Timonel. It takes into account a few particulars of the part, such as the fact that it lacks a protected memory area where a bootloader would normally reside, and it doesn’t have a native I2C interface, only the USI (Universal Serial Interface). He’s just released the first functional version for the ATtiny85, but there’s no reason it couldn’t be made to work with the ATtiny45 and ATtiny25 as well.

Timonel is designed for systems where there is a more powerful microcontroller or microprocessor running the show (such as an ESP8266, Arduino, or even a board like a Raspberry Pi.) In designs where the ATtinys are on an I2C bus performing peripheral functions such as running sensors, Timonel allows the firmware for these peripheral MCUs to be updated directly from the I2C bus master. Embedded below is a video demo of [casanovg] sending simple serial commands, showing a successful firmware update of an AVR ATtiny85 over I2C.

Continue reading “I2C Bootloader for ATtiny85 Lets Other Micros Push Firmware Updates”

Custom ATTiny85 Board Powers Kids’ Light Show

We’ve often said that kids with hackers and makers for parents must be some of the luckiest kids in the world. While all the other children have to settle for some mass produced drivel from Toys“R”Us Amazon, they’ve got some of the most thoughtfully engineered and built toys and gadgets on the planet. After all, there’s no way any hacker worth their salt is going to give anything less than 110% for their own child.

A case in point is this RGB star nightlight that [Unexpected Maker] built for his children. The star itself is simple enough, just a basic shape printed in transparent PLA on his Prusa i3. The impressive part is how he lights it up. Rather than stick an Arduino or ESP8266 in there as we have seen plenty of times before, he’s put together his own custom ATTiny85 board specifically for controlling the RGB LED strips.

The board, which he calls TinyDev, is designed to be the same thickness as NeoPixel style LED strips so it can fit inside tight spaces. He solders it onto the tail end of his LED strip, adds a photoresistor so the star can tell when it’s time to light up, and then snakes the whole arrangement through a channel printed in the star itself. There’s a battery pack in the middle, but that’s about it. It really does allow for a remarkably clean LED strip implementation, and the mind can’t help but start thinking of interesting possibilities when you can tuck the controller into the same space as the lights themselves.

[Unexpected Maker] has made the TinyDev completely open source for anyone who wants to build their own, but it’s also available on Tindie if you want to get one to play with quickly. If you’re looking to light up the little one’s room with somewhat more mainstream methods, we’ve got that covered too.

Continue reading “Custom ATTiny85 Board Powers Kids’ Light Show”

Tiny Function Generator on the ATtiny85, Complete with OLED

It’s easy to have a soft spot for “mini” yet perfectly functional versions of electronic workbench tools, like [David Johnson-Davies]’s Tiny Function Generator which uses an ATtiny85 to generate different waveforms at up to 5 kHz. It’s complete with a small OLED display to show the waveform and frequency selected. One of the reasons projects like this are great is not only because they tend to show off some software, but because they are great examples of the kind of fantastic possibilities that are open to anyone who wants to develop an idea. For example, it wasn’t all that long ago that OLEDs were exotic beasts. Today, they’re available off the shelf with simple interfaces and sample code.

The Tiny Function Generator uses a method called DDS (Direct Digital Synthesis) on an ATtiny85 microcontroller, which [David] wrote up in an earlier post of his about waveform generation on an ATtiny85. With a few extra components like a rotary encoder and OLED display, the Tiny Function Generator fits on a small breadboard. He goes into detail regarding the waveform generation as well as making big text on the small OLED and reading the rotary encoder reliably. His schematic and source code are both available from his site.

Small but functional microcontroller-based electronic equipment are nifty projects, and other examples include the xprotolab and the AVR-based Transistor Tester (which as a project has evolved into a general purpose part identifier.)

Continuity Tester uses the ATtiny85’s Comparator

There’s an inside joke among cyclists – the number of bikes you need is “n+1”, where “n” is your current number of bikes. The same probably also applies to the number of tools and equipment a hacker needs on their workbench. Enough is never enough. Although [David Johnson-Davies] has a couple of multimeters lying around, he still felt the urge to build a stand-alone continuity tester and has posted details for a super-simple ATtiny85 based Continuity Tester on his blog. For a device this simple, he set himself some tall design goals. Using the ATtiny85 and a few SMD discretes, he built a handy tester that met all of his requirements and then some.

The ATtiny85’s Analog Comparator function is perfectly suited for such a tester. One input of the comparator is biased such that there is a 51 ohm resistor between the input and ground. The output of the comparator toggles when the resistance between the other input and ground is either higher or lower than 51 ohms. Enabling internal pullup resistors in the ATtiny85 not only takes care of proper biasing of the comparator pins, but also helps reduce current consumption when the ATtiny85 is put to sleep. The test current is limited to 100 μA, making the tester suitable for use in sensitive electronics. And enabling the sleep function after 60 seconds of inactivity reduces standby current to just about 1 μA, so there is no need for a power switch. [David] reckons the CR927 button cell ought to last pretty long.

For those interested in building this handy tester, [David] has shared the Eagle CAD files as well as the ATtiny85 code on his Github repository or you could just order out some boards from OSHpark.

Ambitious ATtiny85 Board Tests a Beginner’s Skills

[Chris O’Riley] has been playing around with Arduinos for around a year, and decided he wanted a breadboardable ATtiny85 in order to prototype using the actual controller that would be used in the final project. He wants to use it to interface with a Bosch BMP280 pressure sensor, but for now it stands alone.

It’s a simple board with the Tiny85, 3.3 V and 5 V regulators, a power LED, as well as the usual resistors and caps [Ed: not resistor sand caps]. The double-sided PCB [Chris] milled himself — he’s an illustrator and photographer by day, so it’s no surprise the board turned out gorgeous. He designed the board in Illustrator after taking a stab at Eagle, then ran it through his CNC to mill the circuits using a .017 inch end mill as well as drilling the vias. He add solder paste using the tip of a knife, but after messing around with an iron, he ended up investing in a hot air rework station.

We love our Tiny85s here on Hackaday. Check out the ATtiny85 gaming console, the NTSC-generating ATTiny85, and making DIY I2C devices with the chip.

Saturday Clock: An 0.000011574Hz ATtiny85 clock

In these times when we try to squeeze out extra clock cycles by adding more cores to our CPUs and by enlisting the aid of GPUs, [Ido Gendel] thought it would be fun to go in the exact opposite direction, supply a clock to the ATtiny85 that cycles only once per day, or at 0.000011574Hz. What application could this have? Well, if he could do it in seven instructions or less, how about turning on an LED at sunset Friday evening, to indicate the start of the Jewish Shabbat (Saturday), and turn it off again at sunset Saturday evening.

Notice the subtlety. A clock that cycles once per day means you can execute at most one instruction per day. Luckily on AVR microcontrollers, the instructions he needed can execute in just one cycle. That of course meant diving down into assembly code. [Ido] wasn’t an assembly wizard, so to find the instructions, he compiled C code and examined the resulting assembly until he found what he needed. One instruction turns on the LED and the instruction immediately following turns it off again, which normally would make it happen too fast for the human eye to register. But the instruction to turn it on runs on Friday evening and the very next instruction, the one that turns it off, doesn’t run until Saturday evening. Do you feel like you’re in a science fiction story watching time slowed down? Freaky. A few NOPs and the jump for the loop take up the remaining five cycles for the week.

For the source of the clock he chose to use an LDR to detect when the light level dropped at the end of the day. The problem he immediately ran into was that clouds, bird shadows, and so on, also cause drops in the light level. The solution he found was to widen the light and dark range by adding a TLV3702 push-pull output comparator and some resistors. [Ido] gives a detailed explanation of the circuit in the video after the break.

Continue reading “Saturday Clock: An 0.000011574Hz ATtiny85 clock”