FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ESP32S3-7814 added HT16K33 support, MQTT changes, webpage updates. · wbeebe/MicroPythonProjects@17fcf88 · GitHub

Repository navigation

Commit 17fcf88

Browse files
committed
ESP32S3-7814 added HT16K33 support, MQTT changes, webpage updates.
1 parent a3404f8 commit 17fcf88

23 files changed

Lines changed: 2810 additions & 64 deletions
-151 KB
Binary file not shown.
-219 KB
Binary file not shown.
187 KB
LoadingViewer requires iframe.
-156 KB
Binary file not shown.

‎Espressif/ESP32S3-7814/README.md‎

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,27 @@ ESP32S3-7814 is no longer a stand-alone WiFi access point. Because of the additi
1111

1212
This is the web page a fully functioning ESP32-S3 developer board presents now.
1313

14-
![Example webpage](../Assets/ESP32-S3-7814-Screenshot_20250614.png)
14+
![Example webpage](../Assets/ESP32-S3-7814-Screenshot_20250708.png)
1515

1616
The view the web page presents is dynamic. Here's what that means:
1717
1. If the OLED display isn't present, then the `Toggle OLED` button is not shown.
18-
2. If the ESP32-S3 fails to connect with the MQTT broker then the `MQTT5 Test` button is not shown.
18+
2. If the ESP32-S3 fails to connect with the MQTT broker then the `MQTT Report` button is not shown.
1919
3. If the ESP32-S3 developer board does not have a configured `vfs2` FLASH section, then the text at the bottom showing `vfs2 size` is not shown.
2020

2121
## Startup Output
2222
This startup output is captured from Thonny's REPL window.
2323
```
2424
Boot: START
25-
Memory: 8,297,184 bytes
25+
Memory: 8,172,048 bytes
2626
Flash: 33,554,432 bytes
2727
Platform: MicroPython 1.26.0 preview xtensa IDFv5.4.1 with newlib4.3.0
2828
Unique ID: 68B6B33D7814
2929
SSID: ESP32S3-7814
3030
CPU Clock: 160,000,000 Hz
3131
I2C: SoftI2C(scl=2, sda=1, freq=500000)
32-
I2C: Devices found: ['0x3d']
33-
I2C: SSD1306 OLED Found
32+
I2C: Devices found: ['0x3d', '0x70', '0x71']
33+
I2C: SSD1306 OLED Initialized
34+
I2C: HT16K33 LEDs Initialized
3435
Boot: END
3536
Main: START
3637
LED: COLORS
@@ -41,14 +42,13 @@ This startup output is captured from Thonny's REPL window.
4142
WIFI: 192.168.0.174
4243
WIFI: NTP Connection Attempt #1
4344
WIFI: NTP Connection Successful
44-
DATE: 8:28 AM Friday 27 June 2025
45+
DATE: 8:19 AM Monday 7 July 2025
4546
MQTT: Broker connection start from ESP32S3-7814 to 192.168.0.210
4647
MQTT: Set callback
4748
MQTT: Connect
4849
MQTT: Subscribe to topic b'esp32-mqtt5/test'
49-
MQTT: Init ping timer: Timer(3, mode=PERIODIC, period=60000)
50+
MQTT: Init ping timer: Timer(3, mode=PERIODIC, period=120000)
5051
MQTT: Broker connection successful to 192.168.0.210
51-
5252
```
5353
If the board fails to connect to the MQTT broker, this is the last part of the output:
5454
```
@@ -73,7 +73,7 @@ Install the latest MicroPython release to the ESP32-S3 development board. It can
7373

7474
Once the firmware is operational on the ESP32-S3 developer board, then upload all the Python files, and only the Python files, to the developer board.
7575

76-
You will need to create `settings.py` file that contains the two lines:
76+
You will need to create `settings.py` file that contains the following two lines:
7777
1. `AP_SSID = "your-wifi-SSID"` and
7878
2. `AP_PASSWORD = "your-wifi-password"`,
7979

@@ -86,7 +86,12 @@ Install Mosquitto via `apt`:
8686
```bash
8787
$ sudo apt install mosquitto mosquitto-clients -y
8888
```
89-
Once installed make sure that the Mosquitto broker is up and running:
89+
Once installed, add the following lines (at a minimum) to `/etc/mosquitto/conf.d/default.conf`:
90+
```
91+
allow_anonymous true
92+
listener 1883 0.0.0.0
93+
```
94+
Once installed make check if the Mosquitto broker is up and running:
9095
```bash
9196
$ systemctl status mosquitto
9297
● mosquitto.service - Mosquitto MQTT Broker
@@ -107,7 +112,7 @@ Jun 10 22:01:46 pi05-01 systemd[1]: Started mosquitto.service - Mosquitto MQTT B
107112
Jun 14 00:50:10 pi05-01 systemd[1]: Reloading mosquitto.service - Mosquitto MQTT Broker...
108113
Jun 14 00:50:10 pi05-01 systemd[1]: Reloaded mosquitto.service - Mosquitto MQTT Broker.
109114
```
110-
In the example above Mosquitto is loaded and active (running). If it's not, then type `sudo systemctl start mosquitto` at the prompt and check the status again.
115+
In the example above Mosquitto is loaded and active (running). If it is and you've edited the `default.conf` file, then type `sudo systemctl stop mosquitto` followed by `sudo systemctl start mosquitto` to read the configuration file. `systemctl` has a `restart` command, but I prefer a hard stop then a start to make sure everything is properly initialized.
111116
#### Development and Testing
112117
Once the broker is up, open a terminal and type the following:
113118
```bash
@@ -119,30 +124,36 @@ The application on the ESP32-S3 connects to the broker via the Mosquitto subscri
119124

