Go Down

Topic: HW-MS03 Radar Sensor? (Read 392 times) previous topic - next topic

c1-c2

Dec 01, 2019, 07:11 pm Last Edit: Dec 01, 2019, 07:12 pm by c1-c2
Hi,

has anybody managed to run this sensor
https://www.amazon.com/HW-MS03-2-4GHz-5-8GHz-Sensor-Module/dp/B07MPVQ6ZQ
with Arduino/ESP8266?

I am looking for an example sketch / library... but it seems nobody posted some lines of code yet...

Pls let me know if you have a pointer to some code to get me started... that would be great! :)

thanks in advance



Paul_KD7HB

Do you have on in hand or are wanting to get in line to order one?

Paul

c1-c2

Hi Paul,

I already have it. Why is this relevant I wonder...

Dave

Paul_KD7HB

Hi Paul,

I already have it. Why is this relevant I wonder...

Dave
Your link points to the statement that it is NOT available!

Paul

c1-c2

Yeah sorry. I picked a random link to provide a pic of the part.

gilshultz

Why not write the code and help all of us! The unit is in short supply at the current time. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

c1-c2

Gil,
thanks a lot for taking the time to respond.
However, your input does not help a bit.

I am certainly not trying to rip off the community to solve a $$$ project for me.

I am merely looking for a wiring diagram or a few lines of code would just save me 2h fiddling and possibly risking the health of the module - this is not about solving my problem at all.

The module is part of a complex home assistant project and I am looking forward to spend a lot of time solving this by myself.

> The unit is in short supply at the current time.
btw: The item is broadly available on Ali.

thanks
Dave


pert

There are only 3 connections: GND, OUT, +Vin
So the first question is what is the safe supply voltage range to connect to the +Vin pin. According to the first Google result, the minimum is 5 V:
https://youtu.be/9WiJJgIi3W0?t=406

So to power it you need to connect the GND pin from your Arduino to the GND pin on the HW-MS03 and the 5V pin from your Arduino to the +Vin pin on the HW-MS03.

So the way this is going to work is like the PIR sensors. When the module doesn't detect movement, the OUT pin will be in one state (LOW or HIGH, I'm not sure) when it detects movement, the OUT pin will switch to the other state for 5 seconds (according to the same video: https://youtu.be/9WiJJgIi3W0?t=475), before switching back (unless movement has continued to be detected).

Since it runs at 5 V, likely the output is also 5 V. Since your ESP8266 is a 3.3 V device, you will probably want to convert the 5 V output of the module to 3.3 V. You can do this with a resistive voltage divider. So connect the OUT pin on the HW-MS03 to any free IO pin on your Arduino via the voltage divider.

You really don't need a library to use with this sensor because it's so simple. Likely there is some PIR sensor library for Arduino that will work just as well with this sensor, but anyone who would write such a library is probably a beginner so there is no guarantee that the code will be any good. The most basic code you could use to test the sensor looks like this:
Code: [Select]
const byte motionSensorPin = 3;

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(digitalRead(motionSensorPin));
}

This is configured for the motion sensor's OUT pin to be connected to pin 3 on your ESP8266, but you can adapt it to any pin you like. Note that on some ESP8266 boards like the WeMos D1 Mini, you need to use the pin names like D3 in order for them to match to the labels on the silkscreen of the board.

Upload that sketch to your ESP8266, open Serial Monitor, then make sure the baud rate is set to 9600. you will see a string of 0 or 1 scrolling down the screen depending on whether the sensor has detected motion or not. You should be able to go from there to write code for your particular application.

c1-c2

Hi pert,

This is way more help than I ever expected to get here. Thank you, and I really appreciate the time you spent to write up this information.
Works great, I'll add mqtt now and integrate all of it into home assistant.


pert

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

Go Up