Adafruit AirLift Shield ESP32 Скачать руководство пользователя страница 38

#     tx=board.TX,
#     rx=board.RX,
# )

adapter = esp32.start_bluetooth()

ble = BLERadio(adapter)
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)

while True:
    ble.start_advertising(advertisement)
    print("waiting to connect")
    while not ble.connected:
        pass
    print("connected: trying to read input")
    while ble.connected:
        # Returns b'' if nothing was read.
        one_byte = uart.read(1)
        if one_byte:
            print(one_byte)
            uart.write(one_byte)

Talk to the AirLift via the Bluefruit LE Connect App

Start the Bluefruit LE Connect App on your phone or tablet. You should see a CIRCUITPY device available

to connect to. Tap the Connect button (1):

You'll then see a list of Bluefruit Connect functions ("modules"). Choose the UART module (2):

© Adafruit Industries

https://learn.adafruit.com/adafruit-airlift-shield-esp32-wifi-co-processor

Page 38 of 56

Содержание AirLift Shield ESP32

Страница 1: ...Adafruit AirLift Shield ESP32 WiFi Co Processor Created by Brent Rubell Last updated on 2021 03 29 01 04 51 PM EDT...

Страница 2: ...e WiFi Manager CircuitPython BLE CircuitPython BLE UART Example Adafruit AirLift ESP32 Shield Wiring Update the AirLift Firmware Install CircuitPython Libraries Install the Adafruit Bluefruit LE Conne...

Страница 3: ...ing nina fw with esptool Verifying the Upgraded Firmware Version Arduino CircuitPython Downloads Files Schematic Fab Print Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wi...

Страница 4: ...ps adafru it METROXMETR that comes with its own set of awesome peripherals and lots of libraries But it doesn t have WiFi or BLE built in So let s give that chip a best friend the ESP32 This chip can...

Страница 5: ...supports BLE Bluetooth Low Energy though not simultaneously with WiFi Many of our CircuitPython builds include native support for ESP32 BLE You use a few control pins and the RXI and TXO pins to talk...

Страница 6: ...d We ve tested this with all our Metros and it should work just fine with them except the Metro M4 Airlifts https adafru it F6o because they already have WiFi For use in Arduino the 328 and 32u4 you c...

Страница 7: ...nt of the Arduino WiFiNINA core which works great https adafru it E7O At this time connection to Enterprise WiFi is not yet supported Adafruit Industries https learn adafruit com adafruit airlift shie...

Страница 8: ...ower logic ground 3V this is the output from the 3 3V regulator The regulator can supply 500mA peak but half of that is drawn by the ESP32 and it s a fairly power hungry chip 5V This is the input to t...

Страница 9: ...a These pins are labeled CLK MISO MOSI and have level shifting so you can use this shield with 3 3V or 5V microcontroller boards By default the 2x3 pin ICSP header on the right hand side is where the...

Страница 10: ...ou ll need to connect it to use BLE mode Solder the pad on the bottom of the shield to connect it RX TX Serial data in and Serial data out used for bootloading new firmware and for communication when...

Страница 11: ...u d like to PWM them for a visual alert They re connected to the ESP32 s pins 26 Red 25 Green and 27 Blue Prototyping Area We have a big grid of prototyping holes and power rails if you want to make s...

Страница 12: ...nically stronger and they re much less expensive too If you want to stack a shield on top do not perform this step as it is not possible to uninstall the headers once soldered in Skip down to the bott...

Страница 13: ...nto the headers of your Arduino Place the assembled shield on top of the header ed Arduino so that all of the short parts of the header are sticking through the outer set of pads Adafruit Industries h...

Страница 14: ...Solder each one of the pins into the shield to make a secure connection Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 14 of 56...

Страница 15: ...That s it Now you can install the 2x3 header Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 15 of 56...

Страница 16: ...rt If you want to stack a shield on top of the WiFi Shield you ll want to pick up some stacking headers and use those instead of the plain header shown here Adafruit Industries https learn adafruit co...

