File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
22# SPDX-License-Identifier: MIT
33
4+ from os import getenv
45import time
56import board
67import busio
910import adafruit_requests
1011from adafruit_wiznet5k .adafruit_wiznet5k import WIZNET5K
1112
12- # Get Adafruit.io details from a secrets.py file
13- try :
14- from secrets import secrets
15- except ImportError :
16- print ("WiFi secrets are kept in secrets.py, please add them there!" )
17- raise
13+ # Get Adafruit IO keys, ensure these are setup in settings.toml
14+ # (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
15+ aio_username = getenv ("ADAFRUIT_AIO_USERNAME" )
16+ aio_key = getenv ("ADAFRUIT_AIO_KEY" )
1817
1918cs = DigitalInOut (board .D10 )
2019spi_bus = busio .SPI (board .SCK , MOSI = board .MOSI , MISO = board .MISO )
3433 feed = "test"
3534 payload = {"value" : data }
3635 response = requests .post (
37- "http://io.adafruit.com/api/v2/"
38- + secrets ["aio_username" ]
39- + "/feeds/"
40- + feed
41- + "/data" ,
36+ f"http://io.adafruit.com/api/v2/{ aio_username } /feeds/{ feed } /data" ,
4237 json = payload ,
43- headers = {"X-AIO-KEY" : secrets [ " aio_key" ] },
38+ headers = {"X-AIO-KEY" : aio_key },
4439 )
4540 print (response .json ())
4641 response .close ()
You can’t perform that action at this time.
0 commit comments