OLED Sensor With Micropython Using BharatPi Board
by bharatpi in Circuits > Electronics
77 Views, 0 Favorites, 0 Comments
OLED Sensor With Micropython Using BharatPi Board
In this blog, you’ll learn how to use the OLED Sensor with the ESP32 using Micropython firmware. This tutorial covers how to wire the sensor to the ESP32 boards and provides a simple Micropython script for OLED display.
In this project, we are using Bharat Pi which has both an ESP32 microcontroller and a SimCom A7672S 4G/LTE module.
Bharat Pi is an IoT prototyping board for students, innovators, startups, and developers. A simplified board with an all-in-one compute, network and storage on a single board to build rapid prototypes.
Supplies
Parts required:
Here’s a list of the parts you need,
1. ESP32
3. OLED sensor
4. USB Cable
5. Jumper wires
Pre required:
To follow this instruction you need an IDE to write and upload the code to your board, you can use uPyCraft IDE or Thonny IDE.you also need Micropython firmware installed in your ESP32 boards.
If you don't have the setup means then you can check the README file of installing and setup of uPyCraft and Thonny IDE in our Bharat Pi github page you can find the link below,
> https://github.com/Bharat-Pi/MicroPython/blob/main/README.md
Schematic – ESP32 With OLED Sensor
In this section, we will see how to connect OLED sensor with ESP32. The OLED sensor will be connected with the ESP32 board with its pins.
Follow the schematic diagram for the ESP modules and connect them accordingly. Connect the ESP32 device with the OLED sensor as shown in the schematic diagram above:
Pinout of the OLED Sensor :
OLED Sensor - ESP32
VCC - Power Supply
SDA - SDA
SCL - SCL
GND - GND
Wire the OLED sensor to the ESP32 as shown in the following schematic diagram. We’re connecting the vcc pin to 3v/5v and the sda pin to sda, scl pin to scl pin of esp32 and GND pin to GND of esp32.
ESP32 Wiring With OLED Sensor :
OLED Sensor - ESP32
VCC - 5V / 3V
SDA - SDA
SCL- SCL
GND - GND
OLED Sensor
An OLED (Organic Light-Emitting Diode) display is a type of flat-panel display technology that uses organic compounds to produce light when an electric current is applied. Unlike traditional LCD displays, OLEDs do not require a backlight because each pixel emits its own light. This allows OLED displays to achieve deeper blacks, higher contrast ratios, faster response times, and wider viewing angles compared to LCDs.
OLED displays are widely used in various electronic devices, including smartphones, tablets, televisions, computer monitors, and wearable devices, due to their flexibility, thinness, and energy efficiency. They are also favored for their ability to produce vibrant colors and sharp images.
There are different types of OLED displays, such as passive-matrix OLEDs (PMOLEDs) and active-matrix OLEDs (AMOLEDs). AMOLEDs are more commonly used in modern consumer electronics because they offer faster refresh rates and higher resolution compared to PMOLEDs.
Overall, OLED displays offer several advantages over traditional display technologies, making them a popular choice for manufacturers and consumers alike.
CODE Snippet
from machine import Pin, SoftI2C
import ssd1306
from time import sleep
# ESP32 Pin assignment
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
# ESP8266 Pin assignment
#i2c = SoftI2C(scl=Pin(5), sda=Pin(4))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.text('Hello ', 0, 0)
oled.text('welcomem to' , 0, 10)
oled.text('Bharat Pi ', 0, 20)
oled.show()