Страница 17: ...the outer rows of the shield from the top Then flip the board over so its resting on the four headers Pull on the legs if necessary to straighten them out Tack one pin of each header to get them set...

Страница 18: ...ou ve tacked and straightened all the headers go back and solder the remaining pins for each header Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 18...

Страница 19: ...Insert the 2x3 stacking header as shown Solder into place Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 19 of 56...

Страница 20: ...Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 20 of 56...

Страница 21: ...lInOut board D10 esp32_ready DigitalInOut board D7 esp32_reset DigitalInOut board D5 If you wish to use the GPIO0 pin on the ESP32 solder the jumper on the back of the shield highlighted below Then in...

Страница 22: ...Usage Copy the following code to your code py file on your microcontroller import board import busio from digitalio import DigitalInOut from adafruit_esp32spi import adafruit_esp32spi print ESP32 SPI...

Страница 23: ...controller Pinout at the top of this page Once you ve succeeded continue onto the next page If you can read the Firmware and MAC address but fails on scanning SSIDs check your power supply you may be...

Страница 24: ...ur local WiFi setup As you make projects you may need more tokens and keys just add them one line at a time See for example other tokens such as one for accessing github or the hackaday API Other non...

Страница 25: ...crets are kept in secrets py please add them there raise print ESP32 SPI webclient test TEXT_URL http wifitest adafruit com testwifi index html JSON_URL http api coindesk com v1 bpi currentprice USD j...

Страница 26: ...le com esp _debug True print Fetching text from TEXT_URL r requests get TEXT_URL print 40 print r text print 40 r close print print Fetching json from JSON_URL r requests get JSON_URL print 40 print r...

Страница 27: ...using the adafruit_esp32spi_socket for this example We ll also set the interface to an esp object This is a little bit of a hack but it lets us use requests like CPython does requests set_socket sock...

Страница 28: ...adafruit com testwifi index html print Fetching text from TEXT_URL r requests get TEXT_URL print 40 print r text print 40 r close Or if the data is in structured JSON you can get the json pre parsed i...

Страница 29: ...ESP_SPIcontrol spi esp32_cs esp32_ready esp32_reset print Connecting to AP while not esp is_connected try esp connect_AP secrets ssid secrets password except RuntimeError as e print could not connect...

Страница 30: ...talInOut board D10 esp32_reset DigitalInOut board D5 spi busio SPI board SCK board MOSI board MISO esp adafruit_esp32spi ESP_SPIcontrol spi esp32_cs esp32_ready esp32_reset print Connecting to AP whil...

Страница 31: ...thon dict object We can also fetch and parse json data We ll send a HTTP get to a url we know returns a json formatted response instead of text data Then the code calls response json to convert the re...

Страница 32: ...your WiFi credentials DO NOT share that file or commit it into Git or other source control pylint disable no name in module wrong import order try from secrets import secrets except ImportError print...

Страница 33: ...if WiFi drops resetting the ESP32 if it gets into a bad state etc Here s a more advanced example that shows the WiFi manager and also how to POST data with some extra headers SPDX FileCopyrightText 2...

Страница 34: ...ht counter 0 while True try print Posting data end data counter feed test payload value data response wifi post https io adafruit com api v2 secrets aio_username feeds feed data json payload headers X...

Страница 35: ...Adafruit IO feed named test If you do not know how to set up a feed follow this page and come back when you ve set up a feed named test https adafru it f5k We can then have a simple loop for posting...

Страница 36: ...ble BLE The rest of the ESP32 pins you need are already jumpered to certain shield pins Update the AirLift Firmware You will need to update the AirLift s firmware to at least version 1 7 1 Previous ve...

Страница 37: ...r MatrixPortal you can use the default pin settings Leave this DEFAULT line uncommented esp32 ESP32 DEFAULT If you are using CircuitPython 6 0 0 or earlier on PyPortal and PyPortal Titano only use the...

