2. April 2017

Custom font for OLED display connected to ESP8266 via SPI

Small OLED displays can easily extend the functionality of ESP8266.

I made an experiment with 128×64 OLED display from Com-Four.

The first challenge was how to connect the display to ESP8266. The recommended way for high performance is to use Serial Peripheral Interface Bus (SPI). The advantage of this approach is the speed, the disadvantage is that it will take more pins.

The display could be connected in following way (also described in the example of ESP8266_SD1306 library):

ESP8266 - SD1306
GND     - GND
3V      - VDD
D5      - SCK (also known as CLK)
D7      - SDA (also known as MOSI/DOUT)
D0      - RES
D2      - DC
D8      - CS

If you’re using PlatformIO, just add ESP8266_SD1306 library to dependencies in platfromio.ini:

lib_deps =

Now you can run any example from Squix78 library. The library contains 3 sizes of Arial font: 10, 16 and 24px.

My goal was to display temperature from Observatory in Brno. Retrieving temperature and sending it to MQTT for ESP8266 was quite easy.

#!/usr/bin/env python3

import paho.mqtt.publish as publish

import urllib.request
f = urllib.request.urlopen('http://www.hvezdarna.cz/meteo/lastmeteodata')
content = f.read().decode('utf-8')

items = content.split(' ')

publish.single('/home/monitor/display/0', items[4], hostname='localhost')

I used default Arial 24 font. The problem was that the number was too small and barely readable from a distance. Luckily Daniel Eichhorn published great online tool which is able to generate font of any size for OLED display: http://oleddisplay.squix.ch.

My first attempt was to generate Roboto Light 54px font. It was working, just number 4 was not visible. I discovered a bug in the generator, that too big font will overflow default size of char in the jump table.

After several attempts I’ve found the right font for me DejaVu Sans 52px. This font was far more readable.

The last touch to make the font more readable was to tune down contrast little bit by the command:


I can definitely recommend this type of OLED display. It has good readability even during a sunny day. The code is available at GitHub in LampESP project.

24. March 2017

How to start Wireshark on openSUSE

The simple way how to start Wireshark on Linux is to type:


If you run this command as a normal user you won’t be able to capture packets. In order to dump packets, you need to execute it as root. This must be done in a specific way. If try just sudo you’ll end up with interesting errors like:

Attempt #1

$ sudo su
# wireshark
QXcbConnection: Could not connect to display 
Aborted (core dumped)

Attempt #2

$ sudo wireshark
QXcbConnection: Could not connect to display 
[1]    8836 abort      sudo wireshark

The proper way how to start Wireshark is by gtk-su:

xdg-su -c wireshark

13. March 2017

How to switch tabs in Konsole

Konsole has support for tabs like other terminal emulators. The question is how to switch between tabs using a keyboard.

Default keyboard shortcut is Shift + Left/Right Arrow.

If you’re used to other keyboard shortcuts like Ctrl + PgUp/PgDn which are common in Google Chrome then you can add new shortcuts easily.

Open menu Settings, select Configure Shortcuts…

Type word tab into Search field.

Find item Next tab. Click column Alternate. Click button with title None. Now you can define a keyboard shortcut. Press Ctrl + PgUp.

Find item Previous tab. Click column Alternate and button with title None. Press Ctrl + PgDown. Click OK to confirm your configuration.

Now you can enjoy new configuration. If you like this tip or you’d like some other hint about Linux let me know in the comments section bellow.

8. March 2017

How to enable line numbers in KWrite

The text editor KWrite has support for line numbers. This feature is disabled by default. You can enable it by few clicks.

From menu Settings select Configure Editor…

Navigate to Appearance. Select Borders tab, click Show line numbers and click OK.

Here you can see KWrite with enabled line numbers:

2. March 2017

How to increase font size in pgAdmin 4 on Windows

New version of pgAdmin 4 is based on QT5. When you install pgAdmin 4 on Windows computer with a high-density display you may see that letters are too small.

Solution is to send one parameter to QT engine. It will handle DPI in different way.

Open PowerShell and go to directory with pgAdmin. Then launch application with parameter:

cd "c:\Program Files\PostgreSQL\9.6\pgAdmin 4\bin"
.\pgAdmin4.exe -platform windows:dpiawareness=0

You can persist the configuration by creating qt.conf. Start PowerShell as Administrator. Go to directory with pgAdmin and create the file:

cd "c:\Program Files\PostgreSQL\9.6\pgAdmin 4\bin"
notepad qt.conf

Write there following content:

WindowsArguments = dpiawareness=0

Save the file and start pgAdmin 4 and enjoy new font size.