Author Archives: Alex Wende

MicroMod Calendar

via SparkFun: Commerce Blog

In the past I've worked on a few desk gadgets to help me work either more efficiently, or keep track of the time. One of these first projects was a macro keyboard, which I later updated to wireless using Bluetooth. Another was a clock using an ESP32 and our OLED breakouts. Like most work places across the world, once the pandemic started, we relied even more on email and virtual meetings to continue planning and releasing products which increased the importance of staying on top of my calendar and email.

To try and stay organized, I keep my mail and calendar apps open and check them throughout the day. The problem though is as I'm working, I have windows open on top of those apps as I read through a datasheet, update schematics, work on a board design, write code, etc., and I have to rely on the notifications that pop up, which don't always get my attention. I thought that when I upgraded to two monitors it would be enough, but unfortunately it wasn't, and a third monitor isn't really an option. So instead, I drew inspiration from my desk gadgets and thought that they might like a new friend that I call the MicroMod Calendar.

MicroMod Calendar

It uses two boards, the MicroMod Input and Display Carrier Board, and the MicroMod ESP32 Processor board. It connects to my Google account through a script, creates a text output with all of my meetings for the day from the calendar, and checks my email to see how many unread messages I have to display on the 2.4" TFT screen.

Script Output

Since the ESP32 is connected to the internet, I also get the current time using the Network Time Protocol, which allows the board to show when my next meeting is. Most of the time my computer will give me a 10-minute warning, but because Cortana likes to hide those alerts on me from time to time, I used the APA102 LEDs to always give me alerts when a meeting is 10 minutes out, five minutes out, and starting now, by flashing the LEDs green, yellow and red.

LED Alerts

As I was working on the software, I realized that it could also be really useful not just on my desk, but my lab bench as well where my back is always facing my desk. And while my desk already has a clock that I made sitting on it, my bench does not, so I want something a little different for each location.

On this first display, I show the time, what my next meeting is, and how long until it starts. Below in slightly smaller text are future meetings, along with their start times to help plan out my day. Finally at the bottom, I show how many unread emails are sitting in my inbox.

Calendar View 1

On the second display, I removed the time, which allowed me to increase the text size a bit, and give a little more space for better readability.

Calendar View 2

To switch between the two displays, I made use of the 5-way switch on the Input and Display - left/right switches between the displays, up/down changes the backlight brightness, and the center button flips the display 180 degrees, which allows for the USB cable to come out on either the left or right side of the case. All of these settings get saved to memory, so if the board resets or loses power it maintains the same settings.

For the past week or so I've had the MicroMod Calendar set up trying to spot any bugs in the code, and make a couple tweaks here and there. Mainly it was adjusting the brightness of the LEDs that they could get my attention without leaving me seeing spots. But similar to my macro keyboard, this has been a really handy tool to have on my desk, and wish I made it sooner. If you're interested in building your own, you can check out the GitHub page, which has everything you'll need to make your own from the ESP32 code, Google Apps Script, and 3D models that I made for the case.

comments | comment feed

Enginursday: Building a Wireless Custom Keyboard

via SparkFun: Commerce Blog

A little over three years ago I made a custom keyboard to help speed up the process of laying out a PCB in Eagle. Truth be told, I only ended up using the keyboard for a short amount of time. It wasn't that the keyboard wasn't useful; the main issue was the case wasn't complete. It sat flat on the desk, and I was using pieces of thermal gap filler as feet to keep it from sliding.

Front and back of the original keyboard

Combined with the fact that it used a frequently needed micro USB cable, and the next closest cable was miles ten feet away from my desk, it became a tool that spent most of its time in my desk drawer. What I was missing was a little bit of inspiration to invest the time to do it right.

A few months ago I saw a library for the ESP32 that used the Bluetooth radio and turned the ESP32 into a Human Interface Device, or HID. The original keyboard didn't have enough space to easily fit the ESP32 Thing Plus I wanted to use, so it forced me to fully enclose it like I originally intended:

Profile view of the keyboard

The new box I made had more of an ergonomic pitch that matched my keyboard, starting at around an inch high in the back and thinning down to around half an inch in the front (making sure to leave room for the Cherry MX key body). I used CA glue to hold five of the six sides in place, and black electrical tape to keep the top in place. I was pretty happy with the shape and feel, and I reclaimed some of the functions the previous keyboard had, plus a few new ones:

