1 of 27

Pre-Course Setup and Testing

UCLA Physics Department

1

University of California, Los Angeles

Department of Physics and Astronomy

​

Physics 4AL/4BL

​

2 of 27

Information about the class

The new Physics 4AL is designed to master three critical skills.

​

  • How to conduct experiments based on hypothesis and compare with observation.

​

  • How to design experiments by modern technology ESP32

​

  • How to take and analyze data by computer programing using Python

UCLA Physics Department

3 of 27

Lab Safety Rules

  • Electrical safety around live circuits and power supplies

​

  • Proper handling of shared lab equipment

​

  • No food or drinks

​

  • Proper attire (covered shoes, etc.)

​

  • Sealed water bottles

​

  • Reporting damaged or malfunctioning hardware

​

​

UCLA Physics Department

​

Electrical Safety

live circuits, power supplies

​

Equipment Handling

shared instruments and hardware

Lab Conduct

no food/drink, sealed bottles, covered shoes

4 of 27

Attendance & Participation

  • Consistent attendance at scheduled lab sessions

​

  • Active participation in setup, measurement, and analysis

​

  • Timely communication with TAs about conflicts

​

  • Constructive engagement with lab partners.

​

​

​

UCLA Physics Department

Lab Attendance

scheduled sessions and make-ups

Active Participation

setup, measurement, analysis

TA Communication

conflicts and questions, handled early

5 of 27

Use of AI

​

​

  • AI may support debugging, drafting, and understanding concepts

​

  • Analysis, conclusions, and write-ups remain the student's own work

​

  • Any substantive AI assistance should be disclosed, not hidden

​

  • Use must comply with University policy against plagiarism

​

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.

6 of 27

UCLA Physics Department

6

7 of 27

ESP32

UCLA Physics Departmentc

7

8 of 27

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”

9 of 27

ESP32 Download

​

UCLA Physics Department

9

10 of 27

ESP32 Connection (Windows)

UCLA Physics Department

10

11 of 27

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.

12 of 27

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 of 27

13

10

4

Confirm Successful Installation

When this confirmation appears, choose Close. The CH34x driver is installed.

14 of 27

Troubleshooting for Mac

  • If you aren’t able to upload sketches, after following tutorial directions to download the drivers (CH34x), go to System Settings > Privacy and Security > Allow, then reset computer and Arduino IDE for the drivers to work

Elegant Mind Club, UCLA

URW 5/22-26/2023

15 of 27

Arduino

UCLA Physics Department

15

Elegant Mind Club, UCLA

URW 5/22-26/2023

16 of 27

13

Downloads and references

  • Arduino IDE 2.3.10

Use the current Arduino IDE 2 release. The old 1.8.x Legacy IDE is no longer required for this course.

  • References

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

17 of 27

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

18 of 27

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

19 of 27

Downloads and references

  • Arduino IDE download (Scroll down to Windows or Mac options)
  • Arduino Reference
    • https://www.arduino.cc/reference/en/
    • Contains all the references for functions and variables

19

20 of 27

Arduino IDE

20

21 of 27

IDE Environment Configuration

21

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

​

Mac: Arduino -> Settings

22 of 27

IDE Environment Configuration

22

If everything’s right !

​

Make sure to select this board for the rest of this course!

​

23 of 27

Testing

UCLA Physics Department

23

Elegant Mind Club, UCLA

URW 5/22-26/2023

24 of 27

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

25 of 27

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

26 of 27

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

27 of 27

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