Tag Archives: USB

Designing a USB power meter stick with ATmega328

This USB stick measures supply voltage, calculates power consumption and displays it on an OLED display.

There was a time when USB drives were only for transferring data. Not anymore. The interface is increasingly being used as a power supply and charging port for an assortment of gizmos and gadgets. Take this DIY USB line power meter stick from Electro-Labs, for example. The meter is capable of measuring the supply voltage of the devices connected to the USB port or charger, calculating its power consumption, and then displaying the reading on an integrated 0.5″ OLED screen.


The board itself is built around an ATmega328. In order to keep the circuit as small as possible and reduce the number of components, the MCU runs off its internal 8MHz clock. Meanwhile, the voltage and current are measured by its built-in 10-bit ADC.

To enhance the accuracy of the measurements, an external 2.5V voltage reference IC is included as well. The current is converted to voltage on a 0.01R sense resistor and precisely amplified by an LT6106 high side current sense amplifier before being sent to the AVR’s 10-bit analog port. The stick is capable of measuring up to 2.5A. Since the OLED display requires 3.3V supply voltage, a linear voltage regulator handles the 5V to 3.3V conversion.


“An external 2.5V voltage reference is used to get more accurate ADC readings. Since the ADC module of ATmega328 is 10-bit, the reading resolution is 2.44mV (2.5V/1024). It is quite enough for the purpose of the circuit,” Electro-Labs writes. “The 5V line of the USB port is passed through a voltage divider network including 14K and 10K resistors to extend the readable voltage up to 6V.”

The tiny OLED communicates via an SPI interface and is driven by the U8Glib library. An Arduino sketch reads the separate ADC inputs for the voltage and current, and reveals the measurements on the display. 10 samples from each channel are averaged to filter out the noise.

“After a simple V*I power calculation, it shows up the values on the display by using the U8Glib library. The measurement is repeated every one second. The software runs in an endless loop,” the Electro-Labs crew adds.


Intrigued? You can find a breakdown of entire project, including bill of materials and its necessary code, on its original page here.

Capacitive sensing with ancient keyboards

The Model M keyboard is a designation for a group of computer keyboards manufactured by IBM, Lexmark, Unicomp and MaxiSwitch, starting in 1984.

According to Wikipedia, the many variations of the keyboard have their own distinct characteristics, with the vast majority boasting a buckling spring key design and many having fully swappable keycaps.

As the venerable M keyboards are understandably ancient, there really is no easy method of connecting the device to a modern system. This unfortunate fact prompted a modder by the name of xwhatsit to ultimately build his own controller.

According to Hackaday’s Brian Benchoff, the beam spring keyboards use capacitive switches.

“With 122 keys, the usual method of reading capacitance – putting a capacitor in an oscillator – would be far too slow to be of any use in a keyboard. There is another method of reading capacitance: measuring the current going through the capacitive switch. This can easily be accomplished with an LM339 comparator,” he explained.

“xwhatsit‘s keyboard controller uses this capacitive sensing circuit to read the four rows of keys, with a few shift registers taking care of the columns. Atmel’s ATMega32u2 MCU is the brains of the outfit, running LUFA to translate the key presses to USB.”

Interested in learning more? Well, you’re in luck, because xwhatsit is selling Atmel based controllers for the Model M as well as the Model F using the same basic circuit.

ATmega32u4 MCU powers littleBits Arduino module

LittleBits has debuted a programmable ATmega32u4-powered Arduino at Heart Module. The new component will allow Makers to easily incorporate sketches into their littleBits circuits.

According to a LittleBits rep, the Arduino Module is capable of reading two types of input signals.

“The first is digital, which is a simple ‘on’ or ‘off’ signal. This is the type of signal you will get from a button or trigger. In the Arduino coding language, on is a HIGH signal and off is a LOW signal. All three inputs on the Arduino Module can read digital signals,” the rep explained.

