Hello
this is a smoke sensor forum with esp32
i need help of what should i link
and what code
I have moved your topic to Project Guidance, It wasn't really related to IDE 1.x.
What smoke sensors are you looking at?
mine is "flying fish" wroom32 smoke-sensor, could you find a linkage with an esp32?
accualy i found it, so uhm here it is
#include <Arduino.h>
#include <driver/adc.h>
const int GPIO32 = 32; // Define GPIO32 constant
const int BUZZER_PIN = 13; // Define buzzer pin as GPIO13
void setup() {
Serial.begin(115200);
pinMode(GPIO32, INPUT);
pinMode(BUZZER_PIN, OUTPUT); // Set buzzer pin as output
adc1_config_width(ADC_WIDTH_12BIT); // Configure ADC1 to use 12-bit resolution
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_11DB); // Set attenuation for ADC1 channel 0 (GPIO32) to 11dB
}
void loop() {
int sensorValue = analogRead((uint8_t)GPIO32); // Convert pin number to uint8_t before calling analogRead()
// Check if sensor value exceeds a threshold (e.g., 1000)
if (sensorValue > 1000) {
tone(BUZZER_PIN, 440); // Play a 440Hz tone if smoke detected
} else {
noTone(BUZZER_PIN); // Stop the tone otherwise
}
Serial.println(sensorValue);
delay(100);
}
thanks
It all works properly for you?
1 Like
Yes it does
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.