Hi everyone. Now I am trying to connect my anemometer to ESP32 microcontroller board and the coding is done in Arduino IDE software. However, I cannot get the output properly. With the same coding, there is no problem with the output when I connect my anemometer to Arduino Uno board. Can anyone help me figure out why this happen?
CODING IN ARDUINO IDE:
/*****************************************************************
* Project: Wind Sensor Test Code in m/s (meter per second)
* Name : MYBOTIC www.mybotic.com.my
* Date : 8 April 2021
*****************************************************************/
#define READ_TIME 1000 //ms
#define WIND_SENSOR_PIN 2 //wind sensor pin
#define WIND_SPEED_20_PULSE_SECOND 1.75 //in m/s this value depend on the sensor type
#define ONE_ROTATION_SENSOR 20.0
volatile unsigned long Rotations; //Cup rotation counter used in interrupt routine
float WindSpeed; //Speed meter per second
unsigned long gulStart_Read_Timer = 0;
void setup(){
Serial.begin(9600);
pinMode(WIND_SENSOR_PIN,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(WIND_SENSOR_PIN),isr_rotation, CHANGE); //Set up the interrupt
Serial.println("Rotations\tm/s");
sei(); //Enables interrupts
gulStart_Read_Timer - millis();
}
void loop()
{
if((millis() - gulStart_Read_Timer) >= READ_TIME)
{
cli(); //Disable interrupts
//convert rotation to wind speed in m/s
WindSpeed = WIND_SPEED_20_PULSE_SECOND/ONE_ROTATION_SENSOR*(float)Rotations;
Serial.print(Rotations); Serial.print("\t\t");
Serial.println(WindSpeed);
sei(); //Enables interrupts
Rotations = 0; //Set Rotations count to 0 ready for calculations
gulStart_Read_Timer = millis();
}
}
// This is the function that the interrupt calls to increment the rotation count
void isr_rotation()
{
Rotations++;
}
Need for help to check code for ESP32 with anemometer in Arduino IDE
Re: Need for help to check code for ESP32 with anemometer in Arduino IDE
You didn't specify what module you where using.
Try a different GPIO pin. Maybe your board has a pull down on that pin.
ESP32 SoC has 5 boot strapping pins. They are:
GPIO0 (HIGH during BOOT)
GPIO2 (LOW during BOOT)
GPIO5 (HIGH during BOOT)
GPIO12 (LOW during BOOT)
GPIO15 (HIGH during BOOT)
Try a different GPIO pin. Maybe your board has a pull down on that pin.
ESP32 SoC has 5 boot strapping pins. They are:
GPIO0 (HIGH during BOOT)
GPIO2 (LOW during BOOT)
GPIO5 (HIGH during BOOT)
GPIO12 (LOW during BOOT)
GPIO15 (HIGH during BOOT)
Who is online
Users browsing this forum: No registered users and 84 guests