120125
All ESP32-S3 minified JSON messages:
121126
```
122-
{"PWRON":"ESP32S3-7814","DATE":"2025-06-27T20:22:53.004Z"}
123-
{"PING":"ESP32S3-7814","DATE":"2025-06-27T20:23:53.004Z"}
124-
{"LED":"ESP32S3-7814","COLOR":"RED","STATE":"ON","DATE":"2025-06-27T20:24:01.004Z"}
125-
{"LED":"ESP32S3-7814","COLOR":"RED","STATE":"OFF","DATE":"2025-06-27T20:24:06.004Z"}
126-
{"LED":"ESP32S3-7814","COLOR":"GREEN","STATE":"ON","DATE":"2025-06-27T20:24:08.004Z"}
127-
{"LED":"ESP32S3-7814","COLOR":"GREEN","STATE":"OFF","DATE":"2025-06-27T20:24:10.004Z"}
128-
{"LED":"ESP32S3-7814","COLOR":"BLUE","STATE":"ON","DATE":"2025-06-27T20:24:12.004Z"}
129-
{"LED":"ESP32S3-7814","COLOR":"BLUE","STATE":"OFF","DATE":"2025-06-27T20:24:14.004Z"}
130-
{"TEST":"ESP32S3-7814","VERSION":"MicroPython 1.26.0 preview","COMPILER":"IDFv5.4.1","BUILD_DATE":"2025-06-26","DATE":"2025-06-27T20:24:17.004Z"}
131-
127+
{"PWRON":"ESP32S3-7814","DATE":"2025-07-08T18:54:56.001Z"}
128+
{"NEOP":"ESP32S3-7814","COLOR":"RED","STATE":"ON","DATE":"2025-07-08T18:55:05.001Z"}
129+
{"NEOP":"ESP32S3-7814","COLOR":"RED","STATE":"OFF","DATE":"2025-07-08T18:55:07.001Z"}
130+
{"NEOP":"ESP32S3-7814","COLOR":"GREEN","STATE":"ON","DATE":"2025-07-08T18:55:08.001Z"}
131+
{"NEOP":"ESP32S3-7814","COLOR":"GREEN","STATE":"OFF","DATE":"2025-07-08T18:55:09.001Z"}
132+
{"NEOP":"ESP32S3-7814","COLOR":"BLUE","STATE":"ON","DATE":"2025-07-08T18:55:11.001Z"}
133+
{"NEOP":"ESP32S3-7814","COLOR":"BLUE","STATE":"OFF","DATE":"2025-07-08T18:55:12.001Z"}
134+
{"REPORT":"ESP32S3-7814","OLED":"Enabled","ANLED":"Enabled","VERSION":"MicroPython 1.26.0 preview","COMPILER":"IDFv5.4.2","BUILD_DATE":"2025-07-07","DATE":"2025-07-08T18:55:15.001Z"}
135+
{"PING":"ESP32S3-7814","DATE":"2025-07-08T18:56:56.001Z"}
132136
```
133137
The `PWRON` message is sent every time the board successfully starts up and immediately after opening a connection to the MQTT broker.
134138

135-
The `PING` message is sent every 60 seconds.
139+
The `PING` message is sent every 120 seconds/two minutes.
136140

137-
The `LED` messages are generated from the web page buttons toggling the color LED. They tell which LED color is chosen and if the LED is on or off.
141+
The `NEOP` messages are generated from the web page buttons toggling the color NeoPixel. They tell which color is chosen and if it's state is on or off.
138142

139-
The `TEST` message is sent via the `MQTT5 Test` web page button. It sends the MicroPython version, the version of the ESP-IDF toolset that was used to build that MicroPython version and the date it was last built.
143+
The `REPORT` message is sent via the `MQTT Report` web page button. It sends if the OLED (`OLED`) display was found and enabled (None if not), if the alphanumeric (`ANLED`) 14-segment LEDs were found and enabled (None if not), MicroPython version, the version of the ESP-IDF toolset that was used to build that MicroPython version and the date it was last built.
140144

141145
Every message contains the SSID that sent the message.
142146

143-
Every message time stamp is in ISO 8601 format, UTC.
147+
Every message time stamp is ISO 8601 UTC.
144148

145149
## Changes and Updates
150+
#### _8 July 2025_
151+
152+
* Stepped up to ESP-IDF 5.4.2 to build the latest MicroPython sources.
153+
* Added drivers and hardware for HT16K33/YT16K33 14-segment LED displays. The LEDs display a 24 hour clock.
154+
The drivers are from **HT16K33 Drivers 4.2.0** (https://github.com/smittytone/HT16K33-Python) and are in the `lib` folder.
155+
* Cleaned up the code and web page to better align everything.
156+
146157
#### _26 June 2025_
147158

148159
After re-reading a specific MicroPython check-in, I re-ran `idf.py fullclean`, then `idf.py set-target esp32s3 menuconfig` to set the maximum amount of flash to 32 GiB. The latest checkins fixed the bug with the ESP32-S3 boards with more than 8 GiB of FLASH; those boards will now report the correct amount of FLASH.

‎Espressif/ESP32S3-7814/boot.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import machine
2323
import ssd1306
2424
import display_tools
25+
import ht16k33_tools as htools
2526

2627
print( " Boot: START")
2728
print(f" Memory: {gc.mem_free():,} bytes")
@@ -56,12 +57,16 @@
5657
# Check if there is an SSD1306 display attached.
5758
#
5859
if ssd1306.OLED_ADDR in i2c_scanned:
59-
print(" I2C: SSD1306 OLED Found")
6060
#
6161
# Create instance of SSD1306 class to control the
6262
# display. Initialize it by clearing everything.
6363
#
6464
DISPLAY = ssd1306.SSD1306_I2C(ssd1306.OLED_WIDTH, ssd1306.OLED_HEIGHT, SOFT_I2C)
6565
DISPLAY.fill(0)
66+
print(" I2C: SSD1306 OLED Initialized")
67+
68+
if htools.LED1_ADDR in i2c_scanned and htools.LED2_ADDR in i2c_scanned:
69+
htools.init(SOFT_I2C)
70+
print(" I2C: HT16K33 LEDs Initialized")
6671

6772
print(" Boot: END")

‎Espressif/ESP32S3-7814/display_tools.py‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
import time
2020
import mqtt_tools as mqtt
2121

22-
_display = None
23-
_ssid = None
24-
_ip = None
22+
display = None
23+
ssid = None
24+
ip = None
2525

26-
def do_graphics(display, SSID, ip):
27-
global _display, _ssid, _ip
26+
def do_graphics(_display, _ssid, _ip):
27+
global display, ssid, ip
2828

29-
_display = display
30-
_ssid = SSID
31-
_ip = ip
29+
display = _display
30+
ssid = _ssid
31+
ip = _ip
3232
#
3333
# Display the official MicroPython logo
3434
#
@@ -45,7 +45,7 @@ def do_graphics(display, SSID, ip):
4545
display.text(platform.platform().split('-')[1], 72, 0, 1)
4646
if mqtt.mqttClient is not None:
4747
display.text(f"MQTT {mqtt.mqtt_msg_count}", 40, 10, 1)
48-
display.text(SSID, 0, 36, 1)
48+
display.text(ssid, 0, 36, 1)
4949
display.text(str(ip), 0, 46, 1)
5050
now = time.localtime(time.time() + (-4 * 3600))
5151
year = now[0]
@@ -59,26 +59,26 @@ def do_graphics(display, SSID, ip):
5959
_show_display = True
6060

6161
def timer_callback(t):
62-
global _display, _show_display
62+
global display, _show_display
6363
_show_display = False
64-
_display.fill(0)
65-
_display.show()
64+
display.fill(0)
65+
display.show()
6666

6767
def setup_display_blank_timer():
6868
timer = Timer(2)
6969
timer.init(period=60000, mode=Timer.ONE_SHOT, callback=timer_callback)
7070

7171
def toggle_display_on_off():
72-
global _display, _ssid, _ip, _show_display
72+
global display, ssid, ip, _show_display
7373

74-
if _display is None:
74+
if display is None:
7575
return
7676

7777
_show_display = not _show_display
7878

7979
if _show_display:
80-
do_graphics(_display, _ssid, _ip)
80+
do_graphics(display, ssid, ip)
8181
setup_display_blank_timer()
8282
else:
83-
_display.fill(0)
84-
_display.show()
83+
display.fill(0)
84+
display.show()
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
Copyright 2025 William H. Beebe, Jr.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
17+
from machine import Timer
18+
import time
19+
from ht16k33 import HT16K33Segment14
20+
21+
LED1_ADDR = const(0x70)
22+
LED2_ADDR = const(0x71)
23+
LED3_ADDR = const(0x72)
24+
LED4_ADDR = const(0x73)
25+
26+
i2c = None
27+
led1 = None
28+
led2 = None
29+
# Make sure to uncomment the next three lines if you choose
30+
# to use the 12 hour clock.
31+
# 11111111112222
32+
# 012345678901234567890123
33+
#am_pm_str = "AAAAAAAAAAAAPPPPPPPPPPPP"
34+
35+
def clock_display_callback(timer_object):
36+
# Time calculation is hard-coded for EST/EDT (New York America).
37+
now = time.localtime(time.time() + (-4 * 3600))
38+
hours = now[3]
39+
minutes = now[4]
40+
seconds = now[5]
41+
atime = f"{hours:2d}{minutes:02d}{seconds:02d}"
42+
led1.set_character(atime[0], 0).set_character(atime[1], 1).set_glyph(0x0009, 2).set_character(atime[2], 3).draw()
43+
led2.set_character(atime[3], 0).set_glyph(0x0009, 1).set_character(atime[4], 2).set_character(atime[5], 3).draw()
44+
"""
45+
This code will produce a 12 hour clock with AM and PM indicator.
46+
I can't decide if I prefer the 12 hour display or the 24 hour display,
47+
so I have left (commented below) code in for both.
48+
am_pm = am_pm_str[hours]
49+
50+
if hours < 12:
51+
if hours == 0:
52+
hours = 12
53+
else:
54+
if hours > 12:
55+
hours -= 12
56+
57+
atime = f"{hours:2d}{minutes:02d}"
58+
led1.set_character(atime[0], 0).set_character(atime[1], 1).set_glyph(0x0009, 2).set_character(atime[2], 3).draw()
59+
led2.set_character(atime[3], 0).set_character(' ', 1).set_character(am_pm, 2).set_character('M', 3).draw()
60+
"""
61+
62+
def init(_i2c):
63+
global i2c, led1, led2
64+
i2c = _i2c
65+
led1 = HT16K33Segment14(i2c, board=HT16K33Segment14.ECBUYING_054)
66+
led1.set_brightness(2)
67+
led1.clear().draw()
68+
led2 = HT16K33Segment14(i2c, i2c_address=0x71, board=HT16K33Segment14.ECBUYING_054)
69+
led2.set_brightness(2)
70+
led2.clear().draw()
71+
72+
def start_clock():
73+
if i2c is None:
74+
return
75+
76+
timer = Timer(1)
77+
timer.init(period=1000, mode=Timer.PERIODIC, callback=clock_display_callback)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
__author__ = 'Tony Smith'
2+
__credits__ = ['Tony Smith', 'Ubi de Feo', 'akbiocca']
3+
__license__ = "MIT"
4+
__version__ = "4.2.0"
5+
__maintainer__ = "Tony Smith"
6+
7+
from .ht16k33 import *
8+
from .ht16k33bar import *
9+
from .ht16k33matrix import *
10+
from .ht16k33matrixcolour import *
11+
from .ht16k33matrixfeatherwing import *
12+
from .ht16k33matrixmulti import *
13+
from .ht16k33segment import *
14+
from .ht16k33segment14 import *
15+
from .ht16k33segmentbig import *
16+
from .ht16k33segmentgen import *

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL