-
Notifications
You must be signed in to change notification settings - Fork 31
ESP_AT Support #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ESP_AT Support #15
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
""" | ||
Usage example of the ESP32 over UART | ||
using the CircuitPython ESP_ATControl library. | ||
|
||
Dependencies: | ||
* https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol | ||
""" | ||
from random import randint | ||
import board | ||
import busio | ||
from digitalio import DigitalInOut | ||
|
||
# Import Adafruit IO REST Client | ||
from adafruit_io.adafruit_io import RESTClient, AdafruitIO_RequestError | ||
|
||
# ESP32 AT | ||
from adafruit_espatcontrol import adafruit_espatcontrol, adafruit_espatcontrol_wifimanager | ||
|
||
#Use below for Most Boards | ||
import neopixel | ||
status_light = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) # Uncomment for Most Boards | ||
|
||
#Uncomment below for ItsyBitsy M4# | ||
#import adafruit_dotstar as dotstar | ||
#status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2) | ||
|
||
#Uncomment below for Particle Argon# | ||
#status_light = None | ||
|
||
# Get wifi details and more from a secrets.py file | ||
try: | ||
from secrets import secrets | ||
except ImportError: | ||
print("WiFi secrets are kept in secrets.py, please add them there!") | ||
raise | ||
|
||
# With a Metro or Feather M4 | ||
uart = busio.UART(board.TX, board.RX, timeout=0.1) | ||
resetpin = DigitalInOut(board.D5) | ||
rtspin = DigitalInOut(board.D6) | ||
|
||
# With a Particle Argon | ||
""" | ||
RX = board.ESP_TX | ||
TX = board.ESP_RX | ||
resetpin = DigitalInOut(board.ESP_WIFI_EN) | ||
rtspin = DigitalInOut(board.ESP_CTS) | ||
uart = busio.UART(TX, RX, timeout=0.1) | ||
esp_boot = DigitalInOut(board.ESP_BOOT_MODE) | ||
from digitalio import Direction | ||
esp_boot.direction = Direction.OUTPUT | ||
esp_boot.value = True | ||
""" | ||
|
||
esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200, | ||
reset_pin=resetpin, rts_pin=rtspin, debug=False) | ||
wifi = adafruit_espatcontrol_wifimanager.ESPAT_WiFiManager(esp, secrets, status_light) | ||
|
||
# Set your Adafruit IO Username and Key in secrets.py | ||
# (visit io.adafruit.com if you need to create an account, | ||
# or if you need your Adafruit IO key.) | ||
ADAFRUIT_IO_USER = secrets['adafruit_io_user'] | ||
ADAFRUIT_IO_KEY = secrets['adafruit_io_key'] | ||
|
||
# Create an instance of the Adafruit IO REST client | ||
io = RESTClient(ADAFRUIT_IO_USER, ADAFRUIT_IO_KEY, wifi) | ||
|
||
try: | ||
# Get the 'temperature' feed from Adafruit IO | ||
temperature_feed = io.get_feed('temperature') | ||
except AdafruitIO_RequestError: | ||
# If no 'temperature' feed exists, create one | ||
temperature_feed = io.create_new_feed('temperature') | ||
|
||
# Send random integer values to the feed | ||
random_value = randint(0, 50) | ||
print('Sending {0} to temperature feed...'.format(random_value)) | ||
io.send_data(temperature_feed['key'], random_value) | ||
print('Data sent!') | ||
|
||
# Retrieve data value from the feed | ||
print('Retrieving data from temperature feed...') | ||
received_data = io.receive_data(temperature_feed['key']) | ||
print('Data from temperature feed: ', received_data['value']) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.