A letter to Jerry Brown

Dear Governor Brown,

By now you are aware of Nicholas Kirstof’s piece[1] in The New York Times in which he presents abundant evidence that investigators and prosecutors framed Kevin Cooper for the murder of four people in Chino.

Advanced DNA testing could produce potentially exculpatory evidence. Or not. But the truth must be pursued. You have rejected calls to exercise the authority of your office to order such testing. It beggars belief that you would not use that authority wisely in the search for truth, when the evidence was distorted for malicious purposes is so strong.

You have erroneously asserted that no one on death row is innocent, but this is clearly untrue. A study published in the Proceedings of the National Academy of Sciences[2] suggests that as many as 1 in 25 persons on death row is innocent. While it may not be politically expedient to do so, the search for truth in this case of apparent injustice must be allowed to proceed.

Alan Kendall Duncan.

  1. Was Kevin Cooper Framed for Murder: https://www.nytimes.com/interactive/2018/05/17/opinion/sunday/kevin-cooper-california-death-row.html

  2. "Rate of false conviction of criminal defendants who are sentenced to death", Samuel R. Gross, Barbara O’Brien, Chen Hu, Edward H. Kennedy
    Proceedings of the National Academy of Sciences May 2014, 111 (20) 7230-7235; DOI: 10.1073/pnas.1306417111.

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 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.

Since we’re using a 3.3v bus, the pullup resistor on DQ is 2.2KΩ, not 4.7K.

In addition to my modified TM1637 component, the project uses David Antliff’s components for the 1-Wire bus protocol and the DS18B20 digital thermometer. You’ll need to follow the instructions in the project README file to clone the project and recurse the three submodules.


After cloning the project, you’ll need to configure the GPIO pins in use using make menuconfig. One GPIO is used for the 1-Wire bus and two lines are used for each TM1637 display for a total of 5 GPIO pins. Be careful that you do not use pins that are in use for other purposes on your particular board. For example, I initially use GPIO12 for one of the TM1637 displays, but when connected, was unable to flash the ESP32. It appears that GPIO12 is used as a bootstrapping pin. On the particular board I used for this project, I believe that GPIO12 needs to be pulled low at reset but the TM1637 was not permitting it. Moving do another GPIO solved the problem.[1]

After completing the hardware connections and specifying them in make menuconfig, you can then simply make flash to upload the application to the device.

All of the source code is on github.


  1. More about GPIO12 here

  2. I prefer these displays to the 74HC595 because the TM1637 handles all of the multiplexing for you, whereas the shift-register displays require the host controller to take on constant refreshing of the display.

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.

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.

Read More

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.

This post is about the TM1637 LED displays. The 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.

Read More

What was the purpose of that tweet?

The thriving New York Times just published a list of questions being posed by Special Counsel Robert S. Mueller, III. What I found particularly interesting was his question about Trump’s intent behind his tweet on May 12, 2017 in which he said: “James Comey better hope that there are no “tapes” of our conversations before he starts leaking to the press!”

The question being posed by Mr. Mueller is insightful because it will require Trump to admit to the office of the Special Counsel that he was deliberately attempting to intimidate a party to a Federal investigation.

All in all, there are about 4 dozen questions for Trump, which means at least 48 lies.

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.


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.

Essentially, we have three tasks to consider:

  • Read sensor data from the Si7021 over the I2C bus. We covered this part previously; so I’ll only say that we’re using the same component and launching a periodic tasks to read the sensor.
  • Connect to the WiFi network
  • Configure and serve the web page incorporating the sensor data.

Read More

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:

Read More

How to disable links opening in a new tab

One of the most infuriating UX choices on the web is the developer’s choice to open every single link in a new tab. There are a few sites I interact with, including Aliexpress, where the designers have inflicted this on the users.

Fortunately, I found a solution. The Chrome extension target="_blank"-toggler works well. When you hover over a link which would open in a new tab, it superimposes a visual signal. Now you have a choice. If you click on the link, it will open in a new tab. If you Command + Shift click,[1] the link will open in the same tab. Problem solved.

  1. The ⌘ + ⇧ combination works on macOS. It is probably CONTROL + Shift on Windows, but you'll have to check the documentation.

Setting up Arduino IDE with Heltec ESP32 module for macOS

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.

Install command line development tools

If you haven’t already installed the command line dev tools, you’ll need to do so.

xcode-select --install

For some reason, I had to do this twice before it would install. It eventually succeeded.

Install the Arduino support files

mkdir -p ~/Documents/Arduino/hardware/espressif
cd ~/Documents/Arduino/hardware/espressif
git clone https://github.com/espressif/arduino-esp32.git esp32
cd esp32
git submodule update --init --recursive
cd tools
python get.py

With the last command python get.py I got an SSL error. I was able to workaround it but downloading the mkspiffs archive here. My target machine is still on 10.11, and I downloaded mkspiffs-0.2.1-osx.tar.gz. Then I just moved the archive (not unzipped) to ~/Arduino/hardware/espressif/esp32/tools/dist. Then I reran:

python get.py

It still threw an error related to openssl, so I updated the Python distribution with Homebrew[1], and updated openssl:

brew install openssl
brew install python

Then I was able to run get.py:

python3.6 get.py

Now you’re setup to use the Arduino IDE to develop for this powerful little board.


  1. Homebrew is an excellent package manager for macOS. It's incredibly easy to install. See the link provided.