alt text

  • Left Knob: Volume Up/Down and Mute
  • Right Knob: Eagle Grid Spacing +/- and switch between Imperial/Metic
  • LED Indicator: BLE connection status and battery indicator
  • 16 Cherry MX keys for:
    • Play/Pause
    • Skip Forward
    • Skip Backward
    • Launch Calculator (really useful for footprint creation from a datasheet)
    • 12 frequently used Eagle shortcut keys

Making the keyboard wireless gave me the flexibility to move it wherever I needed. It also, however, gave me more challenges to think about - mainly power management.

To start, I checked to see how large a battery I could physically fit, and settled on a 2000mAh battery. While the library uses Bluetooth Low Energy, it was not exactly what you would call low energy. After pairing to my computer, the ESP32 was drawing around 83mA, which means it would barely run for a full 24 hours.

Quite a few years ago when I had a wireless mouse, the number one thing that drove me crazy was that I had to charge it every few days. Often I just left the USB cable connected to keep the battery charged and went wireless only when I had to. Having that still in my mind, I wanted to make sure I didn’t run into the same issue again. By putting the ESP32 to deep sleep you can power down parts of the chip you don’t need to use, like the radio, analog to digital converter, etc., to significantly cut down on power and extend the battery life.

Pairing status image on the computer

Every time the board wakes up, the time it takes to reconnect to the computer can vary, so I needed a way to tell when it was trying to connect, and whether it was awake or asleep. I also needed to know when it was time to charge the battery. The library has a function to send the battery percentage to the computer (shown in the image above), but it wasn’t updating on the computer reliably enough to count on. I solved all of these issues with a single red/green led between the two encoders:

Alternating red and green when pairing (which looks better in person than on camera):

Gif of keyboard pairing

Double green blink when it’s connected and active:

Gif of keyboard connected over bluetooth

Double red blink when it’s awake and needs charging:

gif of led indicator to charge the battery

The LEDs draw less than a couple milliamps of current, but if you only flash the LEDs periodically, especially for when the battery needs to be charged, you can get the most out of the battery. To decide when to go to sleep, I monitor any key presses and reset a timer, so that if after 20 minutes the keyboard hasn’t been used, it will put itself to sleep. The biggest downside admittedly is that because I used a voltage divider on the keys, I can’t use them to wake up from sleep. I did try to leave the ADC powered on, but I measured 20mA of current was still being used because it was constantly polling the ADC to see if a key was pressed to wake up.

The other power management solution I came up with was adding a switch to pull the enable pin of the 3.3V regulator down to ground, which cuts power to the ESP32, but will still allow the battery to charge if power is connected.

Speaking of charging the battery, I used a USB-C Breakout along with some wire wrap to provide not only power for charging, but the USB data pins as well so that I can reprogram the board without having to open up the case and stress the wires connecting the keys to the ESP32.

back view of the keyboard

Aside from that, it behaves exactly like the wired version. I’m not exactly sure what the normal use battery life is quite yet. I’ve had the board running for about a week now without charging, aside from making a few quick tweaks to the code.

If you’re interested in making your own, you can check out the wishlist for the parts used, and the GitHub repo, which has the files for the box, code used, and schematic for the hardware and images for the keycaps I used.

Two parts not on the wishlist are the common anode red/green LED and the switch, which were parts I had laying around in my parts bin, but you should be able to easily edit the size of the holes to match your parts.

comments | comment feed

Enginursday: Understanding Thermal Resistance

via SparkFun: Commerce Blog

One of the byproducts of electronics is heat. Understanding how hot you can expect your components to get can not only save you from burning yourself, but it can also keep them working longer.

When parts get hot, you can use a heatsink, but will a small heatsink work, or will you need a large heatsink? How do you know if passively cooling will be enough, or whether you’ll need to add a fan to your cart before you place that order? Our latest tutorial on thermal resistance can help answer some of these questions.


Understanding Thermal Resistance

May 14, 2020

Discussing what thermal resistance is, how it’s used for thermal management, and how to maximize the life of your project.

The tutorial not only explains what thermal resistance is, but also how effective different materials are at transferring heat, from PCBs to metal fins.

The tutorial provides a few real world examples using voltage regulators to compare the numbers that were calculated. For example, with a maximum input voltage of 35V and 1.5A of output current, this 5V regulator wouldn't need a heatsink if it was connected to a 12V source and only drawing 200mA of current, right? For a linear regulator, wasted power is the difference between the input and output voltage, multiplied by the current draw, or 1.4W.