“The other type of signal is an analog signal. Analog signals aren’t just ‘on’ or ‘off.’ They work like a dimmer switch or a volume knob. In the Arduino coding language, analog signals are given a value between 0 and 1023. If you connected a dimmer module to your Arduino and turn the knob up (clockwise), the value would slowly rise from 0 to 1023. The inputs on the Arduino module marked a0 and a1 both accept analog signals.”

As Engadget’s Jon Fingas notes, the programmable module gives Makers much more control over LittleBits’ existing modules, such as the oscillators in the Synth Kit.

“However, it also opens the door to interaction with your computer. Since the Arduino module has USB support built-in, you can create Etch-A-Sketches, Pong games and other programs that have LittleBits and your PC working in harmony,” said Fingas.

“[Plus], many existing Arduino projects should work with only a few slight tweaks to pin assignments.”

The stand-alone Arduino module can be snapped up for $36, although LittleBits is currently offering an $89 starter bundle that includes a total of 8 prototyping modules.

Interested in learning more? You can find additional information about the new LittleBits module here.

Adafruit’s Gemma has Atmel under the hood

Adafruit has debuted Gemma, a tiny wearable platform board packed in a 1″ diameter package. The device – powered by Atmel’s versatile Attiny85 – is easily programmable with an Arduino IDE over USB.

“We wanted to design a microcontroller board that was small enough to fit into any project, and low cost enough to use without hesitation,” Adafruit’s Limor Fried (aka LadyAda) explained in a recent blog post. “Gemma is perfect for when you don’t want to give up your Flora and aren’t willing to take apart the project you worked so hard to design. It’s our lowest-cost sewable controller!”

Fried described the Attiny85 as a “fun processor” because despite being so small, the device boasts 8K of flash and 5 I/O pins, including analog inputs and PWM ‘analog’ outputs.

“We designed a USB bootloader so you can plug it into any computer and reprogram it over a USB port just like an Arduino (it uses 2 of the 5 I/O pins, leaving you with 3),” Fried continued. “In fact we even made some simple modifications to the Arduino IDE so that it works like a mini-Flora. Perfect for small and simple projects – the Gemma will be your go-to wearable electronics platform.”

In addition to Atmel’s ATtiny85, key hardware specs include:

  • 1.1″ / 28mm diameter and 0.28″ / 7mm thick.
  • Easy-to-sew or solder pads for embedding in wearable projects.
  • 8K of flash, 512 byte of SRAM, 512 bytes of EEPROM.
  • Internal oscillator runs at 8MHz.
  • Ultra low power, only 9 mA while running.
  • USB bootloader with LED indicator programmable with the Arduino IDE
  • Mini-USB jack for power and/or USB uploading
  • Rugged and foolproof bootloader process
  • ~5.25K bytes available for use (2.75K taken for the bootloader)
  • On-board 3.3V or 5.0V power regulator with 150mA output capability and ultra-low dropout.
  • Up to 16V input, reverse-polarity protection, thermal and current-limit protection.
  • Power with either USB or external output (such as a battery) – it’ll automatically switch over
  • On-board green power LED and red pin #1 LED; reset button for entering the bootloader or restarting the program.
  • 3 GPIO – The 3 independent IO pins have 1 analog input and 2 PWM output as well.
  • Hardware I2C capability for breakout and sensor interfacing.

Interested in learning more about Adafruit’s Gemma? You can check out LadyAda’s detailed Gemma tutorial here.

A closer look at Atmel’s XMEGA-B1 Xplained

Atmel’s ATxmega128B1 is a low power, high performance 8/16-bit AVR microcontroller. The MCU boasts 128KB self-programming flash program memory, 8KB boot code section, 8KB SRAM, 2048-byte EEPROM, 2-channel DMA controller, 4-channel event system, USB (full speed), 4×40 segment LCD controller and up to 32 MIPS throughput at 32MHz.


The versatile device can be used to power a wide range of applications, including utility metering, home automation, climate control, industrial control, sports equipment, toys, eToken, medical, power tools and fire alarm systems.

To accelerate development with the ATxmega128B1, Atmel offers the XMEGA-B1 Xplained, a hardware-based platform that allows engineers to more easily evaluate the device.

Aside from the ATxmega128B1 microcontroller (MCU), key XMEGA-B1 Xplained specs include:

  • 4×40 transflective LCD module with backlight
  • Transfer data over the USB full/low speed device interface
  • Read a light sensor with the ADC
  • Read a temperature sensor with the ADC
  • Measure external voltage input with ADC
  • Measure potentiometer voltage with ADC
  • Read status of the 4 Atmel QTouch buttons from AT42QT1040 QTouch device
  • 4 LEDs to show status information
  • Read/write data to the 64Mbit Atmel DataFlash
  • Program the kit via USB bootloader or an Atmel programmer
  • Expand the board with Xplained top modules

The XMEGA-B1 Xplained can be ordered from Atmel’s official store here.

Designing in-home display units with Atmel tech

In-home display (IHD) units play a critical role in helping customers reduce their energy usage by providing relevant stats in real-time. Indeed, IHD units are typically designed to acquire and display information via a sensor with built-in RF and/or PLC. A more effective method? Transmitting information from a smart meter using a home area network.

“IHD units vary in complexity, from simple wall-mounted segment LCD displays, up to battery-operated products with color TFT displays and touchscreens,” an Atmel engineering rep told Bits & Pieces. “Advanced IHDs can display not only consumption information, but energy consumption advice from energy providers. They can also support a variety of additional functions such as home automation.”

To be sure, IHD units typically support displays, connectivity via USB and RF, as well as low power and touch buttons or screens for a fully interactive user interface (UI). And that is why Atmel offers a wide range of versatile microcontrollers (MCUs) for IHDs, from entry-level 8-bit AVRs to a sophisticated ARM9 core with embedded LCD graphics display controllers.

“In short, Atmel’s MCUs help facilitate flexible touch solutions, from buttons and wheels to sophisticated touch-screens, all providing support for a wide range of user interface features and capabilities,” the Atmel engineering rep explained.

“Meanwhile, power line communications (PLC) system-on-a-chip (SoC) solutions with full digital implementation deliver best-in-class sensitivity, high performance and high temperature stability. Plus, our CryptoAuthentication lineup provide a cost-effective, easy-to-implement security solution that is critical for wireless communication between meters and  IHD units.”

In terms of power efficiency, Atmel offers a number of advanced capabilities, including 1 µA watchdog and brown-out, picoPower tech for extended battery life, an event system to allow measurement while CPU is in SLEEP mode, support for true 1.6V operation, low-power RF transceivers for connectivity and the lowest power 32 kHz crystal oscillator (650nA RTC).

“In-house display units can range from a basic segment LCD to a more sophisticated color TFT. Depending on the display choice drivers and required  processing power, the primary microcontroller can be either an entry-level 8- or 32-bit MCU, scaling up to a more powerful embedded MPU with on-chip TFT LCD controller,” the engineering rep added.

“As products become more sophisticated, so will the UI. Atmel touch technology provides robust support for state of the art features such as capacitive touch buttons or a full touchscreen. The communications within the IHD depend on the implemented architecture of the HAN (typically RF or PLC). Of course, wireless connectivity can also be supported via Secure Digital Input Output (SDIO) cards.”

Interested in learning more about designing in-home display units with Atmel tech? Be sure to check out our extensive device breakdown here.

Capacity and performance characterize Atmel’s megaAVR

Our ongoing coverage of Atmel’s comprehensive AVR portfolio has taken readers on a detailed MCU (microcontroller) tour this month. First, Bits & Pieces dove into the guts of Atmel’s AVR UC3 which is built around high-performance 32-bit AVR architecture and optimized for highly integrated applications.

