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

Screenshot 2026-03-12 170314.png
Screenshot153837.png

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:

  1. ESP32 IoT development
  2. I2C communication
  3. GPIO expansion
  4. Telegram bot integration
  5. AI API communication
  6. Power regulation and battery monitoring


You can check the YouTube video:


https://youtu.be/xrEWq5Rv_4k


Supplies

sepl.png

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

Untitled-2_0003_Layer 1.jpg
Untitled-2_0001_Layer 3.jpg
Untitled-2_0002_Layer 2.jpg
Untitled-2_0000_Layer 4.jpg

Start by carefully opening the calculator.

  1. Remove the screws on the back
  2. Separate the back cover
  3. Carefully lift the internal board
  4. 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

Untitled-2_0001_Layer 6.jpg
Untitled-2_0000_Layer 7.jpg
full wiring diagram.png
mcp23017_1024x1024.png

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

bottom part.png
Untitled-3_0000_Layer 3.jpg
Untitled-3_0001_Layer 2.jpg
Untitled-3_0002_Layer 1.jpg

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

top part.png
full wiring diagram.png
Untitled-3.jpg

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

am.jpg
voltage regulator.png
power.png
power2.png

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)

voltage divider.png

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

botfr.png
Screenshot 2026-03-12 145819.png

To communicate with the calculator remotely we create a Telegram bot.

Steps:

  1. Open Telegram
  2. Search for BotFather
  3. Send the command " /newbot"
  4. Choose a name for your bot
  5. Telegram will generate a bot token
  6. Or press on open directly for ease guide.

This token allows the ESP32 to communicate with Telegram.

Getting Your Telegram User ID

Screenshot 2026-03-12 150014.png
Screenshot 2026-03-12 150056.png

To prevent strangers from controlling the device, we restrict access to a specific user.

Steps:

  1. Open Telegram
  2. Search for userinfobot
  3. Press Start

The bot will display your Telegram User ID.

Add this ID to your ESP32 code.

Getting a Free Google Gemini API Key

Screenshot 2026-03-12 150322.png
Screenshot 2026-03-12 150400.png
Screenshot 2026-03-12 150427.png
Screenshot 2026-03-12 150505.png

To enable AI responses, we use Google Gemini API.

Steps:

  1. Go to Google AI Studio "https://aistudio.google.com/app/api-keys?"
  2. Log in
  3. 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

flashing part.png
0lqsn9.jpg
Screenshot 2026-03-12 152643.png
Screenshot 2026-03-12 152854.png

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:

  1. WiFi
  2. HTTPClient
  3. ArduinoJson
  4. Adafruit_SSD1306
  5. Adafruit_GFX
  6. Wire
  7. Adafruit MCP23017, The mcp23017 library link (https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library).


Code

Screenshot 2026-03-12 152325.png
Screenshot 2026-03-12 152347.png

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:

GITHUB LINK

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:

https://ai.google.dev/gemini-api/docs/models

Final Assembly

Screenshot 2026-03-12 153147.png
Screenshot 2026-03-12 153025.png
Screenshot 2026-03-12 153049.png

After testing everything:

  1. Arrange components carefully inside the case
  2. Secure them using glue or tape
  3. Close the calculator
  4. Reinstall the screws

Now the calculator looks normal again.

Final Result

keys.png
Screenshot 2026-03-12 153550.png
Screenshot 2026-03-12 153608.png
Screenshot 2026-03-12 153626.png
Screenshot 2026-03-12 153647.png
Screenshot 2026-03-12 153712.png
Screenshot 2026-03-12 153749.png
Screenshot 2026-03-12 153816.png
Screenshot 2026-03-12 153837.png
Screenshot 2026-03-12 153939.png

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.

YOUTUBE