ESP8266 displaying a QR code on an OLED display

In this example we will display a QR code on an OLED display with an ESP8266, in this case a Wemos mini. This will require a couple of libraries to be imported into the Arduino IDE.

 

Layout

 

Code

You will need a couple of libraries

https://github.com/anunpanya/ESP8266_QRcode

and

https://github.com/squix78/esp8266-oled-ssd1306

Now for a simple example, the key line is the class constructor – you need to put in your I2C address of your OLED module and then the SDA and SCL pins

#include <Wire.h>
#include "SSD1306.h"
#include <qrcode.h>
 
SSD1306 display(0x3c, D1, D2);
QRcode qrcode (&display);
 
void setup() 
{
 
  display.init();
  display.display();
 
  qrcode.init();
  qrcode.create("ESP8266 learning");
}
 
void loop() {}

Compile the code and upload and you should see a QR code on your OLED display, I could not quite get the QR code to fit on the Wemos mini OLED shield so I used a seperate OLED display connected

Here is my example running

esp8266 and oled displaying QR code
esp8266 and oled displaying QR code

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*