We then spent some time with Atmel’s AVR XMEGA, an MCU designed for real-time performance, high integration and ultra-low power. And today we want to properly acquaint our readers with Atmel’s megaAVR microcontroller, which is well known for both capacity and performance.

“When your designs need some extra muscle, you need the megaAVR. Ideal for applications requiring large amounts of code, the megaAVR offers substantial program and data memories with performance up to 20 MIPS, with picoPower technology minimizing power consumption,” an Atmel engineering rep told Bits & Pieces. “All megaAVRs offer self-programmability for fast, secure, cost-effective in-circuit upgrades. You can even upgrade the flash while running your application.”

Indeed, the megaAVR family offers Atmel’s widest selection of devices in terms of memories, pin counts and peripherals. Meaning, engineers can choose from general-purpose devices to models with specialized peripherals like USB, or LCD controllers, or CAN, LIN and Power Stage Controllers.

More specifically, Atmel’s megaAVR family is equipped with on-chip flash, SRAM, internal EEPROM, SPI, TWI, USART, USB, CAN, LIN, watchdog timer, a choice of internal or external precision oscillator and general purpose I/O pins.

In terms of analog functions, the megaAVR boasts advanced analog capabilities, such as ADC, DAC, built-in temperature sensor and internal voltage reference, brown out detector, a fast analog comparator and a programmable analog gain amplifier. Simply put, the high level of integration allows designs with fewer external analog components.

And last, but certainly not least, megaAVR microcontrollers help accelerate the development process with advanced in-system programming and on-chip debug, while in-system programming works to simplify production line programming and field upgrades.

Interested in learning more? A full breakdown of our AVR portfolio is available here.

Atmega32u4 MCU takes center stage in wearable tech challenge

Known as “FLORA,” Adafruit’s wearable electronics platform is built around Atmel’s Atmega32u4 MCU. The microcontroller boasts built-in USB support, eliminating the need for pesky special cables and extra parts.

According to Adafruit’s Limor Fried, FLORA is extremely “beginner-friendly.” Indeed, the device is difficult to accidentally destroy by connecting a battery backwards, thanks to a polarized connector and protection diodes. Meanwhile, an onboard regulator ensures even connecting a 9V battery won’t result in damage or tears.

Numerous Makers are using FLORA to design a wide range of creations, a fact that has caught the eye of the folks at element14. To be sure, the Newark Corporation recently issued a challenge to engineers and Makers to develop their own piece of wearable technology. The platform of choice for the contest? Adafruit’s versatile FLORA kit.

“Wearable technology is incredibly popular at the moment. Yet, we’re still waiting for a product that brings wearable technology together with clothing and that’s what makes this competition and the Adafruit kit stand out,” explained Dianne Kibbey, Global Head of Community, element14.

“In this challenge we’re calling on our talented community to create something new in wearable technology that will make a difference to the everyday lives of the user. From tracking the vulnerable or elderly to finding a lost handbag in a nightclub, wearable technology is only just getting started and has the potential to do so much and this is why we’re all really looking forward to seeing the submissions in this competition.”

As previously discussed on Bits & Pieces, Atmel is right in the middle of the wearable tech revolution. First off, Atmel’s SAM4S and tinyAVR MCUs are inside the Agent smart-watch which recently hit Kickstarter. Atmel MCUs have also tipped up in a number of Maker projects for wearable tech, like the LED pocket watch we featured earlier this month.

Clearly, wearable tech is getting a long overdue makeover, as Internet-linked computers are woven into formerly brainless attire such as glasses, bracelets and shoes.

“We are heading for the wearable computing era,” Gartner analyst Van Baker told the AFP. “People are going to be walking around with personal area networks on their bodies and have multiple devices that talk to each other and the Web.”

Ben Arnold, director of industry analysis for consumer technology at NPD, expressed similar sentiments.

