Skip to content

esp32/boards: Add LOLIN_S2_PICO. #7941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/esp32/boards/ESP32_S2_WROVER/board.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"deploy": [
"../deploy.md"
"../deploy_s2.md"
],
"docs": "",
"features": [],
Expand Down
18 changes: 18 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"deploy": [
"../deploy_s2.md"
],
"docs": "",
"features": [
"WiFi",
"USB-C"
],
"images": [
"lolin_s2_pico.jpg"
],
"mcu": "esp32s2",
"product": "S2 pico",
"thumbnail": "",
"url": "https://www.wemos.cc/en/latest/s2/s2_pico.html",
"vendor": "Wemos"
}
4 changes: 4 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("./modules")

freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")
38 changes: 38 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/modules/s2pico.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# LOLIN S2 PICO MicroPython Helper Library

from micropython import const
from machine import Pin, I2C, Signal
from s2pico_oled import OLED

# Pin Assignments

# SPI
SPI_MOSI = const(35)
SPI_MISO = const(36)
SPI_CLK = const(37)

# I2C
I2C_SDA = const(8)
I2C_SCL = const(9)

# DAC
DAC1 = const(17)
DAC2 = const(18)

# LED
LED = const(10)

# OLED
OLED_RST = const(18)

# BUTTON
BUTTON = const(0)

# Helper methods for built in sensors

led = Signal(LED, Pin.OUT, value=0, invert=True)

button = Pin(BUTTON, Pin.IN, Pin.PULL_UP)

i2c = I2C(0)
oled = OLED(i2c, Pin(OLED_RST))
48 changes: 48 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/modules/s2pico_oled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from time import sleep_ms
from ssd1306 import SSD1306_I2C
import network


class OLED(SSD1306_I2C):
def __init__(self, i2c, reset):
reset.init(reset.OUT, value=1)
self._reset = reset
self.reset(False)
super().__init__(128, 32, i2c)

def reset(self, reinit=True):
self._reset(1)
sleep_ms(1)
self._reset(0)
sleep_ms(10)
self._reset(1)
if reinit:
self.init_display()

def test(self):
self.fill(0)
self.fill_rect(0, 0, 32, 32, 1)
self.fill_rect(2, 2, 28, 28, 0)
self.vline(9, 8, 22, 1)
self.vline(16, 2, 22, 1)
self.vline(23, 8, 22, 1)
self.fill_rect(26, 24, 2, 4, 1)
self.text("MicroPython", 40, 0, 1)
self.text("SSD1306", 40, 12, 1)
self.text("OLED 128x32", 40, 24, 1)
self.show()

def display_wifi(self):
self.fill(0)
self.text("Scan...", 0, 0, 1)
self.show()

sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
_wifi = sta_if.scan()

self.fill(0)
self.text(str(len(_wifi)) + " Networks", 0, 0, 1)
self.text(str(_wifi[0][3]) + " " + (_wifi[0][0]).decode("utf-8"), 0, 12, 1)
self.text(str(_wifi[1][3]) + " " + (_wifi[1][0]).decode("utf-8"), 0, 24, 1)
self.show()
11 changes: 11 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(IDF_TARGET esp32s2)

set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
)

if(NOT MICROPY_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
endif()
12 changes: 12 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#define MICROPY_HW_BOARD_NAME "LOLIN_S2_PICO"
#define MICROPY_HW_MCU_NAME "ESP32-S2FN4R2"

#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_HW_ENABLE_SDCARD (0)

#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)

#define MICROPY_HW_SPI1_MOSI (35)
#define MICROPY_HW_SPI1_MISO (36)
#define MICROPY_HW_SPI1_SCK (37)
6 changes: 6 additions & 0 deletions ports/esp32/boards/LOLIN_S2_PICO/sdkconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_USB_AND_UART=y
# LWIP
CONFIG_LWIP_LOCAL_HOSTNAME="LOLIN_S2_PICO"
# end of LWIP