import base64 에서 'NoneType' object has no attribute 'func' 에러 발생
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/lib/base64.py", line 9, in <module>
File "/lib/re.py", line 11, in <module>
AttributeError: 'NoneType' object has no attribute 'func'
/lib 폴더에 같이 설치된 re.py, ffilib.py 파일삭제 후 에러 해결
보이지는 않지만 microPython에 re.py, ffilib.py가 있어서 내장된 패키지 사용해야함
import network
import urequests
def connect_to_wifi(wlan, ssid, password):
if not wlan.isconnected():
print("Connecting to network...")
wlan.connect(ssid, password)
while not wlan.isconnected():
pass
connect_to_wifi(wlan, "WIFI-SSID", "WIFI-PASS")
#urequests 라이브러리 패키지 설치
import upip
upip.install('urequests')
#REST API 호출 후 JSON 화면에 출력
import network
import urequests
import epd
from time import sleep
def connect_to_wifi(wlan, ssid, password):
if not wlan.isconnected():
print("Connecting to network...")
wlan.connect(ssid, password)
while not wlan.isconnected():
pass
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
connect_to_wifi(wlan, "WIFI-SSID", "WIFI-PASS")
response = urequests.get('https://api.openweathermap.org/data/2.5/weather?q=Minneapolis&units=imperial&appid=APP_ID')
print(response.text)
weather_data = response.json()
epd47 = epd.EPD47()
epd47.power(True)
epd47.clear()
epd47.text(response.text, 100, 100, font_size=9)
REST API로 Response JSON 결과 값이 화면에 출력이 되는것을 확인할 수 있다.
C:\temp>esptool -p COM11 -b 460800 --before default_reset --after no_reset --chip esp32s3 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x0 build-LILYGO_T5-4.7-PLUS/bootloader/bootloader.bin 0x8000 build-LILYGO_T5-4.7-PLUS/partition_table/partition-table.bin 0x10000 build-LILYGO_T5-4.7-PLUS/micropython.bin
esptool.py v4.6.2
Serial port COM11
Connecting...
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 34:85:18:97:1c:0c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 16MB
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x00010000 to 0x0017cfff...
Compressed 18784 bytes to 12004...
Wrote 18784 bytes (12004 compressed) at 0x00000000 in 0.2 seconds (effective 761.3 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 117...
Wrote 3072 bytes (117 compressed) at 0x00008000 in 0.0 seconds (effective 888.1 kbit/s)...
Hash of data verified.
Compressed 1493136 bytes to 1026918...
Wrote 1493136 bytes (1026918 compressed) at 0x00010000 in 9.8 seconds (effective 1215.2 kbit/s)...
Hash of data verified.
Leaving...
Staying in bootloader.
from epd import EPD47
from random import randint
from time import sleep
e = EPD47()
e.power(True)
e.clear()
#x = randint(0, 960-200)
x = randint(0, 0)
y = randint(0, 0)
e.jpeg("/test2.jpg", x, y)
sleep(1)
#e.jpeg("/cat.jpg", 0, 0)
#sleep(1)a