logo elektroda
logo elektroda
X
logo elektroda

RPM counter from Arduino to ESP with Hall sensor A3144 display ; LM393

sznickers 1497 20
Best answers

Can I run an Arduino Hall-sensor RPM counter on an ESP and, if so, what is the easiest way to do it with ESPEasy, Domoticz, or an ESP32/ESP8266?

Yes, but you cannot paste an Arduino sketch into ESPEasy Rules; either flash a pure .ino sketch directly to the ESP, or write a proper ESPEasy Rules script instead [#21416663] If you choose the direct route, compile and upload the code from Arduino IDE after preparing it for ESP32/ESP8266 support [#21416795] The Hall module can work for RPM counting on ESP: connect the signal wire to D0, and the board will count revolutions and show RPM, with the module LED blinking when the magnet passes [#21418217] For the display side, the ESP32 I2C defaults are SDA GPIO21 and SCL GPIO22, but those pins must also be set in the code, and the display/hardware should be checked separately if it does not show data [#21416629][#21416080] The forum also notes that I2C needs proper pull-ups and that the display itself should be verified with a simple demo before testing the full RPM program [#21416730]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 21404038
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    Hello,
    A colleague Waldek has made a cool RPM counter on an Arduino using an A3144 Hall sensor with software.
    The video is on YT
    https://www.youtube.com/watch?v=nO3DbYL_3vQ&a...vNgj2g_rZfk9Tht4AaABAg.994sViAIPI9ADUeQknJiDE
    My question is, as I am currently relying on ESP, is it possible to upload this soft to ESP in some non-difficult way? Either in "rules" or as a script in domoticz. There are LUA, dz vents, blockly, python scripts in domoticz. Is it possible to convert this in some easy way ? If not I will do it on Arduino and somehow try to connect to Domoticz.
    batch to arduino:

    Code: C / C++
    Log in, to see the code
    .

    Added after 4 [minutes]: .

    I also bought a : Hall sensor module hall sensor A3144 Arduino, but without scripting - which I am poor at - is it possible to get a measurement of the number of revolutions ? In combination with ESP
    Hall sensor module A3144 for Arduino
  • ADVERTISEMENT
  • Helpful post
    #2 21404166
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    Code for ESP
    Code: C / C++
    Log in, to see the code
    .

    And to house

    Code: C / C++
    Log in, to see the code
  • ADVERTISEMENT
  • #3 21404337
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    thank you Iftri, as I upload, check, let me know, I will order the components on ali.
  • #4 21405428
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    I've uploaded the soft on ESP8266 but I see it's cramped :) -waiting for ESP32
    ESP Easy Mega user interface with code exceeding text limit. .
  • #5 21406001
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    Configuration screen view with sensor settings, including pulse counter and analog input. .
    I'm trying to think the other way, I have this ready-made module with Hall sensor: A3144E, Comparator: LM393, Signal: digital, analogue. I don't know how to set, because count, total and time nothing changes.
    Screenshot of ESP Easy Mega device configuration with pulse counter settings. .

    Added after 6 [hours] 42 [minutes]: .



    .
    Hall sensor module A3144E and microcontroller board connected with wires. .
    Electronic circuit with Hall sensor A3144E and comparator LM393. .
    I managed to get it to work. I don't know what the "Time" is for, whether to use it and how. Surely the correct mounting of the magnet in relation to the sensor is important. It works.
  • #6 21416018
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    I got the display, connected the Hall sensor, uploaded the revised software to the ESP. I uploaded it to the ESP32 and it doesn't work - i.e. it doesn't display RPM etc on the display.



  • #7 21416080
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    Can you see anything on the display, does it light up maybe you need to tune the contrast, What pins is it connected to on the ESP 32 (SDA - default GPIO21, SCL - default GPIO22)? This display is not on 5v? The Esp32 gives 3v3,.
  • ADVERTISEMENT
  • #8 21416089
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    I checked the display by displaying the measurements of other sensors [....#...]. I adjusted the contrast. I connected the display (power) to the 5v pin naturally it's VIN (because I switched to ESP32W32room board) or VBUS for esp32S2 mini . SDA SCL as in the picture
    ESP Easy Mega configuration screen with device and GPIO settings. .
  • #9 21416496
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    ESP32-WROOM-32 pinout diagram with color-coded pin functions. .
  • #10 21416616
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    Are you saying to connect SCL, SDA under GPIO21,22 ? There is an option to connect under several different pins these channels and so I did. Do you think that if I change to these pins it will be ok ?
  • Helpful post
    #11 21416629
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    These pins are the default, for those to work you need to set them in the code.
  • Helpful post
    #12 21416663
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    sznickers wrote:
    doesn't work-i.e. doesn't display RPM etc.


    @sznickers again you are trying to conflate two different "currency systems".
    You are trying to run an arduino program in RULES espeasy. RULES is an internal interpreter created for espeasy and is like its own programming "language".
    Mixing ingredients like this is only good for cooking bigos :) .

    ... you either upload a pure .ino ...or espeasy and a proper rules script.

    https://www.letscontrolit.com/forum/viewtopic.php?t=3476&start=10

    As usual - documentation and google "espeasy rpm meter"
  • #13 21416711
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    oldob thanks, I'm happy to listen to your comments, you have the knowledge and experience and I'm a simple mechanic :) (not the automotive one). I'd be happy to rework that lesson from letscontrolit.
    The iftri I changed the SCL and SDA pins to 21 and 22, but it didn't go either. The display lights up, but only in green.
    Screenshot of the ESP Easy Mega interface showing a device list with names, ports, and GPIO values. .
  • #14 21416730
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    sznickers wrote:
    Display lights up, but only in green.


    The I2C bus always requires 2 external pull-up resistors for the SDA and SCL lines.
    Perhaps, it is sufficient for the GPIO to include an internal pullup? (most "tutorials" only use internal").
    First run the display itself by uploading some arduino demo, when you are sure that the hardware works well - upload espeasy.
  • #15 21416735
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    Turn the contrast potentiometer on the display
  • #16 21416743
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    Screenshot of ESP Easy Mega settings on the Devices tab with configuration for a pulse counter. .
    I changed to pull up, also nothing. The display works because I tested it on a different script, when I turn ESP on or off it says ESP Easy.

    Added after 3 [minutes]: .


    LCD display showing values: 3158 W and 9.051/min, connected to a Siemens device. .

    when switching on the LUA script from domoticz from other sensors it works nicely
  • ADVERTISEMENT
  • #17 21416752
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    sznickers wrote:
    when I switch ESP on or off the text ESP Easy appears.

    So much good :)
    tip... In espeasy there is in tools > interfaces > I2c scanner, allows you to check if the device is detected.
    What are you trying to display and how?... because I don't really believe you've already dealt with the rules. More info!
  • #18 21416781
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    Yeah, there's such a tool, I'm getting it :)
    Screenshot of the ESP Easy Mega user interface showing used I2C addresses and supported devices.
    Screenshot of the ESP Easy Mega interface with the Devices tab showing a list of tasks and devices. .
    it's about the script I uploaded to Rules, a colleague iftri made a change of this script from arduino to esp, I uploaded it to rules and it doesn't hula

    Added after 5 [minutes]:

    I came up with the idea of how to do it in domoticz and then send the measurement to esp32, but the whole issue was to eliminate the middleman which is raspberry, wifi etc, and to raspberry possibly I could have the measurements and register coming in. But cool, as if it would work, unless I upload this Arduino script to the esp and it would too, then instead of the esp easy what application, program do I need to install to get it on the Arduino ? Because i understand that you can upload arduino to esp.
  • Helpful post
    #19 21416795
    iftri
    Level 19  
    Posts: 315
    Help: 31
    Rate: 70
    You can upload to esp32 from Arduino Ide, compile and upload, beforehand you have to prepare Arduino Ide under ESP32
  • #20 21416796
    starob
    Level 29  
    Posts: 1088
    Help: 128
    Rate: 137
    sznickers wrote:
    mate iftri made a change to this script from arduino to esp, I uploaded it to rules and it doesn't hula


    You don't even read (or understand) what I wrote! What @iftri did is an arduino script to upload directly to the ESP instead of espeasy.
    Uploading it to rules won't work because espeasy doesn't understand it.

    Again, use this tutorial and don't mix two different solutions.
    https://www.letscontrolit.com/forum/viewtopic.php?t=3476&start=10

    p.s. I am still reviewing your pics.
    Which sensor signal, A or D do you have connected to the GPIO of the esp? (Because you have cables on both).
    When you spin that magnet does your DOUT LED blink?

    I ask this for future reference :) .
  • #21 21418217
    sznickers
    Level 11  
    Posts: 196
    Help: 1
    Rate: 8
    On the hall module, I have the signal cable connected to D0 and the ESP counts the number of revs and the number of rpm --> yes +/- because it obviously still needs to be calibrated. The LED on the hall module when I apply a magnet or a fan with a magnet blinks, yes or lights up continuously as there are revs.

Topic summary

✨ The discussion centers on adapting an Arduino-based RPM counter using an A3144 Hall sensor and LM393 comparator for use with ESP microcontrollers, specifically ESP8266 and ESP32, with display output on an I2C LiquidCrystal LCD. The original Arduino code was modified for ESP8266, successfully displaying RPM and a bar graph on a 16x2 LCD. Challenges arose when porting to ESP32, including display initialization issues, I2C pin configuration (default GPIO21 for SDA and GPIO22 for SCL), and ensuring proper pull-up resistors on the I2C bus. The user experimented with wiring and contrast adjustments, confirming the Hall sensor module's LED output blinking with magnet rotation, indicating signal detection. It was clarified that Arduino sketches can be uploaded directly to ESP devices via the Arduino IDE configured for ESP32, but the Arduino code cannot be run directly within Domoticz rules or ESPEasy rules due to incompatible scripting environments. The recommendation is to either run the Arduino sketch natively on the ESP or use ESPEasy with its own rules language. The user also considered integrating measurements into Domoticz but aimed to avoid intermediary devices like Raspberry Pi. The importance of correct sensor wiring, magnet placement, and calibration was emphasized for accurate RPM measurement.
Generated by the language model.

FAQ

TL;DR: ESP32 runs at 3.3 V, and "SDA - default GPIO21, SCL - default GPIO22." If your I2C LCD is blank, set those pins in code and adjust contrast to fix it when migrating Arduino RPM counters to ESP32. [Elektroda, iftri, post #21416080]

Why it matters: This FAQ helps ESP8266/ESP32 builders fix no‑display and counting issues when using A3144/LM393 Hall sensors and I2C LCDs for RPM.

Quick Facts

Can I run an Arduino A3144 RPM sketch on ESP8266/ESP32 without ESPEasy?

Yes. Set up Arduino IDE for ESP8266/ESP32, select your board, and upload the .ino over USB. This bypasses ESPEasy entirely. The thread confirms uploading to ESP32 from Arduino IDE after installing the ESP32 platform. Open the IDE, choose the correct COM port, and flash. Then wire the Hall sensor and LCD as the sketch expects. Check Serial Monitor to verify counts. [Elektroda, iftri, post #21416795]

Why does my I2C LCD stay blank on ESP32?

ESP32 is 3.3 V logic. Many LCD backpacks expect 5 V power, so confirm supply and contrast. Set I2C to the default pins in code: SDA=GPIO21 and SCL=GPIO22. Recheck cabling and polarity. The helper specifically called out pins 21/22 and contrast during troubleshooting. This fixes most “blank screen” cases when migrating. [Elektroda, iftri, post #21416080]

Do I need pull‑up resistors on I2C for ESP boards?

Yes. I2C requires pull‑ups on SDA and SCL. Internal pull‑ups may work, but external ones improve reliability. First, bring up the display with a simple Arduino demo to prove wiring and pull‑ups. After that, proceed with ESPEasy or your sketch. This sequence reduces false negatives during debugging. [Elektroda, starob, post #21416730]

How do I wire an LM393 Hall module to ESP and verify it works?

Power the module, then connect D0 to a chosen GPIO. Spin the magnet and watch the onboard DOUT LED. The poster confirmed working RPM counts after wiring D0, with the LED blinking during rotation. If the LED never blinks, the sensor isn’t detecting passes. Confirm wiring and continue testing. [Elektroda, sznickers, post #21418217]

How is RPM calculated in the provided ESP code?

The sketch samples for 1000 ms, counts pulse edges, then multiplies by 60 to get RPM. It sets the Hall pin as INPUT_PULLUP and uses an LCD at address 0x27. Serial logging runs at 115200 baud. Edit sampleTime to balance responsiveness and stability. One pulse corresponds to one revolution by default. [Elektroda, iftri, post #21404166]

How do I send RPM readings to Domoticz from an ESP?

Use HTTP GET to Domoticz’s udevice endpoint. Format: /json.htm?type=command&param=udevice&idx=YOUR_IDX&nvalue=0&svalue=RPM. The example transmits every 5 seconds with ESP8266HTTPClient. Replace idx with your device index and set your Domoticz IP:8080. Check returned HTTP code to confirm delivery. [Elektroda, iftri, post #21404166]

Why won’t my Arduino code run inside ESPEasy Rules?

ESPEasy Rules is a separate interpreter, not C++. Upload the sketch directly instead. As one expert noted, “Uploading it to rules won’t work.” Use either a pure .ino or ESPEasy with proper Rules, not both together. Mixing approaches leads to failure. [Elektroda, starob, post #21416796]

How do I check my I2C LCD with ESPEasy before coding?

Open ESPEasy, go to Tools > Interfaces > I2C Scanner. It lists detected I2C addresses, confirming the LCD responds. If the LCD appears, wiring and pull‑ups are likely correct. If not, recheck power, SDA/SCL, and cable integrity before changing code. This saves time. [Elektroda, starob, post #21416752]

What does the “Time” knob on my LM393 board do? Do I need it?

A user reported success without touching the “Time” setting. Correct magnet alignment relative to the sensor fixed their issue. If readings stall, prioritize spacing and orientation first. Only tweak the board after alignment feels solid. This matched their working setup. [Elektroda, sznickers, post #21406001]

Which I2C pins should I set in ESP32 code?

Use GPIO21 for SDA and GPIO22 for SCL. Call Wire.begin(21, 22) or configure your LCD library accordingly. As a reminder, “These pins are the default.” Setting them explicitly prevents silent configuration mismatches. This step resolves many display problems. [Elektroda, iftri, post #21416629]

How do I build a basic ESP RPM counter in 3 steps?

  1. Wire the Hall module: D0 to GPIO (ESP8266 D2/GPIO4), plus VCC and GND.
  2. Open the provided sketch in Arduino IDE, select your ESP board and port, and upload.
  3. Open Serial at 115200 baud, then tune sampleTime and confirm LCD address 0x27. [Elektroda, iftri, post #21404166]

My RPM stays at zero. What should I check first?

Check the module’s D0 LED during magnet passes. If it never blinks, the sensor isn’t triggering. After wiring D0 to a GPIO, the poster reported successful counting. Verify the signal path and repeat the magnet test until the LED indicates detection. [Elektroda, sznickers, post #21418217]

Can I change sample time or baud rate for responsiveness?

Yes. The example uses sampleTime=1000 ms and Serial at 115200 baud. Lower sampleTime for faster updates, or raise it for smoothing. Keep the RPM multiplier aligned with your sampleTime change. Tuning both parameters improves readability without sacrificing accuracy. [Elektroda, iftri, post #21404166]

Which GPIO should I use for the Hall sensor on ESP8266?

The example uses GPIO4, labeled D2 on many ESP8266 boards. Configure it as INPUT_PULLUP and connect the module’s D0 there. This matched the working code path shared. Verify your board’s pin labels and test with a magnet. [Elektroda, iftri, post #21404166]
Generated by the language model.
ADVERTISEMENT