Skip to content

Commit b0f8490

Browse files
committed
Merge branch 'master' of github.com:ladyada/Adafruit_CircuitPython_ESP32SPI
2 parents e2699fc + 31fe2ef commit b0f8490

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def ping(self, dest, ttl=250):
447447

448448
def get_socket(self):
449449
"""Request a socket from the ESP32, will allocate and return a number that
450-
can then be passed to the other socket_ commands"""
450+
can then be passed to the other socket commands"""
451451
if self._debug:
452452
print("*** Get socket")
453453
resp = self._send_command_get_response(_GET_SOCKET_CMD)

examples/esp32spi_simpletest.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import board
2+
import busio
3+
from digitalio import DigitalInOut
4+
5+
from adafruit_esp32spi import adafruit_esp32spi
6+
import adafruit_esp32spi.adafruit_esp32spi_requests as requests
7+
8+
print("ESP32 SPI webclient test")
9+
10+
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
11+
JSON_URL = "http://api.coindesk.com/v1/bpi/currentprice/USD.json"
12+
13+
esp32_cs = DigitalInOut(board.ESP_CS)
14+
esp32_ready = DigitalInOut(board.ESP_BUSY)
15+
esp32_gpio0 = DigitalInOut(board.ESP_GPIO0)
16+
esp32_reset = DigitalInOut(board.ESP_RESET)
17+
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
18+
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset, esp32_gpio0)
19+
20+
requests.set_interface(esp)
21+
22+
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
23+
print("ESP32 found and in idle mode")
24+
print("Firmware vers.", esp.firmware_version)
25+
print("MAC addr:", [hex(i) for i in esp.MAC_address])
26+
print("APs: ", esp.scan_networks())
27+
print("Connecting to AP...")
28+
esp.connect_AP(b'adafruit', b'ffffffff')
29+
print("Connected to", esp.ssid, "RSSI", esp.rssi)
30+
print("My IP address is", esp.pretty_ip(esp.ip_address))
31+
print("IP lookup adafruit.com: %s" % esp.pretty_ip(esp.get_host_by_name("adafruit.com")))
32+
print("Ping google.com: %d ms" % esp.ping("google.com"))
33+
34+
#esp._debug = True
35+
print("Fetching text from", TEXT_URL)
36+
r = requests.get(TEXT_URL)
37+
print(r.text)
38+
r.close()
39+
40+
print("Fetching json from", JSON_URL)
41+
r = requests.get(JSON_URL)
42+
print(r.json())
43+
r.close()
44+
45+
print("Done!")

0 commit comments

Comments
 (0)