Forum

OLED library for ES...
 
Notifications
Clear all

OLED library for ESP32

7 Posts
2 Users
0 Likes
87 Views
(@jordan-hahn)
Member
Joined: 8 months ago
Posts: 4
Topic starter  

Looking to utilize some small OLED screens on some ESP32 devices, and I was wondering if we could be sent the source code for the firmware or request the libraries be added to a future firmware revision. Thanks!


   
Quote
(@pbruno3)
Reputable Member Admin
Joined: 6 years ago
Posts: 341
 

Hi Jordan,

 

What devices are you looking to add? We can add them to the firmware for you.


   
ReplyQuote
(@jordan-hahn)
Member
Joined: 8 months ago
Posts: 4
Topic starter  

We've got a few Heltec ESP32, "WiFi Kit 32 (v2)". It's an ESP32 and works to run firmware v46 but it also has an OLED screen on it and that does not currently work. 

Here is the pin out http://resource.heltec.cn/download/WiFi_Kit_32/WIFI_Kit_32_pinoutDiagram_V2.pdf

Oled is on a diff set of pins than brucontrol typically uses for LCD

Thanks!


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 6 years ago
Posts: 341
 

We need to know what type of display it is. I looked at the resources and it isn't clear. Do you know?

An code which addresses it would also help.

This post was modified 2 months ago by pbruno3

   
ReplyQuote
(@jordan-hahn)
Member
Joined: 8 months ago
Posts: 4
Topic starter  

It's a monochrome 128x64 I2C display that can use the U8glib V2 library, though I'm not sure exactly which display it is. Working code example follows:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                          //
//                                     Heltech WiFi Kit 32 Wifi Scanner                                     //
//                                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Includes.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include                              "WiFi.h"
#include                              <U8g2lib.h>

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Variables.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

U8G2_SSD1306_128X64_NONAME_F_HW_I2C   u8g2(U8G2_R0, /* clock=*/ 16, /* data=*/ 15, /* cs=*/ 4);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 
// Setup.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup()
{
  // Set the wifi mode to station.
  
  WiFi.mode(WIFI_STA);

  // Initialize the graphics library.
  
  u8g2.begin();
  u8g2.setFont(u8g2_font_6x10_tf);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setDrawColor(1);
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main loop.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

void  loop()
{
    // Obtain network count.
    
    int nNetworkCount = WiFi.scanNetworks();

    // Clear the display buffer.
    
    u8g2.clearBuffer();

    // Display networks.
    
    if(nNetworkCount == 0) 
    {
        // No networks found.
        
        u8g2.drawStr(0, 0, "0 networks found.");
    } 
    else 
    {
        // Networks found.
        
        char    chBuffer[128];
        char    chEncryption[64];
        char    chRSSI[64];
        char    chSSID[64];
      
        // Display network count.
        
        sprintf(chBuffer, "%d networks found:", nNetworkCount);
        u8g2.drawStr(0, 0, chBuffer);

        // Display the networks.
        
        for(int nNetwork = 0; nNetwork < nNetworkCount; nNetwork ++) 
        {
            // Obtain ssid for this network.
      
            WiFi.SSID(nNetwork).toCharArray(chSSID, 64);

            // Obtain the rssi for this network.
            
            sprintf(chRSSI, "(%d)", WiFi.RSSI(nNetwork));

            // Obtain the encryption type for this network.
            
            sprintf(chEncryption, "%s", WiFi.encryptionType(nNetwork) == WIFI_AUTH_OPEN ? " ": "*");

            // Display the results.
            
            sprintf(chBuffer, "%d: %s %s %s", nNetwork + 1, chSSID, chRSSI, chEncryption);
            u8g2.drawStr(0, 8 + ((nNetwork + 1) * 8), chBuffer);
        }
    }

  // Send the display buffer to the oled.
  
  u8g2.sendBuffer();

  // Delay.
  
  delay(2000);
}




   
ReplyQuote
(@jordan-hahn)
Member
Joined: 8 months ago
Posts: 4
Topic starter  

Was that sufficient information or do I need to disassemble one of the units?


   
ReplyQuote
(@pbruno3)
Reputable Member Admin
Joined: 6 years ago
Posts: 341
 

Yes. Will take a look.


   
ReplyQuote
Share: