Electronics

A quick word on ATtiny 1-series interrupts

The Atmel AVR 8-bit microcontrollers have always been a favourite for tinkering; and the massive popularity of the Arduino based on the ATmega 168 and 328 MCUs introduced a lot of hobbyists to this series. The companion ATtiny series from Atmel were the poor stepchildren of the ATmega controllers to an extent - useful for small projects but often quite limited. However, the acquisition of Atmel by Microchip Technology in 2016 ushered in a new series of MCUs bearing the same moniker of ATtiny, but much more capable and innovative. They have been around for a while now, but many hobbyists are just beginning to poke around with these new capable MCUs.

ESP32, DS18B20, TM1637 integration: Displaying temperature data

In a previous post I wrote about displaying arbitrary data on a TM1637-based 4 digit LED display, highlighting an ESP-IDF component that I extended to display positive and negative floating point numbers. Now we’re going to put that component to use and display actual data from a DS18B20 temperature sensor.

The {% asset_link DS18B20.pdf “DS18B20” %} temperature sensor operates on the Dallas Semiconductor 1-Wire bus. In this application, we aren’t powering the devices using parasitic power. Instead we’re powering the device from an external supply.

Interfacing an ESP32 to an MCP23017 GPIO expander

While the ESP32 sports a number of GPIO pins, not all are broken out on every board, meaning that sometimes a GPIO expander is necessary. This project is a simple design to test interfacing the ESP32 to an MCP23017 via the I2C interface.

MCP23017 I2C addressing

There are so many tutorials on the MCP23017 that I won’t delve in depth into how it works, but I’ll point out a few features of the custom MCP23017 component that I’m developing as part of this demonstration project. If you need to get up-to-speed developing applications using I2C within the ESP-IDF environment, this tutorial from Luca Dentella is excellent and concise.

Using TM1637-based LED displays with ESP32

There are three main types of 4 digit seven segment displays to be found on the market:

  • Bare displays without any driver. These come in a variety of colors and with either decimal points or clock-type display with a colon dividing two sets of two digits.
  • 74HC595-based displays. Usually these displays have two daisy-chained 74HC595 shift registers and rely on the host controller to fill the serial registers and handle the multiplexing. Depending on the processor speed, this ends up being a significant overhead.
  • TM1637-based displays. These displays reduce the burden on the host controller because all of the multiplexing is handled on the interface chip.

Getting ESP32 to talk to TM1637-based displays

This post is about the TM1637 LED displays. The {% asset_link Datasheet_TM1637.pdf TM1637 datasheet %} is terrible, but fortunately there are several libraries for Arduino that provide a little insight into how others have managed to make this work. First things first, the communication protocol for this device is not I2C despite what vendors on Aliexpress frequently claim.

Serving sensor data via ESP32

Previously, I wrote about using the ESP32 to read sensor data over I2C from the Si7021 temperature and humidity monitor. Today, I’m going to briefly take you through the process of serving this data via the web.

Basic project setup

Description

The project plan is to connect to WiFi in STA mode, collect temperature and humidity data every 5 seconds from a Si7021 sensor via the I2C bus. We will launch a web server and whenever we have a GET/ request we’ll serve a simple web page that reports the temperature and humidity. If the URL path is /h (e.g. 192.168.1.x/h) then we’ll turn on an LED connected to GPIO 4. If the path is /l (e.g. 192.168.1.x/l) then we’ll turn off the LED. In both latter cases, we’ll also serve the same page showing the temperature and humidity.

ESP32 reading Si7102 temperature and humidity data via I2C bus

Recently I wrote about reading Si7021 temperature and humidity data using a Raspberry Pi. Now let’s try a completely different platform, the ESP32. This is essentially a project to explore using I2C on the ESP32 platform and to understand the build process.

Project layout

Since we’re developing the Si7021 interface code as a reusable component, we need to structure our project in such a way that we can easily refer to it in our main code. Here’s how I structured this project:

Setting up Arduino IDE with Heltec ESP32 module for macOS

Heltec WiFi Kit 32 ESP32 module

The Heltec WIFI Kit 32 is an interesting little module that integrates a WiFi/MCU SoC and a small OLED display on a single board. If you want to set up the Arduino IDE to work with this device and you’re on macOS, this is for you. This particular ESP32 module has a number of impressive features: 240 MHz processor speed and 4 MB of flash memory. The onboard OLED display can be conveniently used for debugging.

A software debouncing class for rotary encoders

Rotary encoders are notoriously difficult to get right.

Although I haven’t used this new encoder class yet, it looks very interesting. From active Teensy forum user Theremingenieur, it allows initialization with upper and/or lower limits.

You can find the code in this thread.

Implementing a simple menu interface on OLED display

While working on a project to automate environmental control in our greenhouse, I needed to implement a menu interface on a small OLED display. In this sub-project, meant to test the concept, I’ve used a Teensy 3.1, a small I2C-driven 0.96" monochrome OLED display and a rotary encoder.

Bill of materials:

  • Teensy 3.1 - the Teensy 3.1 is no longer available, but you can easily find the compatible Teensy 3.2.
  • 0.96" yellow/blue I2C OLED module - I used the version with the yellow band at the top so that it this area could act as the highlighted region of the display.
  • Rotary encoder with push-button switch - I used this one from Adafruit, but there are many options.
  • {% asset_link MC74HC14.pdf 74HC14 Schmitt Trigger inverter %} - to debounce the pushbutton.

Description

This project is a proof-of-concept for using a rotary encoder to manipulate an on-screen menu of options. A number of electronics design concepts are used here.

Displaying Cyrillic fonts on a 128x64 OLED display

Recently I picked up a couple inexpensive 128x64 pixel OLED displays with an I2C interface. It turns out that displaying Russian text on these displays is not difficult. But it’s non-obvious. This is a brief description of how to make it work.

First, there’s a variety of these little displays and they’re all seemingly configured a little differently. I used this device for this test.

There are two options for libraries to simplify communicating with SSD1306 boards: