background image

 

Adafruit Airlift Bitsy Add-On - ESP32 WiFi

Co-Processor

Created by Bryan Siepert

 

https://learn.adafruit.com/adafruit-airlift-bitsy-add-on-esp32-wifi-co-processor

Last updated on 2021-11-15 07:47:52 PM EST

©Adafruit Industries

Page 1 of 54

Summary of Contents for Airlift Bitsy Add-On

Page 1: ...Bitsy Add On ESP32 WiFi Co Processor Created by Bryan Siepert https learn adafruit com adafruit airlift bitsy add on esp32 wifi co processor Last updated on 2021 11 15 07 47 52 PM EST Adafruit Industr...

Page 2: ...ocontroller Pinout CircuitPython Installation of ESP32SPI Library CircuitPython Usage CircuitPython BLE CircuitPython BLE UART Example Update the AirLift Firmware Install CircuitPython Libraries Insta...

Page 3: ...52 52 53 53 53 53 54 Verifying the Upgraded Firmware Version Arduino CircuitPython Downloads Files Schematic Fab Print Adafruit Industries Page 3 of 54...

Page 4: ...Adafruit Industries Page 4 of 54...

Page 5: ...ike the ItsyBitsy M4 https adafru it BQC that comes with its own set of awesome peripherals and lots of libraries But it doesn t have WiFi built in So let s give that chip a best friend the ESP32 This...

Page 6: ...aneously with WiFi Many of our CircuitPython builds include native support for ESP32 BLE Right now we only support the ESP32 acting as a BLE peripheral but that s sufficient to communicate with the ES...

Page 7: ...Pinouts Adafruit Industries Page 7 of 54...

Page 8: ...and Control Pins To keep transfers speedy we use SPI not UART Serial UART is too slow and hard to synchronize This uses more pins but the experience is much better Classic SPI Pins SCK SPI Clock from...

Page 9: ...to bootloading mode if you want to update the firmware It is also used if you like when the ESP32 is acting as a server to let you know data is ready for reading It s not required in WiFi mode but you...

Page 10: ...he left of the ESP32 These RGB LEDs are available in the Arduino and CircuitPython libraries if you d like to PWM them for a visual alert They re connected to the ESP32 s pins 26 Red 25 Green and 27 B...

Page 11: ...Assembly The antenna on the new smaller ESP32 module is very delicate Avoid touching it and grab the add on by the long sides to avoid smushing the antenna Adafruit Industries Page 11 of 54...

Page 12: ...WV module This module allows you to easily add WiFi to your project CircuitPython Microcontroller Pinout Since all CircuitPython running ItsyBitsies follow the same pinout you do not need to change an...

Page 13: ...raries from the bundle adafruit_esp32spi adafruit_requests mpy adafruit_bus_device Before continuing make sure your board s lib folder or root filesystem has the adafrui t_esp32spi adafruit_requests m...

Page 14: ...that we ve changed the pinout in the code example above to reflect the CircuitPython Microcontroller Pinout at the top of this page Once you ve succeeded continue onto the next page Internet Connect O...

Page 15: ..._token h4xx0rs3kret Inside is a python dictionary named secrets with a line for each entry Each entry has an entry name say ssid and then a colon to separate it from the entry key home ssid and finall...

Page 16: ...rt secrets except ImportError print WiFi secrets 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...

Page 17: ...8 tRSSI esp rssi print My IP address is esp pretty_ip esp ip_address print IP lookup adafruit com s esp pretty_ip esp get_host_by_name adafruit com print Ping google com d ms esp ping google com esp...

Page 18: ...ry the type of socket we re using socket type varies by connectivity type we ll be using the adafruit_esp32spi_socket for this example We ll also set the interface to an esp object This is a little bi...

Page 19: ...st_by_name adafruit com OK now we re getting to the really interesting part With a SAMD51 or other large RAM well over 32 KB device we can do a lot of neat tricks Like for example we can implement an...

Page 20: ...ept ImportError print WiFi secrets are kept in secrets py please add them there raise If you are using a board with pre defined ESP32 Pins esp32_cs DigitalInOut board ESP_CS esp32_ready DigitalInOut b...

Page 21: ...e json Parse out the json key from json_resp dict print JSON Data received from server json_resp json print 40 response close The code first sets up the ESP32SPI interface Then it initializes a reques...

Page 22: ...s response we can read it back Luckily for us request s automatically decodes the server s response into human readable text you can read it back by calling response text Lastly we ll perform a bit o...

Page 23: ...formatted data to a server by passing json_data into the re quests post method json_data Date July 25 2019 print POSTing data to 0 1 format JSON_POST_URL json_data response requests post JSON_POST_URL...

Page 24: ...0 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 while not esp is_conn...

Page 25: ...i secrets are kept in secrets py please add them there raise If you are using a board with pre defined ESP32 Pins esp32_cs DigitalInOut board ESP_CS esp32_ready DigitalInOut board ESP_BUSY esp32_reset...

Page 26: ...ome additional information to your secrets file so that the code can query the Adafruit IO API aio_username aio_key You can go to your adafruit io View AIO Key link to get those two values and add the...

Page 27: ...adafru it DWV module This module allows you to easily add WiFi to your project You need plenty of RAM for CircuitPython requests json so the ItsyBitsy M0 will not work Please use an Itsy with at leas...

