ESP-01 OLED configuration

If someone can help me with this I would very much appreciate it;

Attempting to use a ESP-01 module with the following library;

SSD1306Ascii - Arduino Libraries

Any it's driving me insane

All I want to do is display hello world, it's like pulling teeth to try and get this to work....

I would like to use GPIO0 and GPIO2 for SDA and SCL

I have written the following script for my uno, which works, but I need to make it work on my ESP-01

All I need is help with making the display work, nothing else

#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <dht.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
#define I2C_ADDRESS 0x3C
SSD1306AsciiAvrI2c oled;
#define PIN_SD_SPI 4
#define PIN_ETH_SPI 10
#define DHTTYPE DHT11
#define DHT11_PIN 7
dht DHT;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 0, 102 };
byte gateway[] = {192, 168, 0, 1 };
byte subnet[] = {255, 255, 255, 0 };
EthernetServer server(80);

File webFile;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
  pinMode(PIN_ETH_SPI, OUTPUT);
  pinMode(PIN_SD_SPI, OUTPUT);
  // disable w5100 while setting up SD
  digitalWrite(PIN_ETH_SPI, HIGH);
  delay(100);
    // initialize SD card
    Serial.println("Initializing SD card...");
    if (!SD.begin(4)) {
        Serial.println("ERROR - SD card initialization failed!");
        return;    // init failed
    }
    Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("INDEX~1.HTM")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");


  Serial.println("Staring Ethernet, setting MAC and assigning IP address...");
  Ethernet.begin(mac, ip, gateway, subnet);
  Serial.println("Begining webserver...");
  server.begin();
  Serial.print("Server is at ");
  Serial.println(Ethernet.localIP());
  oled.begin(&Adafruit128x32, I2C_ADDRESS);
  oled.setFont(Adafruit5x7);
  }
void loop() {

EthernetClient client = server.available();  // try to get client

    if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/html");
                    client.println("Connection: close");
                    client.println();
                    // send web page
                    webFile = SD.open("INDEX~1.HTM");        // open web page file
                    if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                        client.println("HTTP/1.1 200 OK");
                    client.println("Content-Type: text/css");
                    client.println("Connection: close");
                    client.println();
                        webFile = SD.open("MAIN.CSS");
                        if (webFile) {
                        while(webFile.available()) {
                            client.write(webFile.read()); // send web page to client
                        }
                        webFile.close();
                    }}
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client)
  
  //readdhtsensor();
  //delay(5000);
  //displaydhtdata();
  }
void readdhtsensor() {
  DHT.read11(DHT11_PIN);
  delay(1000);
  }
void displaydhtdata() {
  delay(1000);
  oled.clear();
  oled.set1X();
  oled.println(" Narnia Data Logger");
  oled.println("--------------------");
  oled.print(" Temperature    ");
  oled.print(DHT.temperature,0);
  oled.println("c");
  oled.print(" Humidity       ");
  oled.print(DHT.humidity,0);
  oled.println("%");
}

Thank you in advance

And one more thing, if I could be so bold;

I have built a 3.3v 1.5a power supply for the ESP-01 using a LM317T, however the dam thing will not power up with it, I am using the chip enable pin linked to the V+ and it just won't work.

Interestingly enough if I use jumper wires from the programmer usb board, it works

PIC;
https://ibb.co/rQHfrHn

Here is the powersupply;
https://ibb.co/wcGTK0K

Hello

use an I2C scanner to find out the right adress. Use any example of the Lib for the OLDE to find out if it works with a standard sketch.

I also missing a line in the Setup like

 // I2C Bus starten an pin 1 u pin 2
  Wire.begin(0, 2);

I have used this normaly together with an BME280 I2c Modul. The two buttons for reset and programming

Welcome,

The problem may be that you use SSD1306AsciiAvrI2c which is made especially for AVR microcontrollers, and the ESP-01 is not an AVR. I think you should use SSD1306AsciiWire instead.

Try this example : SSD1306Ascii/HelloWorldWire.ino at master · greiman/SSD1306Ascii · GitHub

And the RST pin ? It's needs to be HIGH as well.

[quote="khaycock, post:1, topic:853626"]
I have written the following script for my uno, which works, but I need to make it work on my ESP-01
[/quote]But hardware SPI, though available on an ESP8266 is problematic since the pins are not exposed.
with the help from my friends at Google i found 2 things.
This vague possibility to use FastLED as swSPI.
and this in which a picture says a thousand words.

Brahs, thank you for responding so fast,

I have tried the following;

// Test for minimum program size.

#include <Wire.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"

// 0X3C+SA0 - 0x3C or 0x3D
#define I2C_ADDRESS 0x3C

// Define proper RST_PIN if required.
#define RST_PIN -1


SSD1306AsciiWire oled;
//------------------------------------------------------------------------------
void setup() {
  Wire.begin(0, 2);
  Wire.setClock(400000L);

#if RST_PIN >= 0
  oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
  oled.begin(&Adafruit128x64, I2C_ADDRESS);
#endif // RST_PIN >= 0

  oled.setFont(System5x7);
  oled.clear();
  oled.print("Hello world!");
}
//------------------------------------------------------------------------------
void loop() {}

and I get this;

Pic;

It doesn't look like a 128*64 display.

Try replace &Adafruit128x64 by &Adafruit128x32 or &SSD1306_96x16

It doesn’t look like a 128*64 display.

Try replace &Adafruit128x64 by &Adafruit128x32 or &SSD1306_96x16

Getting closer...

Dammit even in my first code post I missed that...

oled.begin(&Adafruit128x32, I2C_ADDRESS);

Still trying...

Got it working with the following;


#include <Wire.h>
#include "SSD1306.h"
SSD1306  display(0x3c, 0, 2, GEOMETRY_128_32);

void setup() {
  Wire.pins(0, 2);
  Wire.begin(0,2);
  display.init();
  display.flipScreenVertically();// flipping came in handy for me with regard 
                                                                // to screen position
  display.setFont(ArialMT_Plain_10);

}


void loop() {
  display.clear();
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.setFont(ArialMT_Plain_16);
  display.drawString(0, 10, "Hello world");
  display.display();
  delay(10);
}

Using this library;

Thanks again for all your help

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.