Skip to content

Commit 952b38b

Browse files
author
brentru
committed
fix redefined pins
1 parent 1b26dc6 commit 952b38b

File tree

2 files changed

+60
-4
lines changed

2 files changed

+60
-4
lines changed

examples/esp32spi_aio_post.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import time
2+
import board
3+
import busio
4+
from digitalio import DigitalInOut
5+
import neopixel
6+
from adafruit_esp32spi import adafruit_esp32spi
7+
from adafruit_esp32spi import adafruit_esp32spi_wifimanager
8+
9+
print("ESP32 SPI webclient test")
10+
11+
# Get wifi details and more from a secrets.py file
12+
try:
13+
from secrets import secrets
14+
except ImportError:
15+
print("WiFi secrets are kept in secrets.py, please add them there!")
16+
raise
17+
18+
# for externally connected ESP32
19+
esp32_cs = DigitalInOut(board.D9)
20+
esp32_ready = DigitalInOut(board.D10)
21+
esp32_reset = DigitalInOut(board.D5)
22+
23+
# For PyPortal use
24+
"""
25+
esp32_cs = DigitalInOut(board.ESP_CS)
26+
esp32_ready = DigitalInOut(board.ESP_BUSY)
27+
esp32_reset = DigitalInOut(board.ESP_RESET)
28+
"""
29+
30+
31+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
32+
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
33+
"""Use below for Most Boards"""
34+
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards
35+
"""Uncomment below for ItsyBitsy M4"""
36+
#status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
37+
wifi = adafruit_esp32spi_wifimanager.ESPSPI_WiFiManager(esp, secrets, status_light)
38+
39+
counter = 0
40+
41+
while True:
42+
try:
43+
print("Posting data...", end='')
44+
data = counter
45+
feed = 'test'
46+
payload = {'value':data}
47+
response = wifi.post(
48+
"https://io.adafruit.com/api/v2/"+secrets['aio_username']+"/feeds/"+feed+"/data",
49+
json=payload,
50+
headers={"X-AIO-KEY":secrets['aio_key']})
51+
print(response.json())
52+
response.close()
53+
counter = counter + 1
54+
print("OK")
55+
except (ValueError, RuntimeError) as e:
56+
print("Failed to get data, retrying\n", e)
57+
wifi.reset()
58+
continue
59+
response = None
60+
time.sleep(15)

examples/esp32spi_simpletest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
esp32_reset = DigitalInOut(board.ESP_RESET)
2424
"""
2525

26-
esp32_cs = DigitalInOut(board.ESP_CS)
27-
esp32_ready = DigitalInOut(board.ESP_BUSY)
28-
esp32_reset = DigitalInOut(board.ESP_RESET)
29-
3026
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
3127
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
3228

0 commit comments

Comments
 (0)