GPS speedometer and clock
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Shop by category
Shop all componentsBuild a clock that sets itself: the ESP32 asks an internet time server for the exact time and shows it on the OLED. After joining your Wi-Fi, configTime() asks a time server (NTP) for the time and keeps the ESP32's own clock in step. The offset of 19800 seconds turns world time (UTC) into Indian time (UTC + 5:30). getLocalTime() then fills a date and time structure, and strftime() turns it into text for the screen.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_109_internet_clock_oled.inoVerify & upload in Electrolark#include <WiFi.h>
#include <time.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
const long utcOffset = 19800; // India: UTC + 5 h 30 min = 19800 seconds
const char* days[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int lastMinute = -1;
void setup()
{
Serial.begin(9600);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Connecting to Wi-Fi");
display.display();
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
configTime(utcOffset, 0, "pool.ntp.org", "time.google.com");
Serial.println(" connected, asking the time server");
}
void loop()
{
struct tm now;
if (!getLocalTime(&now))
{
Serial.println("Waiting for the time server");
delay(1000);
return;
}
char hhmm[6], secs[3], date[16];
strftime(hhmm, sizeof(hhmm), "%H:%M", &now);
strftime(secs, sizeof(secs), "%S", &now);
strftime(date, sizeof(date), "%d %b %Y", &now);
display.clearDisplay();
display.setTextSize(3);
display.setCursor(4, 6);
display.print(hhmm);
display.setTextSize(1);
display.setCursor(104, 20);
display.print(secs);
display.drawRect(4, 34, 120, 5, SSD1306_WHITE);
display.fillRect(4, 34, now.tm_sec * 2, 5, SSD1306_WHITE); // fills across each minute
display.setCursor(4, 44);
display.print(date);
display.setCursor(4, 55);
display.print(days[now.tm_wday]);
display.display();
if (now.tm_min != lastMinute)
{
lastMinute = now.tm_min;
Serial.printf("%s %s\n", date, hhmm);
}
delay(200);
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
Type your Wi-Fi name and password into the sketch exactly, and use a 2.4 GHz network: the ESP32 cannot join 5 GHz-only Wi-Fi.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
Change utcOffset to your time zone in seconds: hours x 3600 (India is 19800).
After joining your Wi-Fi, configTime() asks a time server (NTP) for the time and keeps the ESP32's own clock in step. The offset of 19800 seconds turns world time (UTC) into Indian time (UTC + 5:30). getLocalTime() then fills a date and time structure, and strftime() turns it into text for the screen.
The OLED shows Connecting to Wi-Fi, then the time in large digits. Seconds tick in the corner and a bar fills across each minute. The date and the day of the week show underneath.
Yes. It is project 109 of 120 in the Geekobot Titan Kit, in level 16 (Wi-Fi, IoT and new sensors). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Titan Kit project is wired with jumper wires on the ESP32 expansion board and the breadboard.
Yes. The ESP32 keeps counting on its own clock and checks the time server again every hour while it can reach it.
5 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Dupont Jumper Wires (40 pcs), 0.96" OLED Display 128x64 and ESP32 38-Pin Expansion Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 30 minutes. The build on this page has 4 steps.
No. This page has the complete, tested code (titan_kit_109_internet_clock_oled.ino).
About ₹799 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How NTP sets a clock over the internet; Time zones as an offset in seconds; Formatting time and date with strftime(); Big and small text on an OLED.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Records where you went every five seconds, ready to open on a map.
Two boards, two radios: press the button at the gate and it rings indoors.
Check temperature, humidity and pressure from any phone on your Wi-Fi.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.