|
7 | 7 | This exampl us for the Espressif Soala Wrover with an OV2640 Camera |
8 | 8 |
|
9 | 9 | This example requires that your WIFI and Adafruit IO credentials be configured |
10 | | -in CIRCUITPY/secrets.py, and that you have created a feed called "image" with |
| 10 | +in CIRCUITPY/settings.toml, and that you have created a feed called "image" with |
11 | 11 | history disabled. |
12 | 12 |
|
13 | 13 | The maximum image size is 100kB after base64 encoding, or about 65kB before |
|
17 | 17 | """ |
18 | 18 |
|
19 | 19 | import binascii |
20 | | -import ssl |
21 | 20 | import time |
22 | | -from secrets import secrets # pylint: disable=no-name-in-module |
| 21 | +from os import getenv |
23 | 22 |
|
24 | 23 | import board |
25 | 24 | import busio |
26 | 25 | import wifi |
27 | | -import socketpool |
| 26 | +import adafruit_connection_manager |
28 | 27 | import adafruit_minimqtt.adafruit_minimqtt as MQTT |
29 | 28 | from adafruit_io.adafruit_io import IO_MQTT |
30 | 29 | import adafruit_ov2640 |
31 | 30 |
|
32 | 31 | feed_name = "image-saola-ov2640" |
33 | 32 |
|
| 33 | +# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml |
| 34 | +# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.) |
| 35 | +ssid = getenv("CIRCUITPY_WIFI_SSID") |
| 36 | +password = getenv("CIRCUITPY_WIFI_PASSWORD") |
| 37 | +aio_username = getenv("ADAFRUIT_AIO_USERNAME") |
| 38 | +aio_key = getenv("ADAFRUIT_AIO_KEY") |
| 39 | + |
34 | 40 | print("Connecting to WIFI") |
35 | | -wifi.radio.connect(secrets["ssid"], secrets["password"]) |
36 | | -pool = socketpool.SocketPool(wifi.radio) |
| 41 | +wifi.radio.connect(ssid, password) |
| 42 | +pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio) |
| 43 | +ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio) |
37 | 44 |
|
38 | 45 | print("Connecting to Adafruit IO") |
39 | 46 | mqtt_client = MQTT.MQTT( |
40 | 47 | broker="io.adafruit.com", |
41 | | - username=secrets["aio_username"], |
42 | | - password=secrets["aio_key"], |
| 48 | + username=aio_username, |
| 49 | + password=aio_key, |
43 | 50 | socket_pool=pool, |
44 | | - ssl_context=ssl.create_default_context(), |
| 51 | + ssl_context=ssl_context, |
45 | 52 | ) |
46 | 53 | mqtt_client.connect() |
47 | 54 | io = IO_MQTT(mqtt_client) |
|
0 commit comments