“Traditional technology companies will have to start paying attention to how sensors are enabling us to live,” he added. “Consumers are ultimately going to become more aware of their data in the digital ether. I suspect wearables are going to disrupt the way tech firms are doing business now.”

Atmel-powered Babuino connects smartphones to digital devices

The Atmel-powered Babuino (USB) stick allows users to easily control multiple electronic devices from their smartphones.

Babuino, designed by OpenJungle, is also capable of the reverse – controlling a smartphone from a PC or Mac.

There are currently two versions of the open source Babuino: one enclosed in a case (stick) and the other, as a board, sans case with fully accessible ports. As noted above, both iterations of the device are powered by an Atmel MCU.

Specifically, original prototypes are equipped with an ATMega32U4 microcontroller, although the final versions of Babuino are expected to boast the ATXMega128A1U MCU. Additional hardware specs include a Bluetooth module, infrared RX/TX and 128KB Flash Memory (without bootloader).

More information about Babuino can be found here on IndieGoGo.

Smallest mixed-signal oscilloscope with AWG packs Atmel’s ATXMEGA32A4U

An oscilloscope is an electronic test instrument designed to monitor varying signal voltages, typically as a two-dimensional graph of one or more electrical potential differences using the vertical or y‑axis, plotted as a function of time (horizontal or x‑axis).

A mixed-signal oscilloscope (or MSO) is often equipped with two types of inputs – a small number of analog channels (typically two or four) and a larger number of digital channels (16). The mixed-signal model is capable of accurately time-correlating analog and digital channels, thus offering a distinct advantage over a separate oscilloscope and logic analyzer. As such, digital channels may be grouped and displayed as a bus with each bus value displayed at the bottom of the display in hex or binary.

Recently, Saelig introduced the Xprotolab Portable, which the company describes as the smallest handheld mixed-signal oscilloscope with AWG (arbitrary waveform generation). The device – powered by Atmel’s ATXMEGA32A4U microcontroller – offers a combination of three electronic instruments: a mixed signal oscilloscope (simultaneously sampling of 2 analog / 8-bit/200kHz and 8 digital / 1MHz signals), an arbitrary waveform generator and protocol sniffer. The oscilloscope weighs less than 60g, is a compact 3.13″ x 1.83″ 0.7″ and boasts an integrated graphic 1.3” OLED to render waveforms on a 128×64 pixel display. In terms of connectivity, the Xprotolab Portable can link to a PC’s USB port for battery charging, external control, or screen dumps.

As a mixed-signal oscilloscope, the device offers simultaneous 2MSa/s sampling of 2 analog and 8 digital signals; as an arbitrary waveform generator it provides advanced sweep options on all waveforms; as a protocol sniffer, it can decode SPI, I2C and UART. The handheld mixed-signal oscilloscope also features an advanced triggering system, adjustable trigger level and the ability to view signals prior to the trigger.

As a portable DigitalMeter, the Xprotolab Portable displays VDC, VPP and input frequency to 12MHz, with XY Mode facilitating Lissajous Figures, the display of V/I curves and the phase difference between two waveforms. Meanwhile, an integrated FFT Spectrum Analyzer offers various windowing options, along with selectable vertical log and IQ visualization. Perhaps most importantly, the waveform generator and the oscilloscope can operate simultaneously, with the waveform generator running in the background.

And last, but certainly not least, the Xprotolab Portable AWG can output Sine, Square, Triangle and Exponential signals, as well as periodic noise that fills the AWG buffer with random data. In addition, a SWEEP feature increases one or more parameter values automatically on each screen refresh of the oscilloscope.

Accessories include one USBmini-USB-PC cable, two 3.5mm-EZhook signal probes and an 8-channel logic probe. An optional 3.5mm to BNC adapter facilitates the use of standard 10:1 scope probes for signal input, while an optional Tripod Adapter allows Xprotolab Portable to be mounted using a standard camera screwthread.

Additional information about the $98 Xprotolab Portable is available here.