Home Programming with ESP32 Lolin D32
Post
Cancel

Programming with ESP32 Lolin D32

Purchasing

This video does a good job explaining which ESP32 to buy: https://www.youtube.com/watch?v=mnoZYlyebBc&t=602s. For prototyping, I’m picking the Lolin D32 because of its low power draw and use in breadboarding https://docs.google.com/spreadsheets/d/1Mu-bNwpnkiNUiM7f2dx8-gPnIAFMibsC2hMlWhIHbPQ/edit

Install

  1. Download Arduino IDE: https://www.arduino.cc/en/software
  2. Go to File>Preferences and drop https://dl.espressif.com/dl/package_esp32_index.json into libraries
  3. Go to board manager, type in ESP 32, and install
  4. Download CH340 Driver: https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/
  5. Get a 100uF capacitor and connect from EN to ground pin https://randomnerdtutorials.com/solved-failed-to-connect-to-esp32-timed-out-waiting-for-packet-header/
  6. Test out a variety of usb cables until one works (the shorter the better)

Testing

  1. go to Tools > board > ESP32 Arduino > select the Lolin D32 Board
  2. select the Tools > Port > whichever COM port is available
  3. upload a blank sketch (File > New)
  4. Try uploading the SimpleTime sketch
    • Open: File > Examples > ESP32 > Time > Simple Time
  5. Put in your Wifi/password
  6. Put in your GMT offset
  7. Upload
  8. Go to Tools > Serial Monitor
  9. Tada

Pins

Check out this spreadsheet for what pins to use https://drive.google.com/file/d/1gbKM7DA7PI7s1-ne_VomcjOrb0bE2TPZ/view. This video helps explain it https://www.youtube.com/watch?v=LY-1DHTxRAk.

I2C (SDA/SCL)

For I2C connections, SDA pins of the microcontroller connect to SDA pins on the sensor, and likewise SCL connects to SCL. On the ESP32:

  • SDA: GPIO21
  • SCL: GPIO 22

Programming

Asyncrhonous Webserver

This website is a treasure trove of good info on programming with the ESP32 https://randomnerdtutorials.com/getting-started-with-esp32/. However, if you want to control things from your computer/phone or see sensor input, here’s the steps:

  1. Download the AsyncTSP library: https://github.com/me-no-dev/AsyncTCP
  2. Download the ESPAsyncWebServer: https://github.com/me-no-dev/ESPAsyncWebServer
  3. Unzip both files
  4. Drag into your Arduino Library Folder.
    • In my case, my Arduino folder was in my Documents folder, so the path was: C:\Users\Username\Documents\Arduino\libraries, but your path might be slightly different depending on where it’s located.

Troubleshooting

Com port not showing up

    1. open up device manager and check with ESP32 plugged in
    1. Now check without ESP32 but micro USB cable left in computer. If you don’t notice a difference, try a different USB cable OR try putting your laptop in full power mode (not battery saver).
    1. Download CH340 Driver: https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all
    2. Install
    3. Restart Computer
    4. Tada

      Error uploading

    1. Try new usb cable
    2. Try putting 100 uF capacitor from the enable pin to the ground pin. This tutorial suggests a 10uF capacitor, but I’ve found a 100uF cap works better: https://randomnerdtutorials.com/solved-failed-to-connect-to-esp32-timed-out-waiting-for-packet-header/
This post is licensed under CC BY 4.0 by the author.

DIY Camera Stand (Draft)

Designing a DIY Pull up bar (Draft)