def __init__(self, esp, secrets, status_pixel=None, attempts=2): """ :param ESP_SPIcontrol esp: The ESP object we are using :param dict secrets: The WiFi and Adafruit IO secrets dict (See examples) :param status_pixel: (Optional) The pixel device - A NeoPixel or DotStar (default=None) :type status_pixel: NeoPixel or DotStar :param int attempts: (Optional) Failed attempts before resetting the ESP32 (default=2) """ # Read the settings self._esp = esp self.debug = False self.secrets = secrets self.attempts = attempts requests.set_interface(self._esp) self.statuspix = status_pixel self.pixel_status(0)
esp_boot.direction = Direction.OUTPUT esp_boot.value = True """ print("ESP AT commands") esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200, reset_pin=resetpin, rts_pin=rtspin, debug=False) URL = "http://wifitest.adafruit.com/testwifi/index.html" print("ESP AT GET URL", URL) print("Resetting ESP module") esp.hard_reset() requests.set_interface(esp) while True: try: print("Checking connection...") while not esp.is_connected: print("Connecting...") esp.connect(secrets) # great, lets get the data print("Retrieving URL...", end='') r = requests.get(URL) print("Status:", r.status_code) print("Content type:", r.headers['content-type']) print("Content size:", r.headers['content-length']) print("Encoding:", r.encoding) print("Text:", r.text)