Страница 38: ...ected Returns b if nothing was read one_byte uart read 1 if one_byte print one_byte uart write one_byte Talk to the AirLift via the Bluefruit LE Connect App Start the Bluefruit LE Connect App on your...

Страница 39: ...you can type a string and press Send 3 You ll see that string entered and then see it echoed back echoing is in gray Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co...

Страница 40: ...Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page 40 of 56...

Страница 41: ...amazing and written by the Arduino team The official WiFi101 library won t work because it doesn t support the ability to change the pins So We made a fork that you can install Click here to download...

Страница 42: ...t you ll need to need to modify the pin definition above for the AirLift Shield Replace the configuration in the sketch with the pinouts below define SPIWIFI SPI The SPI port define SPIWIFI_SS 10 Chip...

Страница 43: ...r for the ESP32 not to brown out WiFi Connection Test Now that you have your wiring checked time to connect to the Internet Open up the WiFiWebClient example https adafru it EVx Open up the secondary...

Страница 44: ...ck check wiring power and your SSID password https adafru it EVz Secure Connection Example Many servers today do not allow non SSL connectivity Lucky for you the ESP32 has a great TLS SSL stack so you...

Страница 45: ...afru it EVA Note we use WiFiSSLClient client instead of WiFiClient client to require an SSL connection Adafruit Industries https learn adafruit com adafruit airlift shield esp32 wifi co processor Page...

Страница 46: ...ru it Evn to convert that to a format we can use and then display that data on the serial port which can then be re directed to a display of some sort First up use the Library manager to install Ardui...

Страница 47: ...SS 10 Chip select pin define ESP32_RESETN 5 Reset pin define SPIWIFI_ACK 7 a k a BUSY or READY pin define ESP32_GPIO0 6 And then before you check the status of the module call the function WiFi setPin...

Страница 48: ...yWing External AirLift boards have three optional ESP32 control pins which are not connected by default ESPGPIO0 ESPRX ESPTX Make sure to solder each of these pads together You will not be able to upl...

Страница 49: ...rds it will be the only button available Tap this button twice to enter the bootloader If it doesn t work on the first try don t be discouraged The rhythm of the taps needs to be correct and sometimes...

Страница 50: ...nload Project ZIP to download the code below SerialNINAPassthrough Use esptool to flash the ESP32 module For use with PyPortal Metro M4 WiFi Copyright c 2018 Arduino SA All rights reserved This librar...

Страница 51: ...ESP32_RESETN 6 Reset pin define SPIWIFI_ACK 9 a k a BUSY or READY pin define ESP32_GPIO0 1 define NEOPIXEL_PIN 8 elif defined ARDUINO_NRF52832_FEATHER define SerialESP32 Serial1 define SPIWIFI SPI Th...

Страница 52: ...UF2 instructions above If you have an AirLift Breakout or are manually wiring up any of the boards above change the following pin definitions in the sketch to match your wiring elif defined SPIWIFI_S...

Страница 53: ...tyACM0 with the serial port of your board and NINA_W102 1 6 0 with the binary file you re flashing to the ESP32 esptool py port dev ttyACM0 before no_reset baud 115200 write_flash 0 NINA_W102 1 6 0 bi...

Страница 54: ...le Examples WiFiNINA ScanNetworks and upload the sketch Then open the Serial Monitor You should see the firmware version printed out to the serial monitor CircuitPython If you were previously using yo...

Страница 55: ...afru it EVE EagleCAD files on GitHub https adafru it F6p Fritzing object in Adafruit Fritzing Library https adafru it F6q Schematic Fab Print Adafruit Industries https learn adafruit com adafruit airl...

Страница 56: ...Adafruit Industries Last Updated 2021 03 29 01 04 51 PM EDT Page 56 of 56...

Страница 57: ...Mouser Electronics Authorized Distributor Click to View Pricing Inventory Delivery Lifecycle Information Adafruit 4285...

Отзывы: