Hello friends, I hope you all are doing great. Today, I am going to share the ESP32 E-Scooter Speedometer with A3144 and GC9A01 - Proteus Simulation, the ninety-seventh project of our IoT Projects series. If you have searched for an ESP32 speedometer, how a Hall sensor measures speed, a bike computer with a round display, or how to drive a GC9A01 without a library, here is a complete one in a Proteus simulation. Every bike computer and most scooter dashboards work the same way: a small magnet on the wheel, a sensor on the fork that notices it once a turn, and a microcontroller with a stopwatch.

This project builds that speedometer for an electric scooter with a 10-inch wheel. An A3144 Hall switch sees the magnet pass; the ESP32 timestamps every pass with an interrupt and turns the time of one wheel turn into km/h. A 1.28-inch GC9A01 round display shows a dial of 36 segments, the speed in big digits, the trip and the highest speed, and turns red with SLOW above 25 km/h, the legal limit for e-scooters in much of Europe. The trip, the ride time and the average are on a dashboard, with a reset and a km/h / mph switch. In this tutorial, we will go through the circuit, how a Hall switch works and why it needs 5 V, how speed comes from one turn of the wheel, how the round display is driven with plain SPI, and the code. Then we ride a full speed run in the simulation, from walking pace past the limit and back to a stop. At the end, you can download the project with the sketch and every library file.

NOTICE: Our team has put a lot of effort into this project: the circuit, the code and every part in the simulation are our own work, and you get them all free. Your feedback is the fuel that keeps us going, so please tell us what you think in the comments below. And if our free projects help you, you can buy us a coffee. So, let's get started with the ESP32 e-scooter speedometer with A3144 and GC9A01 in Proteus simulation:

Figure: The e-scooter speedometer in a Proteus simulation.
Figure: The project working in the Proteus simulation (an animation of the main steps).

What Does This E-Scooter Speedometer Do?

  • Measures the speed: one wheel turn of 0.80 m, timed to the microsecond by an interrupt.
  • Falls smoothly: as the wheel slows, the speed drops even between passes; no pass for 2 s means stopped.
  • Keeps the trip: the distance, the ride time (moving only), the average and the highest speed.
  • Watches the limit: red and SLOW above 25 km/h, with 1 km/h of hysteresis.
  • A round dial: 36 segments in green, yellow and red, big digits, all drawn with plain SPI.
  • A dashboard: the speed, the trip and the average, RESET TRIP and km/h / mph.

It is a great project for learning interrupts, timing and a raw SPI display in one go. In the simulation, the A3144's pop-up shows the wheel, the magnetic field and every pulse, and the GC9A01's pop-up shows exactly what the round glass displays.

Components Used in the Proteus Simulation

All the parts come from our Proteus libraries, each with its own tutorial. The project zip at the end includes every LIB and DLL file.

The parts of the e-scooter speedometer and their library posts
PartProteus deviceLibrary postConnection
ESP32 DevKit V1ESP32 DEVKIT V1ESP32 DevKit V1 Library for ProteusU1, ESP32_Scooter_Speedo.hex, Wi-Fi 192.168.1.101
A3144 Hall switch moduleHALLA3144TEPA3144 Hall Sensor Library for ProteusU2: S on D27, VCC on 5 V (VIN)
GC9A01 1.28" round TFTGC9A01TEPGC9A01 Round TFT Library for ProteusU3: SCK D18, MOSI D23, CS D5, DC D22, RST D21
Laptop WiFi MonitorLAPTOP WIFI MONITORLaptop WiFi MonitorPC1
Mobile WiFi MonitorMOBILE WIFI MONITORMobile WiFi MonitorMOB1

Proteus Simulation of the Speedometer: the Circuit

Figure: The complete circuit of the speedometer on an A3 Proteus sheet.
The connections of the e-scooter speedometer
SignalESP32Goes to
HALLD27the A3144 module's S (falling once a wheel turn)
SCK / MOSID18 / D23the GC9A01's SCL / SDA (SPI)
CS / DC / RSTD5 / D22 / D21the GC9A01's chip select, data / command and reset
5VVINthe A3144 module (it needs 4.5 V or more)
+3.3V-the GC9A01

