Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read HC-SR501- infrared detector module #196

Open
mateusmsantin opened this issue Oct 12, 2021 · 6 comments
Open

Read HC-SR501- infrared detector module #196

mateusmsantin opened this issue Oct 12, 2021 · 6 comments

Comments

@mateusmsantin
Copy link

I used ‘Exemple04_MultipleAccessories’ multiple_accessories.ino example and change to read sensor pin HC-SR501.

// bool m = random_value(0, 10) < 5; 
  bool m = digitalRead(PIN_SENSOR);      
  if(m == HIGH){
       Serial.println( m ? "HIGH" : "LOW");       
   }else {
       Serial.println( m ? "HIGH" : "LOW");
    }
  LOG_D("SENSOR VALUE %u \n", m); //Here I can’t view at serial monitor. I believe it should show similar to the 'simple' example below.

But it is unstable, that is, when the sensor is active it does not show the door reading. When I use the same circuit simply, just to check the reading it works.

simple.ino (just to test)

//faz a leitura do sensor de presença (retorna HIGH ou LOW)
  bool sinal = digitalRead(PIN_SENSOR); 

//HIGH : motion detected
if(sinal == HIGH){      
      Serial.println(sinal ? "HIGH" : "LOW");
      digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  } else {
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    Serial.println(sinal ? "HIGH" : "LOW");
                 
 }

Thanks in Advanced.

@maccoylton
Copy link

Using an interrupt callback works fine for me, example and motion sensor firmware can be found here:- https://github.com/maccoylton/esp-homekit-motion-sensor/tree/master/src

@mateusmsantin
Copy link
Author

Hi @maccoylton, thanks for replying.
I try to compile the code on the Arduino platform, but I get the error:

ensor_HS501: 16: 10: fatal error: espressif / esp_wifi.h: This file or directory does not exist
     16 | #include <espressif / esp_wifi.h>
        | ^ ~~~~~~~~~~~~~~~~~~~~~~~~
compilation finished.
exit status 1
espressif / esp_wifi.h: This file or directory does not exist

What do you use to compile, please.

@maccoylton
Copy link

This is not for use with Arduino, it's normally built from the command line. You need to follow the instructions on esp-homekit to set up your development environment.

@mateusmsantin
Copy link
Author

Ok, I will make a configuration environment to compile and test. Is it possible to compile the example with a generic ESP8266, or just with ESP32?

@maccoylton
Copy link

This should work with either, although I use ESP8266.

@mateusmsantin
Copy link
Author

I’d like to use at Arduino interface, but I stay to try configuring and install environment to compile the example (https://github.com/maccoylton/esp-homekit-motion-sensor/tree/master/src).
But I’m don’t have success to do. Can somebody suggest a manual to compile it at Mac Os please ?
I saw a lot of examples, but many errors. I believe that I don’t have many concepts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants