More info and updates in https://rogerbit.com/wprb/2024/06/beeper/
In this tutorial, you will learn how to configure and use an ESP32 device to receive Telegram messages and display them on an SH1106 display. We will also include the functionality of a button and a buzzer to interact with the system.
Requirements- An ESP32.
- An SH1106 display (128×64) with I2C interface.
- A buzzer.
- A button.
- Connection cables.
- Arduino IDE library installed.
Open the Arduino IDE and make sure you have the following libraries installed:
- WiFi.h for WiFi connection.
- WiFiClientSecure.h for the secure connection.
- UniversalTelegramBot.h to interact with the Telegram bot.
- U8g2lib.h to manage the SH1106 display.
You can install them from the Arduino IDE Library Manager by searching for the library names.
Step 2: Hardware ConnectionConnect the components according to the following diagram:
Display SH1106:
- VCC a 5V del ESP32.
- GND a GND del ESP32.
- SCL a GPIO 22 del ESP32.
- SDA a GPIO 21 del ESP32.
- Display SH1106:VCC a 5V del ESP32.GND a GND del ESP32.SCL a GPIO 22 del ESP32.SDA a GPIO 21 del ESP32.
Buzzer:
- Positive terminal to GPIO 12 of the ESP32.
- Negative terminal to GND of the ESP32.
- Buzzer:Positive terminal to GPIO 12 of the ESP32.Negative terminal to GND of the ESP32.
Button :
- A terminal to GPIO 23 of the ESP32.
- Another terminal to GND of the ESP32.
- Button :A terminal to GPIO 23 of the ESP32.Another terminal to GND of the ESP32.
- Create a bot on Telegram using BotFather and get the Bot Token.
- Replace TOKEN_BOT in the code with the obtained token.
- Replace ssid and password with your WiFi network name and password.
- Connect the ESP32 to your computer.
- Select the ESP32 Dev Module board from the Tools -> Board menu.
- Select the correct port from the Tools -> Port menu.
- Click Upload to upload the code to the ESP32.
- Once the code is loaded, open the Serial Monitor in the Arduino IDE to see the debugging messages.
- On the SH1106 display, the message “Waiting for message!” should appear.
- Send a message to your Telegram bot. The message should appear on the display and the buzzer should sound.
The ESP32 module has all WiFi variants :
- 802.11 b/g/n/e/i/n
- Wi-Fi Direct (P2P), P2P Discovery, P2P Group Owner mode and P2P Power Management
This new version includes connectivity through low-power Bluetooth
- Bluetooth v4.2 BR/EDR and BLE
- BLE Beacon
In addition, it can communicate using the SPI, I2C, UART, MAC Ethernet, Host SD protocols.
Microcontroller featuresThe CPU is made up of a Tensilica LX6 model SoC with the following features and memory
- Dual 32-bit core with 160MHz speed
- Memoria ROM de 448 kBytes
- 520kBytes SRAM memory
Dyspnea at 48 Pines
- 18 ADC de 12 bits
- 2 DAC de 8 bits
- 10 pin contact sensors
- 16 PWM
- 20 digital inputs/outputs
For correct operation of the ESP32, it is necessary to supply a voltage between 2.8V and 3.6V. The energy it consumes depends on the operating mode. It contains a mode, the Ultra Low Power Solution (ULP), in which basic tasks (ADC, RTC...) continue to be performed in Sleep mode.
female pins
Male female dupont cables
Display oled sh1106
It is a 128x64 dot monochrome OLED display module with I2C interface. It has several advantages compared to LCD screens, and we can highlight its high brightness, very good contrast, a wider viewing angle, and low consumption. of energy. It is compatible with Arduino Rasberry Pi and PIC microcontrollers among others. It works with logic levels from 3.3V to 5V and has a viewing angle greater than 160 degrees. Screen Size is 1.3 inches. It is powered with a voltage of 3.3V to 5V. It can be used in applications such as smart watches, MP3s, thermometers, instruments, and various projects, etc.
Characteristics
- Interface: I2C(3.3V / 5V logic level)
- Resolution: 128 x 64
- Angle of view: >160 degree
- Display color: Blue
- Display size: 1.3 inch
- Driver IC: SH1106
- Power supply: DC 3.3V~5V
- Operating temperature: -20~70’C
- Application: smart watch, MP3, thermometer, instruments, DIY projects, etc.
Buzzer Module
Module ky-004
PCB
📷 📷
Download gerber file –> Gerber_esp32
Circuit
Comments
Please log in or sign up to comment.