Anemometer On Wifi LoRa 32

Hi, I’m trying to use an anemometer (Anemômetro Arduino para Estação Meteorológica!) connected to a WiFi LoRa 32, but this sensor needs to be connected to an interrupt pin, I gave a research and it seems that it would be the pin 26 in LoRa 32 . I made the connections using a resistor as requested and made the changes in the code but it still did not work

This is my code:

// Pin definitions
# define Hall sensor 2         //  Pino digital 2

// Constants definitions
const float pi = 3.14159265;           // Numero pi
int period = 5000;               // Tempo de medida(miliseconds)
int delaytime = 2000;             // Time between samples (miliseconds)
int radius = 147;      // Raio do anemometro(mm)

// Variable definitions
unsigned int Sample = 0;   // Sample number
unsigned int counter = 0; // magnet counter for sensor
unsigned int RPM = 0;          // Revolutions per minute
float speedwind = 0;         // Wind speed (m/s)
float windspeed = 0;           // Wind speed (km/h)

void setup()
  // Set the pins
  pinMode(2, INPUT);
  digitalWrite(2, HIGH);     //internall pull-up active
  //Start serial 
  Serial.begin(9600);       // sets the serial port to 9600 baud

void loop()
  Serial.print(": Start measurement...");
  Serial.println("   finished.");
  Serial.print("Counter: ");
  Serial.print(";  RPM: ");
  Serial.print(";  Wind speed: ");
//print m/s  
  Serial.print(" [m/s] ");              
//print km/h  
  Serial.print(" [km/h] ");  

  delay(delaytime);                        //delay between prints

// Measure wind speed
void windvelocity(){
  speedwind = 0;
  windspeed = 0;
  counter = 0;  
  attachInterrupt(0, addcount, RISING);
  unsigned long millis();       
  long startTime = millis();
  while(millis() < startTime + period) {

void RPMcalc(){
  RPM=((counter)*60)/(period/1000);  // Calculate revolutions per minute (RPM)

void WindSpeed(){
  windspeed = ((4 * pi * radius * RPM)/60) / 1000;  // Calculate wind speed on m/s

void SpeedWind(){
  speedwind = (((4 * pi * radius * RPM)/60) / 1000)*3.6;  // Calculate wind speed on km/h

void addcount(){

Always a good idea when troubleshooting a bit of code to reduce it to a minimum that highlights the issue. In this case just reduce the program so that all it does (or should do) is print a message when a button is pressed and causes an interrupt.

The diagram you linked to shows that pin 26 is actually an output from the LoRa device, so attaching a button to it and trying to force this output pin to ground via a button is not a good idea.

As for this bit;

attachInterrupt(0, addcount, RISING);

Where did that code come from ? Your assigning the interrupt to internal interrupt number 0, not sure which physical pin that corresponds to.

This code I am using is one provided by the reseller himself, but I modified it to test and I just forgot to post the original (I modified it in the post now). What do you indicate to do?

I tested with the mega arduino on digital port 2 and 3 and it works correctly because it is interrupt pins, but in LoRa I have not got it yet.

The board is has an ESP32 processor with a OLED and a LoRa device on it. What you are programming has nothing to do with the LoRa device.

Suggest you look up the Arduino reference for ‘attachinterrupt’ and the get a simple push button interrupt example working.

Yes, the code I am using is for the Arduino, but I just wanted to see if it was possible to get the wind speed with the anemometer sensor connected to the Wifi LoRa 32, and then do the LoRa send functions. I'll take a look at the function 'attachinterrupt'.