Pre-Course Setup and Testing
UCLA Physics Department
1
University of California, Los Angeles
Department of Physics and Astronomy
Physics 4AL/4BL
Information about the class
The new Physics 4AL is designed to master three critical skills.
UCLA Physics Department
Lab Safety Rules
UCLA Physics Department
Electrical Safety
live circuits, power supplies
Equipment Handling
shared instruments and hardware
Lab Conduct
no food/drink, sealed bottles, covered shoes
Attendance & Participation
UCLA Physics Department
Lab Attendance
scheduled sessions and make-ups
Active Participation
setup, measurement, analysis
TA Communication
conflicts and questions, handled early
Use of AI
UCLA Physics Department
Students should remember that the UCLA Student Conduct Code applies to GenAI, and states that “Unless otherwise specified by the faculty member, all submissions…must either be the Student’s own work, or must clearly acknowledge the source.” Students should consult with their instructors about the acceptable use of GenAI for each course.
UCLA Physics Department
6
ESP32
UCLA Physics Departmentc
7
ESP32 Connection (Windows)
UCLA Physics Department
8
Check if the computer can find the device. It should download CH340 automatically once connected. If not, follow further instructions.
You can also go to the start menu and type “Device Manager”
ESP32 Download
UCLA Physics Department
9
ESP32 Connection (Windows)
UCLA Physics Department
10
ESP32 Connection (Mac)
UCLA Physics Department
11
11
Download the CH34x Mac Driver
Open CH341SER_MAC.ZIP to extract the driver folder.
Open CH34xVCPDriver.pkg to start the macOS installer.
The folder also includes a PDF with installation instructions.
ESP32 Connection (Mac)
UCLA Physics Department
12
12
Complete the Driver Installation
1
Choose Continue
The installer identifies the CH34x VCP driver and shows version V2.1.
2
Proceed through the installer
Continue through Destination Select, Installation Type, and Installation.
3
Complete Installation
Follow the macOS prompts until the installer reaches the Summary screen.
13
10
4
Confirm Successful Installation
When this confirmation appears, choose Close. The CH34x driver is installed.
Troubleshooting for Mac
Elegant Mind Club, UCLA
URW 5/22-26/2023
Arduino
UCLA Physics Department
15
Elegant Mind Club, UCLA
URW 5/22-26/2023
13
Downloads and references
Use the current Arduino IDE 2 release. The old 1.8.x Legacy IDE is no longer required for this course.
4AL/4BL software versions
Install these through Boards Manager or Library Manager.
ESP32 by Espressif Systems
3.3.12
Adafruit MPU6050
2.2.9
Adafruit BusIO
1.17.4
Adafruit Unified Sensor
1.1.15
Library Manager can install required dependencies automatically when prompted.
UCLA Physics Department
15
IDE Environment Configuration
1 Add the ESP32 source
Open Arduino IDE Settings.
Find Additional Boards Manager URLs.
Add the stable Espressif package URL.
2 Install the ESP32 platform
Open Tools, Board, Boards Manager.
Search for esp32.
Choose esp32 by Espressif Systems and install it.
3 Confirm the version
For this course, use the stable ESP32 Arduino Core version 3.3.12.
Restart the Arduino IDE after installation.
Stable package URL
The stable index used by the IDE is:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
Boards Manager
esp32
esp32 by Espressif Systems 3.3.12
Version check
Boards Manager should show 3.3.12 as installed.
✓
UCLA Physics Department
16
IDE Environment Configuration
Final setup for the ESP32 WROVER boards used in 4AL
1
Connect the ESP32 to the computer with a USB data cable.
2
Open Tools, Board, esp32, then select ESP32 Wrover Module.
3
Open Tools, Port and select the serial port associated with the ESP32.
4
Upload a simple test sketch and open the Serial Monitor to confirm communication.
Board
ESP32 Wrover Module
✓ Ready
Mac note: if no serial port appears, install the current WCH CH34x macOS driver, then reconnect the board.
UCLA Physics Department
Downloads and references
19
Arduino IDE
20
IDE Environment Configuration
21
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Mac: Arduino -> Settings
IDE Environment Configuration
22
If everything’s right !
Make sure to select this board for the rest of this course!
Testing
UCLA Physics Department
23
Elegant Mind Club, UCLA
URW 5/22-26/2023
Running an Example
24
In your Arduino IDE, you can find multiple examples for the ESP32. First, make sure you have an ESP32 board selected in Tools > Board. Then, simply go to File > Examples and check out the examples under the ESP32 section.
For testing your hardware and software setup, try opening the WiFiScan example under File > Examples > WiFi > WiFiScan.
Elegant Mind Club, UCLA
URW 5/22-26/2023
Running an Example
25
1) Go to Tools > Board, scroll down to the ESP32 section and select the ESP32 Wrover board.
2) Go to Tools > Port and select a COM port available. If the COM port is grayed out, this means you don’t have the required USB drivers. Go back to the first slides in this presentation and install the CH340 driver.
3) Press the upload button:
(If the upload doesn’t work, try setting your “Upload Speed” to 115200)
Elegant Mind Club, UCLA
URW 5/22-26/2023
Testing
26
To see if the code is working as expected, open the Serial Monitor ( ) at a baud rate of 115200.
Press the ESP32 RST or EN button to restart the board and start running the newly uploaded code.
You should get a list of nearby wifi networks.
Elegant Mind Club, UCLA
URW 5/22-26/2023
Upload troubleshooting
27
Usually, your board will automatically go into flashing mode and the code will be successfully uploaded straight away.
Sometimes, it may not go into flashing mode automatically, so you may end up getting the following errors.
Failed to connect to ESP32: Timed out... Connecting...
A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.
This means the ESP32 was not in flashing mode when you tried to upload the code. In this situation, you should long press the board BOOT button, when you start seeing the “Connecting….” message on the debugging window.
(Boot and reset buttons are labeled and just to the side of the usb port)
Elegant Mind Club, UCLA
URW 5/22-26/2023