My first project will be a Temperature and Humidity sensor wired to an ESP8266 12-F with a OLED screen to show the data.

Objective is to create a simple clock with 3D printed enclosure with:

  • ESP8266 12-F
  • DHT22 sensor
  • 0.96″ I2C OLED screen
  • Micro USB-Female for power (not LiPo at the moment)

ESP8266 microcontroller apart from show the sensor values on the screen, it will send these values through MQTT to my OpenHAB server (Raspberry Pi powered) in order to integrate in my current home scene.

I had problems ans spent a lot of time with the bitmap conversion. My first attempt was failes because of I wasn’t generating the hex code correctly.
I converted my BMP through this site: or with the powerful LCDAssistant, but I made the mistake of paste the result directly in my Arduino sketch… It seems that isn’t enough… The bit order was not correct.

My 0.96″ I2C OLED screen  paints the bitmap from left to right starting with the least significant bit of each byte.  I assumed the most significant bit is painted first, thus the bit order in each byte needs to be reversed. For example:

0xFE, 0x80, 0x02,… in binary is:
11111110, 10000000, 00000010

0x7F, 0x01, 0x40,… which is:
01111111, 00000001, 01000000

I finally made a PHP script that did this conversion: hex2bin, flipbin, bin2hex:

$val =  explode(",",trim($argv[1]));

foreach($val as $v){
$binval = decbin(hexdec($v));
$binval = str_pad((int) $binval,8,"0",STR_PAD_LEFT);
$binrev[] =  strrev($binval);

foreach($binrev as $b){
$hexval = dechex(bindec($b));
$hex[] = "0x".strtoupper($hexval);

echo implode(", ",$hex);


Following this change of approach, the bitmaps that I wanted to show, finally were painted correctly!

Now I will continue with the sensor reception, and soon, the 3D desint of the enclosure…

Have fun!