-
Notifications
You must be signed in to change notification settings - Fork 1
Creating a Tachometer with a WeMos Board, OLED Shield, and IR Sensor
In this project, I'll walk you through the process of creating a tachometer using a WeMos board (d1 mini pro), an OLED shield (64x48), and an IR sensor (CNY70) to measure the revolutions per seconds (RPS) of a BLDC motor sourced from an old hard disk drive (separate article). This project showcases how you can repurpose electronics and integrate various components to build a functional device that displays real-time RPS data.
The Sketch is compiled with Arduino IDE 2.3.2. It is commented and is easy to understand.
The OLED display libraries are pretty old and you must use them. The new ones won't work with this sketch.
Stack the OLED shield onto the WeMos D1 Mini, ensuring the pins are properly aligned and connected.
Setup and Initialization: The WeMos board initializes the OLED display and sets up an interrupt service routine to count the revolutions detected by the IR sensor.
Measuring RPS: The loop function uses the millis() function to calculate the time interval and update the RPS every 10 seconds. The RPS is then displayed on the OLED screen.
Interrupt Service Routine: The countRevolution function increments the revolution count each time the IR sensor detects a falling edge (indicating a reflective mark has passed).
I connected a square wave generator to input D5 and measured the RPS on the OLED display. I got a consistent 0.5% error between 50 and 10'000 Hz and 1.5% at 100 kHz. Good enough for future uses.
Happy Counting!