I made this Tachometer using IR sensor!

Поделиться
HTML-код
  • Опубликовано: 28 июн 2023
  • Circuit diagram and code:
    www.etechnophiles.com/tachome...
    Steps to make this tachometer:
    1. Put the Arduino Nano on the breadboard
    2. Connect the SDA and SCL pins of OLED to A4 and A5 respectively.
    3. Connect the OUT pin of the IR sensor to digital pin 2 of Arduino Nano and give +5v and GND connections.
    4. Upload the code. (The code is pinned in the first comment.)
    Explanation:
    The current time in milliseconds is stored in the 'currentMillis' variable.
    If the time difference between the current time and the previous time stored in previousMillis is equal to or greater than 1000 milliseconds (1 second):
    The interrupt is temporarily detached to avoid conflicting with the counter variable.
    The RPM value is calculated by dividing the counter value by 2 (assuming each revolution triggers two interrupts) and multiplying it by 60 to convert it to RPM.
    The counter is reset to 0.
    The interrupt is reattached to the IR sensor pin.
    The previousMillis is updated to the current time.
    The OLED display is cleared.
    The RPM value is displayed on the OLED display.
  • НаукаНаука

Комментарии • 32

  • @THEELECTRONICGUY
    @THEELECTRONICGUY  3 месяца назад +1

    Circuit diagram and code:
    www.etechnophiles.com/tachometer-using-arduino/

  • @nicklasmuller2687
    @nicklasmuller2687 3 месяца назад

    Worked great for me. Thank you for your work.

  • @adithyasakthivel4078
    @adithyasakthivel4078 10 месяцев назад +2

    Thank you it worked!

  • @NextGenPhysics
    @NextGenPhysics 9 месяцев назад +1

    Great work! Thank you for the detailed description. Could you kindly post a code for Serial monitor using H05 BT module. Thank you

  • @THEELECTRONICGUY
    @THEELECTRONICGUY  Год назад +6

    Code:
    #include
    #include
    #include
    #define OLED_RESET 4
    Adafruit_SSD1306 display(OLED_RESET);
    const int IR_PIN = 5; // IR sensor input pin
    volatile unsigned int counter = 0; // Counter variable for revolutions
    unsigned long previousMillis = 0; // Variable to store previous time
    unsigned int rpm = 0; // Variable to store RPM value
    void IRinterrupt() {
    counter++;
    }
    void setup() {
    pinMode(IR_PIN, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);
    display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
    display.display();
    delay(2000);
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.println("TEG");
    display.display();
    delay(2000);
    display.clearDisplay();
    display.setTextSize(2);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.println("Tachometer");
    display.display();
    delay(2000);
    }
    void loop() {
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= 1000) {
    detachInterrupt(digitalPinToInterrupt(IR_PIN));
    rpm = (counter / 2) * 60; // Calculate RPM
    counter = 0;
    attachInterrupt(digitalPinToInterrupt(IR_PIN), IRinterrupt, FALLING);
    previousMillis = currentMillis;
    display.clearDisplay();
    display.setCursor(0, 0);
    display.print("RPM: ");
    display.println(rpm);
    display.display();
    }
    }

  • @lukedavies8168
    @lukedavies8168 5 месяцев назад

    how can I change the code to make it a simple counter using this same hardware?

  • @singhaseyha4375
    @singhaseyha4375 6 месяцев назад

    Let make it count the paper sheets please … is it possible????

  • @alpeshjadhav5698
    @alpeshjadhav5698 2 месяца назад

    I cannot see the rpm in display. What should be the problem?? Can se it in serial monitor??

  • @Subhu0420
    @Subhu0420 17 дней назад

    Can we do this for speed ( km/hr)

  • @samnafri795
    @samnafri795 День назад

    hi bro, how about use 2 IR sensor to read 2 different rotation obejct?
    2 IR sensor
    2 object rotation
    1 arduino
    1 LCD display

  • @abdallae.mohamed9386
    @abdallae.mohamed9386 Месяц назад

    How many volts did the source enter?

  • @ahsanamala7246
    @ahsanamala7246 10 месяцев назад

    Thanks it really works,
    but how to convert to KM/H (Kilometers Per Hour)?

    • @mattivirta
      @mattivirta 8 месяцев назад

      wheel circumtanse distance/time.

  • @pzmt
    @pzmt 9 месяцев назад

    How meny maximum rpm?

  • @devendradandekar9740
    @devendradandekar9740 11 месяцев назад +1

    Dear doing great job, with this please try to keep code and diagram with video it would help more to dive deeply to beginners. Keep it up.. Good Luck!🤓🙂

    • @adityadivine2138
      @adityadivine2138 6 месяцев назад +1

      It is working but the rpm values are wayyy off, like it should be 1-2k and it's showing 50k. How to fix

    • @user-jz7jr5rr1c
      @user-jz7jr5rr1c 5 месяцев назад

      make proper gap between fan@@adityadivine2138

  • @fathimathihsana6917
    @fathimathihsana6917 2 месяца назад

    Jumper wire male to female?

  • @debarshi89
    @debarshi89 6 месяцев назад +1

    How we can send this rpm data to computer program?

    • @user-jz7jr5rr1c
      @user-jz7jr5rr1c 5 месяцев назад

      If you used ESP32 then using IOT you can send it or using Serial Data

  • @luizfarah6381
    @luizfarah6381 8 месяцев назад +1

    Hi. Works with WEMOS D1 ?

  • @Sophie333C
    @Sophie333C 3 месяца назад

    Hi, is the IR sensor connect to D2, or D5? As the code says D5, but the video says D2. Cheers

    • @THEELECTRONICGUY
      @THEELECTRONICGUY  3 месяца назад

      Connect it to D5. You can check the blog post for more info :)

    • @Sophie333C
      @Sophie333C 3 месяца назад

      @@THEELECTRONICGUY I’m using a nano, and 5 doesn’t work, but 2 does!

  • @martinkuliza
    @martinkuliza 7 месяцев назад

    Im getting a Pantera Cemetery Gates feel from this video
    am i the only one

  • @alexandruflondor4963
    @alexandruflondor4963 7 месяцев назад

    Hello! Error: Adafruit_GFX.h : No such file or directory. what can I do?

    • @anonymousanonymous7959
      @anonymousanonymous7959 7 месяцев назад

      You have to add this library from your Arduino ide.
      Goto tool then there is "add library" option

  • @sahajyadav7437
    @sahajyadav7437 5 месяцев назад

    It says programmer not responding what to do??

    • @phils6926
      @phils6926 3 месяца назад

      Is it genuine Arduino Nano or a clone?
      Try another bootloader if the comms chip is CH??? and not the genuine FTDI
      Common problem with Nano.

  • @dienau6313
    @dienau6313 Месяц назад

    IT DIDNT WORK, I CHANGED EVERY COMPONENTS AND IT STILL DIDNT WORK

  • @mattivirta
    @mattivirta 8 месяцев назад

    i have similar project whit promixity sensor 12 volt, to optocoupler 12 volt to 5 volt and arduino nano, but not measure right to speed, i measure laser RPM meter my spindle speed and show 5400 rpm, but arduino show 4200-4300 rpm. what need change code can make accurate rpm, promixity sensor trigged spindle chuck 2 x /rev. pulse go to arduino pin 2, code formula have
    print_to_OLED();
    if (millis() - millisBefore > 1000) {
    rpm = ((objects / 3.0) * 60); //(object / 3.0)*60;) // i testing many different (object / 1 or 2 or 4 or other ) x60) but not working right.
    objects = 2; //liipaisujen määrä trigger 2x/rev
    millisBefore = millis();
    }
    delay(100);
    void count() {
    objects++;
    how repair code, working well but not measure right speed. please help, i not understand code lot. I change IR sensor to promixity sensor because IR not sense accurate speed newer, if read speed show display 1200-5600 and not stabile measure whit IR sensor, lot better have promixity sensor my cnc spindle chuck. need measure 0-30 000 rpm. arduino working well but not show right speed, HELP PLEASE.