I’m trying to crate a Lora PIR sensor using HC-SR501 module and Heltec Lora 32 v2 (EU433).
I connected the PIR to groung, 3v3 and GPIO13. I am able read the pin state. Cool.
Then I added some timer-based limits and actions (i.e. notify motion detected not often that 20secs, send keepAlive each 3mins). Untill actions are just Serial.print mocks (nothing is really sent) everything is fine: Sensor is putting the pin HIGH for few seconds, then goes LOW. My time limiters are working and I’m not spamming, but sending keepalives if needed. All is fine.
Then I added actual transmission to my actions:
Code: Select all
void sendMotionDetected() {
Serial.println("LoRa: Sending MotionDetected !");
// send packet
LoRa.beginPacket();
LoRa.print("1");
LoRa.endPacket();
}
void sendKeepAlive() {
Serial.println("LoRa: Sending KeepAlive.");
// send packet
LoRa.beginPacket();
LoRa.print("0");
LoRa.endPacket();
}
Code: Select all
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
LoRa: Sending KeepAlive.
Pirpinstate = 1
LoRa: Sending MotionDetected !
Pirpinstate = 1
Pirpinstate = 1
Pirpinstate = 1
Pirpinstate = 1
Pirpinstate = 1
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
Pirpinstate = 0
LoRa: Sending KeepAlive.
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
LoRa: Sending MotionDetected !
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
Pirpinstate = 1 // 1 shouldn't be here - there was no movement
Pirpinstate = 0
Pirpinstate = 0
Code: Select all
...
Pirpinstate = 0
LoRa: Sending KeepAlive.
Pirpinstate = 0
Pirpinstate = 0
...
They used that pin to talk between Lora and ESP chips - I need to change the pin. Not so easy
What I tried?
- changing pin to GPIO 2 and 12 - the same
- changing PIR sensor to other type (smaller) - the same
- disconnecting sensors OUT wire - this fixed the issue
- connect pullDown resistor between IO pin and GND (and disabling INPUT_PULLDOWN in code) - the same
But how to get rid of it?
(full code below)