The circuit is small: a sensor with one output wire and a display with five. The A3144 module is powered from the DevKit's 5 V pin because the A3144 needs at least 4.5 V; our first run had it on 3.3 V, and its pop-up said NO SUPPLY while the wheel turned past it unseen. The display runs on 3.3 V.

How the E-Scooter Speedometer Works

A Hall Switch and a Magnet

A Hall sensor measures a magnetic field: a current through a thin plate is pushed sideways by the field and a small voltage appears across it. The A3144 adds a comparator with hysteresis and an open-collector output: when the field of a south pole passes 25 mT, its output goes LOW; it is released below 18 mT. A north pole does nothing. On a wheel, a magnet sweeps past once a turn, so S gives one clean falling edge per turn. The module carries a 10 k pull-up, which takes S back up to its supply between passes.

Speed from One Turn

A 10-inch scooter tyre rolls about 0.80 m in one turn. If a turn takes 0.5 s, the scooter does 1.6 m/s, which is 5.8 km/h: speed = 0.80 m / the turn time x 3.6. The ESP32 timestamps every falling edge with micros() in an interrupt, so the turn time is known to a few microseconds. Two details make it behave like a real speedometer. While no new pass has come, the sketch uses the time since the last one if that is longer, so the reading falls smoothly as the wheel slows instead of freezing at the last value. And when no pass comes for 2 s, the scooter is stopped; the first pass after a stop gives no speed yet, because the time since the previous one says nothing about the speed now.

Driving a Round Display with Plain SPI

The GC9A01 has a 240 x 240 frame memory, of which the round glass shows the circle. The ESP32 sends it commands with DC low and data with DC high: the maker's initialisation, then for every drawing a window (CASET for the columns, RASET for the rows) and RAMWR followed by the pixels, two bytes each in 16-bit colour. A full screen is 115,200 bytes, so the sketch never redraws it: the dial is 36 small squares on a circle, the speed two 7-segment digits made of rectangles, the text a 5 x 7 font, and each piece is drawn only when it changes.

The Speed Limit

E-scooters are limited to 25 km/h in many countries. Above it the dial's last segments turn red, the digits turn red and the unit becomes SLOW; the warning clears only below 24 km/h, so it does not flicker at the limit. The sketch counts how often the limit was passed.

The Arduino Code Explained

The sketch is ESP32_Scooter_Speedo.ino, built for our ESP32 DevKit V1 with the WiFi, WebServer and SPI libraries. The wheel and the interrupt on S:

const float WHEEL_M = 0.80;                                       // a 10-inch scooter tyre: 0.80 m a turn
  attachInterrupt(digitalPinToInterrupt(HALL), onPass, FALLING);

In the interrupt, the turn time; the first pass after a stop gives none. Our second run timed a turn from a magnet held next to the sensor five seconds earlier and showed 0.5 km/h:

  period = lastPass && dt < STOP_US ? dt : 0;                     // (the first pass after a stop gives no speed yet: probe 2 timed a

In the loop, the two values copied together with interrupts off, then the speed from the longer of the last turn and the time since:

  noInterrupts(); const unsigned long lp = lastPass, per = period; interrupts();   // (copied together: an edge between two reads)
  const unsigned long t = max(per, since);                          // (no new pass yet: the speed falls with the time since the last one)
  kmh = now ? WHEEL_M * 3.6e6f / t : 0;

The limit with its hysteresis:

  const bool o = over ? kmh > LIMIT_KMH - 1 : kmh > LIMIT_KMH;

The display: a window, then RAMWR and the pixels; a dial segment's place on the circle; one segment of a big digit:

