I tried several brands of microwave sensors. This one specifically worked best for me.
Arduino:
/*
Microwave Motion Sensor
Arduino Uno
HW-MS03 Microwave motion sensor
1000uf 25V Capacitor
Lolin Relay
Capacitor across the + -
Senses motion from front and back of the PCB. Not so much from the sides.
This even worked through a fairly thick plastic table that I used as a barrier.
By Nick Senring; 12-6-2022
*/
int HWPin =7;
int Relay = 13;
int val; // This is the value from the HW-MS03 Microwave motion sensor
// It's either 0V or 5V
void setup()
{
Serial.begin(9600);
pinMode(HWPin, INPUT); // HW-MS03 Microwave motion sensor
pinMode(Relay, OUTPUT);
}
void loop()
{
val = digitalRead(HWPin);
//low = no motion, high = motion
if (val == HIGH)
{
Serial.println("Motion detected. ");
digitalWrite(Relay, HIGH); //Turn something on
delay(5000); // 5000= 5 sec 300000= 5min, 600000= 10 min
// Keep it on for a period of time //
}
else
{
Serial.println("Scanning...");
digitalWrite(Relay, LOW); //Turn something off
}
}
ESP8266
/*
Microwave Motion Sensor
LOLIN (WEMOS) Mini-D Pro
HW-MS03 Microwave motion sensor
1000uf 25V Capacitor
Lolin Relay
Capacitor across the + -
Senses motion from front and back of the PCB. Not so much from the sides.
This even worked through a fairly thick plastic table that I used as a barrier.
By Nick Senring; 12-16-2022
*/
int HWPin = 16;
int Relay = 14;
int val; // This is the value from the HW-MS03 Microwave motion sensor
void setup()
{
Serial.begin(9600);
pinMode(HWPin, INPUT); // HW-MS03 Microwave motion sensor
pinMode(BUILTIN_LED, OUTPUT); // BLUE LED onboard as OUTPUT (High/LOW is inverted)
pinMode(Relay, OUTPUT);
}
void loop()
{
val = digitalRead(HWPin);
//low = no motion, high = motion
if (val == HIGH)
{
Serial.println("Motion detected. ");
digitalWrite(BUILTIN_LED, LOW);
digitalWrite(Relay, HIGH); //Turn something on
delay(5000); // 5000= 5 sec 300000= 5min, 600000= 10 min
// Keep it on for a period of time //
}
else
{
Serial.println("Scanning...");
digitalWrite(BUILTIN_LED, HIGH);
digitalWrite(Relay, LOW); //Turn something off
}
}