Using the datasheet, we can see that the thermal resistance in this case would be 50°C/W. That would mean the junction temperature of the regulator would be around 70°C above room temperature (23-25°C), which would put the absolute temperature up to 95°C! How does that compare on the bench?

thermal image of a 5V regulator without a heatsink under load

Only off by a couple of degrees! So if you too are tired of using your fingers to see if you should be using a heatsink, this thermal resistance tutorial might have exactly what you need!

comments | comment feed

Enginursday: Fixing the ESP32 Thing Plus

via SparkFun: Commerce Blog

Recently, we released v20 of the ESP32 Thing Plus board. After releasing v10, we received some feedback that some boards weren’t able to upload code and the CP2102 was getting hot. It wasn’t a widespread problem, but it was a consistent problem for people that had the issue. When I was testing the board for example, I was able to upload code using both the USB ports on the computer, as well as my powered USB hub without issue. The USB power adapters didn’t cause any problems for me, except one, which helped figure out what was causing the problem.

FLIR image of a toasty CP2012

The problem was a result of inrush current, specifically with switch mode power supplies. Switch mode power supplies have soared in popularity because they allow for smaller and more efficient power supplies, and can be found in nearly all electronics from phone chargers to desktop computers. They achieve this by increasing the AC frequency, which allows the transformers to be smaller by switching at a higher frequency, and by using a buck converter, they switch current through an inductor to charge a capacitor to a specific voltage.

Buck Converter Switching Circuit

Without diving too much into the theory, inductors store energy in a magnetic field and resist the change in current. When an inductor sees a change in current, it tries to maintain that current by increasing the voltage until they run out of energy. This is why in our relay boards we use a diode across the coil to limit flyback voltage spikes, which could cause damage the switching transistor, as shown below.

alt text

Click the image for a closer look!

Finding the problem

Back to the ESP32 Thing Plus though. Now that I had a power supply that was able to replicate the problem some of the users were experiencing, I was able to connect my oscilloscope to the VBUS pin to see what was happening:

Oscilloscope trace of VUSB

After seeing the peak voltage of 8.24V, I went back to the datasheet for the CP2102 and saw that the absolute maximum input voltage on VBUS was 5.8V. I performed the same test with a linear power supply, which still had a small overshoot, but at only 5.68V it was at least below the limit:

Linear Power Supply Response

I suspected the problem was a result of inrush current and I turned my attention to the ceramic capacitors, which have a low equivalent series resistance (which you can learn more about here). Having a small ESR value is good because it allows the capacitor to respond quickly to voltage ripple, but when it first charges up it can cause a large initial spike in current. At first it might be tempting to just remove capacitors, but as the waveform below shows, without capacitors the ripple from the switching power supply would generate too much high frequency noise on the VBUS rail.

Oscilloscope trace of VUSB without bypass capacitors

Without the capacitors though, we can see that the initial voltage spike is gone. Knowing that the low ESR capacitors are causing a problem but that removing capacitors creates a new problem, I needed to find the middle ground, which can done by adding intentionally adding ESR to capacitors with a small value resistor in series with the capacitor. Another problem, however, is that because of where the capacitors are placed, adding a series resistor to the capacitors would add a lot of time reworking the board to move traces and vias.

Highlight of Capacitors connected to VBUS

Before investing the time moving traces around, there was more room available around the CP2102, which gave me another idea. After checking with the datasheet again to see that the input current for the CP2102 was around 20mA during normal operation, I wanted to see if adding a resistor in series between VBUS and the supply pins of the IC could fix the problem. After using my decade resistance box, I settled on value of 10 ohms, which produced the following result:

Oscilloscope traces on the high side and low side of the 10 ohm resistor

The yellow trace is on the high side of the resistor connected to VBUS, and the blue trace is connected to the low side of the resistor connected to the supply pins of the CP2102. As you can see, the spike still makes it through the resistor, but instead of reaching a peak voltage of 8.3V it only peaks at 4.48V. The time scale of 5us/div makes it look like the CP2102 drops back down to around 3V and stays there, but the actual voltage drop with this supply is around 200mV and gets to a steady state voltage within 200us.

As engineers, the goal is to have a test procedure that can thoroughly test your design to identify limits and fix them before it lands in the hands of customers. But just like when the Raspberry Pi added USB-C, mistakes can still happen when you use components for the first time.

comments | comment feed