Unit 1 - Training�Lab 1A : Introduction to Python and ESP 32
UCLA Physics Department
1
University of California, Los Angeles
Department of Physics and Astronomy
Physics 4AL
Course Objectives
By the end of the quarter, you will be able to:
2
Course Objectives
To conduct your own research project, you will learn how to:
3
Outline of Lab 1A
UCLA Physics Department
4
Logistics
UCLA Physics Department
5
Lab Resources and Office hours
UCLA Physics Department
Class Schedule
Detailed schedule: https://www.uclaphysics4labs.org/weekly-schedule.html
UCLA Physics Department
7
Assignments
Grading info: https://www.uclaphysics4labs.org/4al-grading-policy.html
UCLA Physics Department
Online Lab Resources and Format
UCLA Physics Department
Miscellaneous Administrative Information
Section Switching
Course Questions
10
Introduction to Python
UCLA Physics Department
11
Python
12
Using Juypter
Log in link:
https://lab.onescienceplace.org/
Please note that material pulled from this link will be periodically updated as the course is changing throughout the quarter. Your TA will tell you when and if changes were made so that you can update you repos.
Sign in with your ucla gmail account. If you do not know the ucla gmail address which ends with a @g.ucla.edu, please check at https://g.ucla.edu/
click
click
click
has to be Google
Needs to end with g.ucla.edu
“Open app session” button might take 1~2 minutes to appear
Can access class material inside Physics_4AL/
Python Notebooks
21
Python Notebooks
22
Google Collaboratory Notebook
Input Code
Output
TA checkpoint 1 - Python Notebook
23
Numbers
UCLA Physics Department
Variables
UCLA Physics Department
Comments
UCLA Physics Department
Numpy
UCLA Physics Department
TA checkpoint 2 - Using Variables and Numpy
28
Introduction to circuit components
UCLA Physics Department
Electrical Components
Name of Component Electrical Diagram Actual Component Arduino Schematics
Component Polarity
Polarized
Non-Polarized
Breadboard
Black bars denote which holes are connected.
All pins on red column are connected. Similarly all pins on blue column are connected.
Breadboard
Introduction to ESP 32
UCLA Physics Department
34
ESP32
(specify by pinMode in code)
35
URW 5/21/24
24 Summer Training
New Setup !!!
ESP32 Input/Output
36
ESP32
UCLA Physics Departmentc
37
ESP32 Connection (Windows)
UCLA Physics Department
38
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
39
ESP32 Connection (Windows)
UCLA Physics Department
40
ESP32 Connection (Mac)
UCLA Physics Department
41
41
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
42
42
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.
43
10
4
Confirm Successful Installation
When this confirmation appears, choose Close. The CH34x driver is installed.
Troubleshooting for Mac
Arduino
UCLA Physics Department
45
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
49
Arduino IDE
50
IDE Environment Configuration
51
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Mac: Arduino -> Settings
IDE Environment Configuration
52
If everything’s right !
Make sure to select this board for the rest of this course!
Introduction to Digital Multimeter
UCLA Physics Department
Digital Multimeter
Potential measurements with Digital Multimeter
DC Voltage
AC Voltage
Resistance
Continuity
Capacitance
Frequency
Current (smallest)
Current (medium)
Current (largest)
Use left input
Measuring resistance with a multimeter
Set the multimeter to the 𝛀 symbol. Connect the two leads to the two ends of a 100 Ω resistor without connecting to any power source. The multimeter might take a moment to settle on a value, but it will read out a value close to 100 ohms.
TA Checkpoint 3 - Resistance measurements
57
Stated Resistance (Ω) | Measured resistance (Ω) |
| |
| |
| |
Testing ESP32 with multimeter
58
Testing ESP32 with multimeter
59
TA Checkpoint 4 - Voltage Measurements
Measurement | Voltage (V) |
5 V Pin (instructions in slide 36) | |
3.3 V Pin (this pin is close to the 5V pin) | |
Beginner’s Programming Notebook (for practice only)
61
Post-Lab Requirements for lab 1A
62