Page 28: ...CircuitPython starter guide has a great page on how to install the library bundle https adafru it ABU You can manually install the necessary libraries from the bundle adafruit_esp32spi adafruit_bus_d...

Page 29: ...utf 8 ap rssi print Done Connect to the serial console https adafru it BlO to see the output It should look something like the following Make sure you see the same output If you don t check your wirin...

Page 30: ...Airlift Bitsy ESP32 Add On you will need to solder three jumpers closed on the bottom side of the board to enable BLE The rest of the ESP32 pins you need are already jumpered to certain ItsyBitsy pins...

Page 31: ..._ble folders copied over Install the Adafruit Bluefruit LE Connect App The Adafruit Bluefruit LE Connect iOS and Android apps allow you to connect to BLE peripherals that provide a over the air UART s...

Page 32: ...you are using an AirLift Breakout check that these choices match the wiring to your microcontroller board or change them as appropriate esp32 ESP32 reset board D12 gpio0 board D10 busy board D11 chip...

Page 33: ...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 C...

Page 34: ...On the UART module page 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 Page 34 of 54...

Page 35: ...or add sensors and SD card you ll really want an ATSAMD21 Cortex M0 or ATSAMD51 Cortex M4 both of which have plenty or RAM Library Install We re using a variant of the Arduino WiFiNINA library which i...

Page 36: ...FiNINA https adafru it Evm Within the Arduino IDE select Install library from ZIP First Test OK now you have it wired and library installed time to test it out Lets start by scanning the local network...

Page 37: ...pins are defined https adafru it EVv If you don t see this you may have the wrong WiFiNINA library installed Uninstall it and re install the Adafruit one as above Compile and upload to your board wire...

Page 38: ...the MAC address but cannot scan any networks check your power supply You need a solid 3 3V into Vin in order for the ESP32 not to brown out WiFi Connection Test Now that you have your wiring checked...

Page 39: ...SSID password to your network https adafru it EVy You must change these string values before updating to your board After you ve set it correctly upload and check the serial monitor You should see the...

Page 40: ...Example Many servers today do not allow non SSL connectivity Lucky for you the ESP32 has a great TLS SSL stack so you can have that all taken care of for you Here s an example of a secure WiFi connec...

Page 41: ...h Note we use WiFiSSLClient client instead of WiFiClient client to require an SSL connection Adafruit Industries Page 41 of 54...

Page 42: ...Adafruit Industries Page 42 of 54...

Page 43: ...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 ArduinoJSON https adafru it Evo Then load the example JSO...

Page 44: ...pad on the bottom of the Bitsy Add on and set define ESP32_GPIO0 to the correct pin for your microcontroller For the ItsyBitsies it will be D10 10 And then before you check the status of the module c...

Page 45: ...d Upload Serial Passthrough code for Feather or ItsyBitsy First back up any code and files you have on your CIRCUITPY drive It will be overwritten by the code you re going to upload to your board You...

Page 46: ...needs to be correct and sometimes it takes a few tries Once successful the RGB LED on the board will flash red and then stay green A new drive will show up on your computer The drive will be called bo...

Page 47: ...tty Mac or Linux in a terminal If your board is listed in the terminal proceed to the Uploading nina fw with esptool s ection of this guide External AirLift Breakout You ll be turning your Arduino boa...

Page 48: ...klin St Fifth Floor Boston MA 02110 1301 USA include Adafruit_NeoPixel h unsigned long baud 115200 if defined ADAFRUIT_FEATHER_M4_EXPRESS defined ADAFRUIT_FEATHER_M0_EXPRESS defined ARDUINO_AVR_FEATHE...

Page 49: ...ined ADAFRUIT_PYPORTAL define PIN_NEOPIXEL 2 elif defined ADAFRUIT_METRO_M4_AIRLIFT_LITE define PIN_NEOPIXEL 40 endif Adafruit_NeoPixel pixel Adafruit_NeoPixel 1 PIN_NEOPIXEL NEO_GRB NEO_KHZ800 void s...

Page 50: ...7 a k a BUSY or READY pin define ESP32_RESETN 5 Reset pin define ESP32_GPIO0 1 Not connected define NEOPIXEL_PIN 8 endif Using the Arduino IDE upload the code to your board Sketch Upload After uploadi...

Page 51: ...y port dev ttyACM0 before no_reset baud 115200 write_flash 0 NINA_W102 1 6 0 bin If you re using Windows run the following command replacing COM7 with the serial port of your board and NINA_W102 1 6 0...

Page 52: ...er using a solder sucker https adafru it FWk or a bit of solder wick https adafru it yrC Arduino If you were previously using your ESP32 with Arduino you should load up an Arduino sketch to verify eve...

Page 53: ...earlier to CIRCUITPY To verify the new ESP32 WiFi firmware version is correct follow the Connect to WiFi step in this guide https adafru it Eao and come back here when you ve successfully ran the cod...

Page 54: ...Fab Print Adafruit Industries Page 54 of 54...

Page 55: ...Mouser Electronics Authorized Distributor Click to View Pricing Inventory Delivery Lifecycle Information Adafruit 4363...

Reviews: