Connect an SSD1306 OLED screen to ESPEasy

Last modified January 9, 2021

Let's see, step by step, how we can add a screen to our project with NodeMCU and ESPEasy.

In this case, we are going to do it on the CO2 meter which I posted a few days ago, but it can be done with any other type of project.

One of the advantages of ESPEasy (and my favorite, without a doubt), is that it allows us to connect to our project many different accessories without having to program or complicate our lives with firmware modifications or adaptations. One of the most interesting elements is the screens, or «displays«.

And it is not that it allows us to connect very easily "a screen«Is that they are many the different screens that we can connect almost effortlessly.

In this case I have decided to add a screen of type SSD1306 to the CO2 meter Monochrome OLED (blue characters on a black background) of 0.96 inches (0.96 ″).

I have decided on this screen for these two advantages, although they are not the only ones:

  • Use only two cables data (plus the two power). Which means that it is extremely easy to connect and, in addition, by using only two pins, it leaves a lot of free pins to connect other accessories.
  • OLED technology has very low consumption. Important for anyone who wants to use the screen in a portable project with batteries.
  • Looks pretty good outdoors. Very important thing on certain occasions.
  • Low price. These screens can be obtained for about € 3 with shipping from China or about € 7 from Spain.

0.96 Inch 128X64 I2C SSD1306 OLED IIC White Screen Module

In AliExpress you can buy the screen SSD1306 for about 3 Euros, shipping included, from this link. It is a store with many positive reviews and shipping is by AliExpress Standard Shipping, so you should have it at home in about two weeks.

AZDelivery OLED Display Module I2C 128 x 64 pixels 0.96 Inch with white characters compatible with Arduino and Raspberry Pi with E-Book included!
  • ✔️️ AZDelivery's 128 x 64 pixel OLED display has strong contrast on the large 0.96-inch screen thanks to innovative OLED technology.
  • ✔️️ Due to the high resolution of 128 x 64 pixels, the screen provides ample space for displaying many items.
  • ✔️️ Easy screen connection with Arduino, Raspberry Pi and other microcontrollers by I2C interface via only four pins! Thanks to the integrated display adapter, the module can be connected to the I2C bus immediately.
  • ✔️️ By changing the I2C direction and soldering a third contact, two displays can be operated simultaneously. The OLED module can be connected to 3.3 V.
  • ✔️ Welcome to the AZDelivery family! Here you will find high-quality products for your Arduino and Raspberry Pi projects. We are pleased to offer you a series of application examples, comprehensive installation guides, E-Books, libraries, and personalized assistance. ⭐️⭐️⭐️⭐️⭐️ AZDelivery: Your Microelectronics Expert!

* IMPORTANT: If you are going to make your first purchase on AliExpress, enter through this link you will receive € 21 in discount coupons for your purchases.

Connecting the SSD1306 display to the NodeMCU

The connection couldn't be easier. We have to do four connections. Two for food and two for data.

We only have to connect:

  • VDD from SSD1306 to Vin by NodeMCU
  • GND from SSD1306 to GND by NodeMCU
  • SCL from SSD1306 to D1 by NodeMCU
  • SDA from SSD1306 to D2 by NodeMCU

I leave you the diagram also in this format, in case it is easier for you.

Note that in both diagrams I have used the gray and white wires backwards. Don't mix one diagram with another.

Be careful because the silkscreen of most NodeMCU V3 boards are wrong and it says D2 instead of D1 (there are two D1s).

Obviously D1 is the one is wrongly marked as D2 between D0 and «the other»D2.

IMPORTANT: Do not trust the order of the connections and double check them on your board. As the user Zulú indicates, in the comments, sometimes different manufacturers make changes of that type that can make our day bitter, if we are not careful.

The connection to another board, different to the NodeMCU (Wemos D1 Mini, for example), based on ESP8266, or another pass on ESP32, will be very similar. We will only have to be attentive to the change in the connections.

Setting

The configuration is also very simple.

We have to follow the following steps (click on each image to see it larger):

We are going to Tools -> I2C Scan.

This will make a scan of the devices connected to the NodeMCU via I2C, and it will show them to us.


Something similar to this should appear to us.

It means that ESPEasy has detected a PCF8574A OLED device on the screen at address 0x3C


We are going to Devices

Here we will see the list of devices that we have created (if there is any, if we are doing it with the CO2 meter, the MH-Z19 sensor should appear)


Click on Add, on a free device, to add our new device.


We select from the drop-down the device we want to add, in this case «Display - OLED SSD1306»


We enter the configuration data:

  1. The name we want to give the device
  2. We enable the device
  3. We select "Normal" or "Rotated" depending on whether we have the screen with the pins up or down
  4. The screen resolution in pixels. With the screen that I am using 128 × 64
  5. The size of the characters. Try to see which one you like.
  6. From "Line 1" to "Line 8" we will put the eight possible lines that we want to appear on the screen, as I explain later.
  7. We have the option of connecting a pushbutton to one of the NodeMCU pins to turn on the screen, mono that is normally off.
  8. The time it will take for the screen to turn off if we turn it on using the button in point 7.
  9. The screen update time. How often the data will be updated.

When we are satisfied with the configuration, we press «Submit» and we should start to see information on the screen.

Displaying text on screen SSD1306

The SSD1306 screen allows us to display, in the configuration that we have seen previously, eight lines of text.

These eight lines of text can contain the following types of data:

  • A fixed text
  • The value of a sensor
  • A ESPEasy variable, such as the current time.

Showing fixed text

As we have seen in the previous point, we have eight lines of text in which we can display both a fixed text (in the previous example, on line 1 the fixed text »CO2 METER ″ is shown with two spaces in front so that it appears centered on the screen).

To display fixed text, we simply have to type the text we want to display on the corresponding line.

We can add uppercase, lowercase and some special characters by including certain codes (note that it is not possible to write accented vowels):

NameCharacterCode
Degrees˚{D}
Degrees Celsius˚CdegreeC
degree_C
French quotes«
»
{<<}
{>>}
Greek letter Microµ{or}
Coin
¥
£
¢
{AND}
{AND}
{P}
{c}
Mathematical Symbols


¼
½
¾
±
×
÷
{^1}
{^2}
{^3}
{1_4}
{1_2}
{3_4}
{+-}
{x}
{..}

Showing the value of devices

To show the value of a device (a temperature, humidity, CO2 sensor or anything else) we only have to include the device name and the value we want to show in the format [DEVICE#VALOR]

In the example I have shown the PPM value of the CO2 device.

If we see the configuration of that device (from the Devices tab and selecting the device we want to see):

We can see that the name of the device is «CO2» and the value we want to show on the screen is «PPM», therefore, we will have to put [CO2#PPM] on the line where we want to show it.

Displaying system variables

There are a number of variables that ESPEasy itself updates and that we can display.

These variables are the following:

  • %sysname% - Replaced by the ESPEasy unit name (defined in the Config tab).
  • %ip% - It is replaced by the IP of the ESPEasy
  • %systime% - Replaced by the current time

Combining all three

We can combine fixed text, sensor values and ESPEasy variables in the same line, which allows us, for example, to put in a line "CO2: [CO2#PPM] ppm" to be able to include a title, before the sensor value, and the units then.

We could also write "TIME: %sistime%" or "IP: %ip%"

NTP configuration in ESPEasy, or "setting NodeMCU on time"

If you want to show the current time on the screen, using %sistime% », or you need it for some other reason, you have to bear in mind that the NodeMCU has no internal clock so you need to check the internet time.

It does this through the NTP protocol (Network Time Protocol, or Red Time Protocol, in Spanish), which is a very common system used in computer equipment (your equipment probably uses it, even if you don't know it, as is the case of Windows and Mac OS) and ESPEasy is prepared to use it very easily.

To configure it we will have to follow a series of steps:

  1. We go to the tab «Tools» (Tools)
  2. We select the option «Advanced Settings» (Advanced Settings)
  3. We activate the use of the NTP protocol and assign europe.pool.ntp.org (or whatever you prefer) as a time server
  4. We activate the DST option so that ESPEasy automatically changes the summer and winter time
  5. We introduce the corresponding time difference. In Spain 60 minutes, except the Canary Islands which are 0.

Step-by-step video instructions

Although the process is straightforward, and shouldn't give anyone too many headaches, I have recorded a video with step-by-step instructions for adding the screen.

If you liked this page, share it.

10 thoughts on “Conectar una pantalla OLED SSD1306 a ESPEasy”

  1. Thank you very much for taking the trouble to share these projects.
    Last night I finished configuring the CO2 sensor and taking advantage of the fact that I had an OLED screen for a drawer that I never put on a flying wing with INAV, I am going to complete the CO2 project with the screen, which seems more comfortable to handle and very easy to use. install with your great explanations.
    And one question, how to connect the
    NodeMcu to another wifi network if we take it to another site?
    Thank you so much.
    Regards.

    Reply
    • Hello Zulu.

      Great, you will tell us how the screen went and if, following the tutorial, you find a fault or something that needs to be improved.

      On the subject of Wi-Fi, if you take it to another site:

      I'm talking from memory, but I think I remember that if the ESPEasy is not able to connect to the access point it has configured (as would be the case that you say, when you take it to another site), it will recreate the access point with SSID «ESPEasy» (as we saw in the installation tutorial) so that you can connect to it from your mobile and you can configure the access point you want at that moment.

      Anyway, what I would do, if I were to use it in "portable" often, would be to configure the "Wi-Fi Zone" on my mobile to share its connection via Wi-Fi, setting it as the SSID and password the same as you have at home.
      In this way, when you turn it on outside the home, with the mobile sharing the connection, it will connect to it automatically.
      This on Android can be done without problem, on iOS (iPhone) I don't remember, because I haven't used it for a long time.

      Reply
  2. What a good idea about the WiFi Zone with the same SSID and password as the one at home!
    I already have everything working including the OLED screen.
    I have changed some lines to adapt them to my needs and the truth is that it is super easy: you change whatever it is, you click Submit and you immediately see the changes on the screen and so on until you leave it to everyone's taste.
    The only incidence that I have had when following the tutorial is that in the drawing of the wiring from the SSD1306 to the NodeMCU the Red (VCC) and Black (GND) cables on my screen, which is also an SSD1306, have been changed, I suppose it will be another manufacturer. It would not hurt to warn that this can happen and that you do not have to rely only on the colors but check the positive and negative twice, the result can be disastrous, I say this from previous experiences. :-).
    Otherwise all phenomenal. A ten.
    I will be attentive to new improvements to this project, and I will take a look at the CNC to see if I am capable of doing something, it is a gadget that should not be missing in any model airplane workshop.
    Thank you.
    A greeting.

    Reply
    • Thank you so much for everything.

      Regarding the notice about the connections, thank you very much, also, I have already included it in the article and, taking advantage of the fact that I was just mounting the video with the tutorial, it has been very good for me to include it as well.

      If you do the CNC project, keep us updated on your progress. Indeed, for model airplane issues, it has many possibilities.

      Reply
  3. Hello Mariete, first of all, I would like to thank you for so much effort for explaining to the "ignorant" in this matter all the steps to create the Co2 meter, I have already bought everything and looking forward to getting there to assemble it and experiment. I wanted to ask you a question that arises, does the power outlet (power) of the meter come from, if it is portable? And on the other hand, do we recommend a box that has aeration so that it does not get hot and we can mount it being cute? ... hehehe
    Thank you very much for giving us your time
    Cheers

    Reply
    • Hello Luis.

      Thank you very much ?

      I hope you get it right the first time, most have had no difficulty. If you have any questions, you can see that here there begins to be, among all of them, an important knowledge base, so it is easy for you to find the help you need.

      Power is via USB. Any mobile charger from 500mA will do. As long as it has more than 500mA, real, you will not have any problems. It is advisable to use a charger of at least 1A (1000mA) to avoid possible problems. You can also use it with the battery "power banks" without problem (I use them to leave them sometime, one night, outside to calibrate themselves).

      Keep in mind that consumption is relatively high, so it is not possible to use it with batteries permanently.

      About the box ... I have not seen anything too interesting. The best option is 3D printed boxes.

      Reply
      • Thank you very much for everything Mariete, I take note of everything and as soon as it arrives I get on with it, I really want ...
        Cheers

        Reply

Leave a Comment