File tree 1 file changed +7
-12
lines changed
1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 1
1
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2
2
# SPDX-License-Identifier: MIT
3
3
4
+ from os import getenv
4
5
import time
5
6
import board
6
7
import busio
9
10
import adafruit_requests
10
11
from adafruit_wiznet5k .adafruit_wiznet5k import WIZNET5K
11
12
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" )
18
17
19
18
cs = DigitalInOut (board .D10 )
20
19
spi_bus = busio .SPI (board .SCK , MOSI = board .MOSI , MISO = board .MISO )
34
33
feed = "test"
35
34
payload = {"value" : data }
36
35
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" ,
42
37
json = payload ,
43
- headers = {"X-AIO-KEY" : secrets [ " aio_key" ] },
38
+ headers = {"X-AIO-KEY" : aio_key },
44
39
)
45
40
print (response .json ())
46
41
response .close ()
You can’t perform that action at this time.
0 commit comments