A chronometer is a timekeeping device used to measure the amount of time elapsed between its activation and deactivation. It typically consists of a digital or analog display and buttons to start, stop, and reset the timer. chronometer functions are commonly used in sports, fitness activities, scientific experiments, and various timed events where precise timing is essential.
Using a chronometer with ESP32 board is a fun and educational project. You can create a simple chronometer using theESP32 board and some additional components like buttons and LCD I2C 1602 display.
The operation of the chronometer controlled by the ESP32 board with LCD I2C 1602 display and push buttons can be described as follows:
Initial Startup: When you power theESP32 board, the timer begins to display Press START on the LCD I2C 1602 display.
Start Button: By pressing the Start button, the chronometer starts measuring the time from 00:00 until you press the Stop button.
When the chronometer is running, the LCD I2C 1602 display shows the elapsed time in minutes and seconds, for example, 00:15 (15 seconds elapsed), 01:30 (1 minute and 30 seconds), etc.
Pressing the stop button again causes the chronometer to freeze, recording the time elapsed up to that point, without setting it to zero.
Reset Button: By pressing the reset button, the timer returns to 00:00, thereby resetting the elapsed time to zero, regardless of its previous state (running or stopped).
This operation allows you to control the chronometer using the push buttons: start to start measuring time, stop to freeze the current time and reset to reset the chronometer to zero. The LCD I2C 1602 display shows real-time elapsed time in minutes:seconds format while the chronometer is running.
To build a chronometer controlled by an ESP32 board, you'll need several components to create the necessary functionalities. Here's a list of components required:
ESP32 board:
The ESP32 is a powerful microcontroller developed by Espressif Systems. It's renowned for its integrated Wi-Fi and Bluetooth capabilities, making it a popular choice for various IoT (Internet of Things) applications.
LCD I2C 1602 Display:
The LCD I2C 1602 display is a type of liquid crystal display (LCD) that utilizes the I2C (Inter-Integrated Circuit) communication protocol to interface with microcontrollers or other devices.
The display is used to show the elapsed time of the stopwatch
Pushbuttons:
These will serve as controls for starting, stopping, and resetting the chronometer.
Breadboard:
A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering.
Jumper Wires:
For making temporary connections and wiring between components.
These are the basic components required to build a chronometer using the ESP32 board. The specific values and quantities might vary based on your design preferences and the exact functionality you wish to implement.
Mounting the ESP32 board with LCD I2C 1602 display and push buttons involves physically setting up these components on a breadboard or a prototyping board and wiring them together. Here's a step-by-step guide to mounting these components:
Mount the LCD I2C 1602 Display:
- Connect the GND pin of the LCD I2C 1602 display to the GND pin of the ESP32 board
- Connect the VCC pin of the LCD I2C 1602 display to the 3.3V pin of the ESP32 board
- Connect the SDA pin of the LCD I2C 1602 display to the GPIO 21 of the ESP32 board
- Connect the SCL pin of the LCD I2C 1602 display to the GPIO 22 of the ESP32 board
Connect Start Push Button:
- Connect the one of the legs of the push button to GPIO 19 of the ESP32 board
- Connect another leg of the push button to the GND pin of the ESP32 board
Connect Reset Push Button:
- Connect the one of the legs of the push button to GPIO 18 of the ESP32 board
- Connect another leg of the push button to the GND pin of the ESP32 board
Programming an ESP32 board with MicroPython to display a chronometer on an I2C 1602 LCD display involves a few steps.
First, ensure you have the necessary libraries for the LCD display : 'i2c_lcd' and 'lcd_api'.
Secondly, flash MicroPython on to your ESP32 by using the following firmware: esp32-20210902-v1.17.bin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
import machine from machine import Pin, SoftI2C import time from lcd_api import LcdApi from i2c_lcd import I2cLcd I2C_ADDR = 0x27 totalRows = 2 totalColumns = 16 # Define the I2C pins (adjust SDA and SCL to your ESP32 pins) i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000) # Initialize the LCD lcd = I2cLcd(i2c, I2C_ADDR, totalRows, totalColumns) # Define the push buttons pins start_button= machine.Pin(19, machine.Pin.IN, machine.Pin.PULL_UP) reset_button = machine.Pin(18, machine.Pin.IN, machine.Pin.PULL_UP) # Define variables to control the chronometer start_state=0; reset_state=0; running=False; timer=0 second=0 minute=0 lcd.putstr("Start Chrono") lcd.move_to(0,1) lcd.putstr("00:00") while True: # Start Button is pressed if (start_button.value() == False): lcd.clear() running = not running if (running): lcd.putstr("Chrono Running") else: lcd.clear() lcd.putstr("Chrono stopped") lcd.move_to(0,1) if (second<10): lcd.putstr(str(minute)+":0"+str(second)) else: lcd.putstr(str(minute)+":"+str(second)) print("status:"+str(running)) time.sleep(0.5) # Reset Button is pressed if (reset_button.value() == False): print("Reset") timer=0 second=0 minute=0 lcd.clear() lcd.putstr("Chrono stopped") lcd.move_to(0,1) lcd.putstr("00:00") time.sleep(0.5) running=False if (running): second += 1 time.sleep(0.01) if (second == 60): second = 0 minute += 1 if (minute == 60): minute = 0 lcd.move_to(0,1) #Show elapsed time if (second<10): lcd.putstr(str(minute)+":0"+str(second)) else: lcd.putstr(str(minute)+":"+str(second)) |
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info