Turning a Casio Calculator Into an AI Device Using ESP32
by karmou_44 in Circuits > Arduino
11992 Views, 68 Favorites, 0 Comments
Turning a Casio Calculator Into an AI Device Using ESP32
What if a simple scientific calculator could connect to the internet, send messages, receive messages, and even communicate with AI?
In this project, we modify a Casio scientific calculator and hide a small Wi-Fi microcontroller inside it. Using an ESP32, an MCP23017 I/O expander, and an SSD1306 OLED display, the calculator becomes a tiny internet-connected device capable of communicating through Telegram and interacting with AI APIs.
The calculator can:
• Connect to the WI-FI
• Send messages to Telegram
• Receive messages from Telegram
• Display responses on a small OLED screen
• Query an AI model
• Monitor its battery voltage
From the outside it still looks like a normal calculator — but internally it becomes a miniature IoT device.
This project demonstrates several useful concepts:
- ESP32 IoT development
- I2C communication
- GPIO expansion
- Telegram bot integration
- AI API communication
- Power regulation and battery monitoring
You can check the YouTube video:
Supplies
Electronics
• ESP32 development board
• MCP23017 I/O expander
• SSD1306 OLED display (I2C)
• AMS1117 3.3V voltage regulator
• Li-Po battery
• Switch
• 2 resistors for voltage divider
• wires
Tools
• soldering iron
• screwdriver
• wire cutters
• multimeter
• hot glue
Opening the Calculator
Start by carefully opening the calculator.
- Remove the screws on the back
- Separate the back cover
- Carefully lift the internal board
- Remove excess edges if necessary
Be careful not to damage the display ribbon or button contacts.
Once opened, inspect the available space where the new components will fit.
Planning the Internal Layout
Before soldering anything, plan how the components will fit inside the calculator.
Inside we need space for:
• ESP32
• MCP23017
• OLED display
• battery
• regulator
Because the available space is small, it is important to test fit components first.
Place them temporarily to determine the best arrangement.
Connecting the MCP23017
The calculator has many buttons, but the ESP32 does not have enough GPIO pins to read them all.
To solve this, we use the MCP23017 I/O expander, which adds 16 extra input/output pins.
The MCP23017 communicates with the ESP32 using I2C.
Typical connections:
ESP32 → MCP23017
SDA → SDA
SCL → SCL
3.3V → VCC
GND → GND
Now the ESP32 can read additional button inputs through the expander.
Connecting the OLED Display
To show messages from Telegram and AI responses, we add a small SSD1306 OLED display.
This display also uses the I2C bus, so it can share the same SDA and SCL lines as the MCP23017.
Connections:
VCC → 3.3V
GND → GND
SDA → ESP32 SDA
SCL → ESP32 SCL
Once connected, the ESP32 can display text and system information on the screen.
Power System
The calculator is powered by a Li-Po battery, which allows the device to run without external power.
To manage the battery safely and provide the correct voltage for the ESP32, the power system uses three stages: charging, boosting, and regulation.
Battery Charging:
A TP4056 charging module is used to safely charge the Li-Po battery from a 5V USB source.
Power flow:
USB → TP4056 → LiPo Battery
Voltage Conversion
Because the battery voltage varies between 3.0V and 4.2V, a 5V boost converter is used to create a stable input voltage.
This voltage is then regulated to 3.3V using an AMS1117 voltage regulator, which powers the ESP32 and other components.
Final power flow:
Battery → Boost Converter (5V) → AMS1117 (3.3V) → ESP32
A small power switch can be added between the battery and the boost converter to turn the device on and off.
Better Option
For better efficiency, a modern 3.3V regulator such as ME6211 or AP2112K can replace the AMS1117, reducing heat and improving battery life.
Adding Battery Monitoring (Voltage Divider)
To monitor the battery voltage, we add a voltage divider connected to an ESP32 analog pin.
The ESP32 can only measure voltages up to 3.3V, so the divider scales the battery voltage to a safe level.
The voltage divider follows this equation:
V_{out}=V_{in}\frac{R_2}{R_1+R_2}
The ESP32 reads the reduced voltage and calculates the battery level.
Creating the Telegram Bot
To communicate with the calculator remotely we create a Telegram bot.
Steps:
- Open Telegram
- Search for BotFather
- Send the command " /newbot"
- Choose a name for your bot
- Telegram will generate a bot token
- Or press on open directly for ease guide.
This token allows the ESP32 to communicate with Telegram.
Getting Your Telegram User ID
To prevent strangers from controlling the device, we restrict access to a specific user.
Steps:
- Open Telegram
- Search for userinfobot
- Press Start
The bot will display your Telegram User ID.
Add this ID to your ESP32 code.
Getting a Free Google Gemini API Key
To enable AI responses, we use Google Gemini API.
Steps:
- Go to Google AI Studio "https://aistudio.google.com/app/api-keys?"
- Log in
- Generate a free API key
The ESP32 can now send questions to the Gemini model and display responses on the OLED screen.
Programming the ESP32
To upload the firmware, we use the Arduino IDE and a USB-to-UART bridge, since the ESP32 inside the calculator is not directly accessible through USB.
The USB-to-UART adapter allows the computer to communicate with the ESP32 over serial.
USB-to-UART Wiring
Connect the adapter to the ESP32 as follows:
USB-UART → ESP32
TX → RX
RX → TX
GND → GND
3.3V → 3.3V
``` id="uartw1"
If required for your board, connect GPIO0 to the GND before powering the esp32 to enter flashing mode.
Uploading the Firmware
1. Connect the USB-to-UART adapter to your computer
2. Select the ESP32 board in Arduino IDE
3. Choose the correct serial port
4. Upload the firmware
Firmware Capabilities
The firmware performs several tasks:
• Connects to WiFi
• Reads button inputs
• Communicates with Telegram
• Sends and receives messages
• Requests AI responses
• Displays information on the OLED
• Monitors battery voltage
Required Libraries
Install the following libraries in Arduino IDE:
- WiFi
- HTTPClient
- ArduinoJson
- Adafruit_SSD1306
- Adafruit_GFX
- Wire
- Adafruit MCP23017, The mcp23017 library link (https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library).
Code
To make the project easier for others to replicate, the code is hosted on GitHub.
The repository contains:
• ESP32 firmware
• library requirements
• Wiring diagrams
You can download the code from:
Note:
In the code you must change the API key for the Gemini, the Telegram bot token and the user ID.
You can change the Gemini model in the code by going to the line 837:
String url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-lite:generateContent?key=" + String(Gemini_Token);
Here is the google Gemini models docs:
Final Assembly
After testing everything:
- Arrange components carefully inside the case
- Secure them using glue or tape
- Close the calculator
- Reinstall the screws
Now the calculator looks normal again.
Final Result
The calculator is now a tiny IoT device.
It can:
• connect to WiFi
• communicate through Telegram
• send and receive messages
• interact with AI
• display responses on the OLED screen
From the outside it still looks like a regular calculator — but internally it is a fully connected embedded system.