void window(int x0, int y0, int x1, int y1) {                     // CASET, RASET, then RAMWR: the pixels follow
  cmd(0x2C);
    const float a = (225.0f - i * 270.0f / 35) * PI / 180;
  fillRect(x + 8, y, 20, 8, s & 0x01 ? c : BLACK);                // a

Only a change is drawn, for example the unit or SLOW:

  if (strcmp(m, shownMsg)) { strcpy(shownMsg, m); text(96, 146, m, 2, over ? RED : CYAN, BLACK); }

The dashboard's links are Refresh, RESET TRIP and MPH / KPH; /data gives the speed, the trip, the average and the wheel's RPM as JSON.

How to Run the Proteus Simulation

  1. Download the project zip below and install the library files (the steps are under the download button).
  2. Open ESP32-Scooter-Speedo.pdsprj from the Proteus Simulation folder. Keep the HEX and the DLL files next to it.
  3. Press Play. The A3144's DEMO starts the wheel at 7 s and runs it up to 600 RPM, then lets it stop.
  4. Click U2 for the sensor's pop-up and U3 for the display's.
  5. Open the Laptop WiFi Monitor (press Go) for the trip, RESET TRIP and MPH.

Simulation Results: a Ride in Proteus

We pressed Play and let the A3144's DEMO turn the wheel: standing still, then 120 RPM from 7 s, 360 RPM from 10 s, 600 RPM from 13 s, and slowing to a stop from 16 s. The A3144's pop-up shows the wheel, the field at the sensor and every pulse on S; the GC9A01's pop-up shows what the round glass displays. The times are the sketch's clock; the whole run took 33.0 simulated seconds.

Ready and Standing Still

The ESP32 joined TEP-WiFi and reported READY at 2.88 s: a 0.80 m wheel, the limit 25 km/h. By then the display had been initialised and drawn once: the empty dial, a big 0, KPH, the trip and MAX 0.0. The pop-up counts what that took: 277 commands and 73,388 pixels at 8 MHz. A full screen of 240 x 240 would take 317 ms on this bus, which is why the sketch draws only the parts that change.

Figure: Ready: standing still.
Figure: The round display after its first drawing.

Before the ride we held a south pole in front of the sensor with the pop-up's chip: 45 mT, well above the 25 mT operate point, and S went LOW, 0.00 V. The sketch counted one pass and, as designed, no speed: a single pass after standing still says nothing about how fast the wheel turns.

Figure: A south pole in front of the A3144: S LOW.
Figure: The dashboard: stopped, one pass, no speed.

Walking Pace: 120 RPM

At 8.09 s the sketch reported MOVING. At 10 s it read 5.7 km/h with the wheel at 120 RPM. The A3144's pop-up measured 0.502 s between pulses: 0.80 m / 0.502 s x 3.6 = 5.7 km/h. The display shows 6 KPH and the first green segments of the dial.

Figure: Walking pace.
Figure: The display: 6 km/h.
Figure: The A3144: one pulse a turn, 0.502 s apart (the wheel already speeding up to 360 RPM).

Cruising: 360 RPM

At 12 s: 17.1 km/h, the wheel at 357 RPM, the trip 0.014 km. The display shows 17 with the dial green almost to the top and MAX 17.3. The pop-up's pulses were now 0.167 s apart, 360 RPM.

Figure: Cruising at 17 km/h.
Figure: The display: 17 km/h, all green.
Figure: The A3144: 0.167 s between pulses (the wheel on its way to 600 RPM).

Over the Limit: 600 RPM

At 13.60 s the sketch reported OVER THE LIMIT: 25.9 km/h. At 16 s it read 28.7 km/h with the wheel at 599 RPM. The display turned red: 29 in red digits, SLOW instead of KPH, the dial yellow above 20 km/h and red above 25, MAX 28.8. The A3144's pop-up confirms it: 0.100 s between pulses at 600 RPM, which is exactly 28.8 km/h.

Figure: Over the limit.
Figure: The display: 29 km/h, SLOW.
Figure: The A3144: 0.100 s a turn.

Slowing Down and Stopped

The DEMO let the wheel coast. At 16.48 s the sketch reported back under the limit; at 18 s it read 8.9 km/h and at 20 s 1.6 km/h with the wheel at 34 RPM, the speed falling smoothly between the ever longer gaps. At 20.32 s, 2 s after the last pass, it reported STOPPED - trip 0.05 km in 12 s. The display went back to 0 and kept MAX 28.8 and the trip, KM 0.05. The dashboard summed up the ride: an average of 15.1 km/h, the highest 28.8 km/h, 64 passes and over the limit once.

Figure: Stopped.
Figure: The display after the ride.
Figure: The dashboard: the ride.

Miles per Hour and a New Trip

The MPH link at 24.60 s switched the units on both screens: the dashboard showed a trip of 0.03 mi, an average of 9.4 mph and the highest 17.9 mph, and the round display MPH, MAX 17.9 and MI 0.03. Then RESET TRIP at 28.35 s cleared the trip, the ride time, the average and the highest speed; the total passes and the count over the limit were kept. The phone shows the same page.

Figure: The dashboard in mph.
Figure: The display in mph.
Figure: MPH on the round display.
Figure: A new trip.
Figure: The same dashboard on the phone.

The serial monitor logged the whole ride, every 2 s while moving:

Figure: The serial log of the ride.

Download the Project Files

Click the button below to download ESP32-E-Scooter-Speedometer-A3144-GC9A01-Proteus-Simulation-v1.0.zip (about 3.4 MB, without the source code of the models):

ESP32 E-Scooter Speedometer with A3144 and GC9A01 - Proteus Simulation V1.0
  • Proteus Simulation: ESP32-Scooter-Speedo.pdsprj, ESP32_Scooter_Speedo.hex and copies of the models.
  • Arduino Code: ESP32_Scooter_Speedo.ino, the sketch.
  • Proteus Library Files: the LIB files of every part.
  • Proteus Model Files: the DLL models.
  • README.txt: the installation steps, the properties, the test results and the links to every library post.

No Proteus yet? Read How to Download and Install Proteus 7 and 8. New to libraries? Follow How to Install a New Library in Proteus.

How to Install the Project Files

  1. Close Proteus and extract the whole zip file, for example to your Desktop.
  2. Copy the files from Proteus Library Files into the LIBRARY folder of Proteus.
  3. Copy the files from Proteus Model Files into the MODELS folder.
  4. Start Proteus and open the project from the Proteus Simulation folder.

Changing the Code

Open the sketch in the Arduino IDE with the TEP Boards for Proteus installed, select ESP32 Dev Module (TEP Proteus), and use Sketch > Export Compiled Binary. Put the new HEX next to the project. The wheel's circumference, the limit and the dial's scale are near the top.

Ideas to Extend the Project

  • Save the odometer in Preferences so the total distance survives a power cut.
  • Add a second magnet: two pulses a turn double the resolution at low speed.
  • Read the battery voltage and show the range left on the round display.
  • Log every ride with its average and highest speed, and show them on the dashboard.
  • Cut the motor's throttle above the limit instead of only warning.
  • Draw a needle instead of segments, with the anti-aliasing of the library demo's watch hands.

From Simulation to Real Hardware

  • The pull-up: the module pulls S up to its own 5 V; an ESP32 pin takes 3.3 V at most - add a 10 k / 20 k divider, or remove the module's resistor and use INPUT_PULLUP.
  • The magnet: a neodymium magnet on a spoke, its south pole facing the marked side of the A3144, 5 - 10 mm away.
  • The circumference: measure one turn of the loaded tyre on the ground; the printed size is only close.
  • Noise: a scooter's motor controller is noisy; a short, twisted pair to the sensor and a 100 nF capacitor across its supply help.
  • The display: the GC9A01 runs on 3.3 V logic; a sunshade helps it in daylight.

Troubleshooting

  • No speed at all: the A3144 needs 4.5 V or more; on 3.3 V its pop-up says NO SUPPLY.
  • The speed jumps: bounces on S; the sketch ignores passes closer than 15 ms.
  • The display stays black: SCK, MOSI, CS, DC and RST as listed, VCC on 3.3 V.
  • A wrong speed: set WHEEL_M to your tyre's real circumference.
  • No dashboard: the ESP32 joins TEP-WiFi about three seconds after the start; press Go again.

Limitations of the Simulation

  • The A3144 and the GC9A01 are our libraries' models, built from their datasheets, not every detail of real parts.
  • The wheel is the A3144 model's DEMO scene, not a scooter: its speeds come from the scene, not from a motor.
  • There is no road: the trip is the wheel turns times 0.80 m, as on a real speedometer, with no slip.
  • ESP32 is a product of Espressif Systems; this project is not made or endorsed by Espressif or by Labcenter.

So, that was all about the ESP32 E-Scooter Speedometer with A3144 and GC9A01 - Proteus Simulation. I hope it helps you understand how a Hall switch and a magnet measure a wheel, how one turn becomes a speed, and how a round display can be driven with nothing but SPI commands, all tested in a simulation before you mount anything on a scooter. More projects with the ESP32 and the Raspberry Pi 5 are coming. If you have any questions, ask in the comments and I will help you out. Till the next tutorial, take care and have fun!