ESP Easy: How to add OLED SSD1306 display to an IoT ESP8266 project

Black Friday on Amazon right now! Black friday Banggood Gearbest Black Friday
Extra 10% off For XIAOMI SUPER HOME TECH GADGET Sale

Smart Home kits, security camera, robot vacuum cleaner, air purifier ... *Excluding products already on promotion

Reveal
35 days left

ESP Easy is able to manage the on-screen display black and white OLED ( SSD1306, 124 × 68 pixels ) or on screen LCD 2004 (4 lines). Add a view on an Arduino project or ESP8266 requires still a bit of work. If you need to display text and that the sensors and/or actuators are supported by firmware ESP Easy, here’s how. If you have a project more complex that this firmware is not suitable, you should find everything you need in this previous article, how to add a screen OLED SSD1306 to an ESP-01. For a Arduino project, start read this post.

If you’re starting with ESP Easy, you can start by reading this overview article.

To achieve this article, I used the version R120 ESP Easy firmware.

List of components

In this tutorial, we will achieve a small barometer that measures the pressure using a BMP180 sensor and the temperature and humidity using a DHT22.

 

Circuit

Here is a mapping between Arduino and ESP8266 pins.

Component Pin Arduino PIN Equivalence ESP8266 (Wemos D1 mini)
DHT22 VDC 5V 5V
GND GND G
Data GPIO-14 G5
BMP180 VDC 5V 5V
GND ‘ GND G
SDA GPIO-4 D2
SCK GPIO-5 D1
OLED SSD1306 0.96 “ VDC 5V 5V
GND GND G
SDA GPIO-4 D2
SCK GPIO-5 [] D1
Led WiFi activity Pole + GPIO-12 D6
Pole- GND G

espeasy + dht22 + ssd1306 + bmp180

 

Once the wiring is done

esp easy ssd1306 oled display bmp180

 

Configuring ESP8266 with ESP Easy

Find I2C addresses of the accessories

Before going further Let’s start by retrieving each accessories I2C addresses. For it go to the Tools page and then click on I2C Scan . You should get something like this:

 

espeasy ssd1306 oled bmp180 i2c scan

The screen is well identified as a screen OLED SSD1306 0x3c address. The BMP180 has been identified as a BMP085 (normal, it’s his successor). It is located at address 0 x 77. The Firmware ESP Easy is able to find him even the address of many Devices on the I2C bus. There is for the OLED display to help him.

Add the Device BMP180 (or BME280)

The BMP180 digital Barometer measures atmospheric pressure (from 300 to 1100 hPa) and temperature (-50 ° C to + 85 ° C). If you also want to recover the moisture level, opt for a BME280. The advantage of the BME280 is an easier integration in Domoticz. In the list select Temperature & Pressure – BMP085 and

  • Name : give a name to the device. Short, years space if you have to use in a Rule
  • Delay : the measure refresh time-out. Watch for projects on battery consumption.
  • IDX / Var : ID of the Domoticz device. 0 in all cases
  • Send Data : active sending data on a server or an online service
  • Value Name 1 : the name of the variable containing the temperature measurement. You can use it in a Rule
  • Value Name 2 : Ditto for the atmospheric pressure
  • you can also do a unit in the field conversion Formula (attention only with operators + – *, %value% contains the measure)
  • Finally choose the number of digits after the decimal point (Decimals)

 

espeasy configuration bmp180 bmp085

Add the DHT22 Device

with no BME280 to my available, so I added a DHT22 to collect the moisture. In the list, choose Temperature & Humidity – DHT then

  • Name : give a name to the device
  • Delay : the frequency of measurement
  • IDX / Var : ID different from 0 or one of the virtual instrument in Domoticz
  • 1 st GPIO : pin on which we get the measures sent by DHT
  • DHT Type : DHT11 (blue) or DHT22 (white)
  • Send Data : active sending data to the server or online
  • for the rest, it is the same as before.

 

espeasy dht22 configuration

Add and configure the Device display OLED SSD1306

Add a new Device. Select from the list Display – OLED SSD1306.

  • Name : give a name to the Device, e.g. AffichageOLED
  • Delay : display refresh rate in seconds
  • IDX / Var : ID different from 0
  • IC2 Address : the screen on the I2C bus address. Here 3 c
  • Rotation: allows to reverse the screen display.
  • display button : allows you to call the screen for a term Display Timeout by pressing a button connected to a the ESP8266 GPIO. Except error on my part, this function does not work well in the R120.

There is to indicate the content for each line. In the version R120, ESP Easy manages display 8 lines.

You can write any text in the limit of 16 characters per line.

You can retrieve and display system information:

  • %systime%: hour system. If you checked Use NTP, the ESP8266 is set to from the internet automatically at startup time.
  • %ip%: ip address of the module
  • %uptime%: uptime since boot

Finally we can retrieve the value of a variable of any Device like this [NameDuDevice#NameValueX] .Iin the present case, to display the humidity measured by the DHT22, will be [DHT22#HumDHT22].

Remarks

  • the call of the variables is not case sensitive, we can write [dht22#humdtht22]
  • it is not possible to display some special characters, for example: ° ‘ €, and accented characters.

 

espeasy oled ssd1306 wemos d1 mini

Here is the result.

 

esp easy ssd1306 oled display bmp180

Show information remotely on the screen

Another very interesting function is the possibility to order or view the text using a simple HTTP request. We could for example retrieve weather on an online service and display it on the screen from a home automation, a Mode-Red script server…

The HTTP request is of the following form:

http://<ESP IP address>/control?cmd=oled,<row>,<col>,<text>

where

  • row: display line
  • col : display column
  • text : text to display

Limitations:

  • it must first clear the screen ( clear ) before sending a new text
  • text will be displayed until the next refresh ( Delay )

Other commands available:

  • turn on the screen: http:// /control? cmd = oledcmd, we
  • turn off the screen: http:// /control? cmd = oledcmd, off
  • clear the screen: http:// /control? cmd = oledcmd, clear

 

Original article source: http://www.esp8266.nu/index.php/OLEDDisplay

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

DIY Projects