Skip to content

Commit 8608472

Browse files
committed
i2c scan + wifi strong examples tested
1 parent a392e58 commit 8608472

File tree

3 files changed

+45
-18
lines changed

3 files changed

+45
-18
lines changed

examples/40-fm-tuner-rda5807/i2c_scan.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
Scanning I2C... 7 device(s) detected
1616
dec. hex.
1717
16 0x10 -- rda5807 (sequential access / RDA5800 mode)
18-
17 0x11 -- rda5807 (random access / RDA5807 mode !!!)
19-
35 0x23 -- bh1750 (light sensor)
20-
60 0x3c -- OLED (!!!)
18+
17 0x11 -- rda5807 (random access / RDA5807 mode)
19+
60 0x3c -- OLED
2120
96 0x60 -- rda5807 (TEA5767 compatible mode)
21+
119 0x77 -- bmp180 (pressure/temperature)
22+
23+
Older version:
24+
35 0x23 -- bh1750 (light sensor)
2225
104 0x68 -- mpu6050 (accel/gyro/temp)
23-
119 0x77 -- bmp180 (pressure/temperature !!!)
2426
"""
2527

2628
from machine import I2C
5.68 KB
Loading

examples/40-fm-tuner-rda5807/main.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- Tomas Fryza
1111
1212
Creation date: 2025-04-28
13-
Last modified: 2025-04-28
13+
Last modified: 2025-04-29
1414
1515
Inspired by:
1616
* https://docs.micropython.org/en/latest/esp8266/tutorial/ssd1306.html
@@ -35,22 +35,46 @@ def init_display():
3535
"""Initialize the OLED display and show startup screen."""
3636
i2c = SoftI2C(sda=Pin(21), scl=Pin(22)) #, freq=400_000)
3737
display = ssd1306.SSD1306_I2C(128, 64, i2c)
38-
display.sleep(False)
3938
display.contrast(100)
4039
display.fill(0)
4140

41+
print("Scanning I2C... ", end="")
42+
display.text("Scanning I2C...", 0, 5)
43+
44+
addrs = i2c.scan()
45+
# Scanning I2C... 5 device(s) detected
46+
# dec. hex.
47+
# 16 0x10 -- rda5807 (sequential access / RDA5800 mode)
48+
# 17 0x11 -- rda5807 (random access / RDA5807 mode)
49+
# 60 0x3c -- OLED
50+
# 96 0x60 -- rda5807 (TEA5767 compatible mode)
51+
# 119 0x77 -- bmp180 (pressure/temperature)
52+
print(f"{len(addrs)} device(s) detected")
53+
54+
print("dec.\t hex.")
55+
y = 16
56+
for addr in addrs:
57+
print(f"{addr}\t {hex(addr)}")
58+
display.text(hex(addr), 0, y)
59+
y += 8
60+
display.show() # Write the contents of the FrameBuffer to display memory
61+
time.sleep(8)
62+
display.fill(0)
63+
4264
# Draw logo (VUT Brno stylized)
4365
# https://www.designportal.cz/clanky/aktualizovano-vut-v-brne-bude-mit-nove-logo/
66+
# x, y, width, height, color
4467
display.fill_rect(0, 0, 32, 32, 1)
45-
display.fill_rect(5, 5, 14, 8, 0)
46-
display.fill_rect(15, 9, 26, 11, 0)
47-
display.fill_rect(15, 12, 18, 26, 0)
68+
display.fill_rect(5, 5, 10, 4, 0)
69+
display.fill_rect(15, 9, 12, 3, 0)
70+
display.fill_rect(15, 12, 4, 15, 0)
71+
# x, y, color
4872
display.pixel(19, 12, 0)
49-
50-
display.text("STEAM jcmm", 40, 0)
51-
display.text("VUT Brno", 40, 12)
52-
display.text("RadioElect.", 40, 24)
53-
display.show() # Write the contents of the FrameBuffer to display memory
73+
# string, x, y
74+
display.text("STEAM jcmm", 35, 5)
75+
display.text("VUT Brno", 35, 16)
76+
display.text("Radioelektr.", 35, 24)
77+
display.show()
5478
return display
5579

5680
def init_wifi():
@@ -72,17 +96,18 @@ def main():
7296
led.off()
7397

7498
display = init_display()
75-
wlan = init_wifi()
7699

77100
# Initial LED blink and display invert animation
78-
for _ in range(3):
101+
for _ in range(5):
79102
led.on()
80103
display.invert(1)
81104
time.sleep(0.5)
82105
led.off()
83106
display.invert(0)
84107
time.sleep(0.5)
85108

109+
wlan = init_wifi()
110+
86111
# Optional: Show MAC address
87112
# mac_bytes = wlan.config('mac')
88113
# mac_str = ':'.join(f'{b:02x}' for b in mac_bytes)
@@ -91,7 +116,7 @@ def main():
91116
# display.text(f"{mac_str}", 0, 48)
92117
# display.show()
93118

94-
display.text("Strongest WiFi:", 0, 40)
119+
display.text("Strongest Wi-Fi:", 0, 38)
95120
print("Scanning for Wi-Fi networks... Press Ctrl+C to stop.")
96121

97122
try:
@@ -108,7 +133,7 @@ def main():
108133
else:
109134
show_wifi(display, "<no networks>", 0)
110135
print("No networks found")
111-
time.sleep(2)
136+
time.sleep(1)
112137

113138
except KeyboardInterrupt:
114139
# This part runs when Ctrl+C is pressed

0 commit comments

Comments
 (0)