Merge pull request #29 from justmobilize/remove-secrets-usage
Remove secrets usage
This commit is contained in:
commit
8e59509ced
3 changed files with 33 additions and 19 deletions
|
|
@ -89,7 +89,7 @@ Preview images on LCD then save BMP images to SD on Kaluga 1.3 fitted with an il
|
|||
Kaluga 1.3 with Adafruit IO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Upload JPEG images to Adafruit IO. Requires that WIFI and Adafruit IO be configured in ``secrets.py``.
|
||||
Upload JPEG images to Adafruit IO. Requires that WIFI and Adafruit IO be configured in ``settings.toml``.
|
||||
|
||||
.. literalinclude:: ../examples/ov2640_aio_kaluga1_3.py
|
||||
:caption: ov2640_aio_kaluga1_3.py
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ The audio board must be mounted between the Kaluga and the LCD, it provides the
|
|||
I2C pull-ups(!)
|
||||
|
||||
This example requires that your WIFI and Adafruit IO credentials be configured
|
||||
in CIRCUITPY/secrets.py, and that you have created a feed called "image" with
|
||||
in CIRCUITPY/settings.toml, and that you have created a feed called "image" with
|
||||
history disabled.
|
||||
|
||||
The maximum image size is 100kB after base64 encoding, or about 65kB before
|
||||
|
|
@ -21,31 +21,38 @@ base64 encoding. In practice, "SVGA" (800x600) images are typically around
|
|||
"""
|
||||
|
||||
import binascii
|
||||
import ssl
|
||||
import time
|
||||
from secrets import secrets # pylint: disable=no-name-in-module
|
||||
from os import getenv
|
||||
|
||||
import board
|
||||
import busio
|
||||
import wifi
|
||||
import socketpool
|
||||
import adafruit_connection_manager
|
||||
import adafruit_minimqtt.adafruit_minimqtt as MQTT
|
||||
from adafruit_io.adafruit_io import IO_MQTT
|
||||
import adafruit_ov2640
|
||||
|
||||
feed_name = "image"
|
||||
|
||||
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
|
||||
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
|
||||
ssid = getenv("CIRCUITPY_WIFI_SSID")
|
||||
password = getenv("CIRCUITPY_WIFI_PASSWORD")
|
||||
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
|
||||
aio_key = getenv("ADAFRUIT_AIO_KEY")
|
||||
|
||||
print("Connecting to WIFI")
|
||||
wifi.radio.connect(secrets["ssid"], secrets["password"])
|
||||
pool = socketpool.SocketPool(wifi.radio)
|
||||
wifi.radio.connect(ssid, password)
|
||||
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
|
||||
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
|
||||
|
||||
print("Connecting to Adafruit IO")
|
||||
mqtt_client = MQTT.MQTT(
|
||||
broker="io.adafruit.com",
|
||||
username=secrets["aio_username"],
|
||||
password=secrets["aio_key"],
|
||||
username=aio_username,
|
||||
password=aio_key,
|
||||
socket_pool=pool,
|
||||
ssl_context=ssl.create_default_context(),
|
||||
ssl_context=ssl_context,
|
||||
)
|
||||
mqtt_client.connect()
|
||||
io = IO_MQTT(mqtt_client)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
This exampl us for the Espressif Soala Wrover with an OV2640 Camera
|
||||
|
||||
This example requires that your WIFI and Adafruit IO credentials be configured
|
||||
in CIRCUITPY/secrets.py, and that you have created a feed called "image" with
|
||||
in CIRCUITPY/settings.toml, and that you have created a feed called "image" with
|
||||
history disabled.
|
||||
|
||||
The maximum image size is 100kB after base64 encoding, or about 65kB before
|
||||
|
|
@ -17,31 +17,38 @@ base64 encoding. In practice, "SVGA" (800x600) images are typically around
|
|||
"""
|
||||
|
||||
import binascii
|
||||
import ssl
|
||||
import time
|
||||
from secrets import secrets # pylint: disable=no-name-in-module
|
||||
from os import getenv
|
||||
|
||||
import board
|
||||
import busio
|
||||
import wifi
|
||||
import socketpool
|
||||
import adafruit_connection_manager
|
||||
import adafruit_minimqtt.adafruit_minimqtt as MQTT
|
||||
from adafruit_io.adafruit_io import IO_MQTT
|
||||
import adafruit_ov2640
|
||||
|
||||
feed_name = "image-saola-ov2640"
|
||||
|
||||
# Get WiFi details and Adafruit IO keys, ensure these are setup in settings.toml
|
||||
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
|
||||
ssid = getenv("CIRCUITPY_WIFI_SSID")
|
||||
password = getenv("CIRCUITPY_WIFI_PASSWORD")
|
||||
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
|
||||
aio_key = getenv("ADAFRUIT_AIO_KEY")
|
||||
|
||||
print("Connecting to WIFI")
|
||||
wifi.radio.connect(secrets["ssid"], secrets["password"])
|
||||
pool = socketpool.SocketPool(wifi.radio)
|
||||
wifi.radio.connect(ssid, password)
|
||||
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
|
||||
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
|
||||
|
||||
print("Connecting to Adafruit IO")
|
||||
mqtt_client = MQTT.MQTT(
|
||||
broker="io.adafruit.com",
|
||||
username=secrets["aio_username"],
|
||||
password=secrets["aio_key"],
|
||||
username=aio_username,
|
||||
password=aio_key,
|
||||
socket_pool=pool,
|
||||
ssl_context=ssl.create_default_context(),
|
||||
ssl_context=ssl_context,
|
||||
)
|
||||
mqtt_client.connect()
|
||||
io = IO_MQTT(mqtt_client)
|
||||
|
|
|
|||
Loading…
Reference in a new issue