This section of the tutorial is optional and designed for those who want to test the OLED display connected to their microcontroller. While you don’t need an OLED for your weather station, it’s helpful and convenient for showing stuff like temperature and humidity readings. If you’ve got one, this test will help you make sure it’s working properly.
The first step is to download the library for the display, and save it to a location on your computer that you are familiar with. To upload the library onto the microcontroller, open the terminal and run ampy --port COMX --baud 115200 put x:\location\ssd1306.py
, where “X” should be switched with the port number, and “x:\location\” with the actual location of the ssd1306.py file.
Alert
To check if the library is successfully uploaded, connect to the microcontroller via MobaXTerm. In the command prompt, run import os
, than os.listdir()
. You should see “['boot.py', 'ssd1306.py']˙ ” in the next line.
1from machine import Pin, SoftI2C
2import ssd1306
3i2c = SoftI2C(scl=Pin(15), sda=Pin(4))
4rst = Pin(16, Pin.OUT)
5rst.value(1)
6oled = ssd1306.SSD1306_I2C(128, 64, i2c)
7oled.fill(0)
8oled.text('Hello World', 0, 0)
9oled.show()
Tip
Take a look at your microcontroller’s display. You should see “Hello World” displayed on it.