This is a Doppler RF transmitter and receiver which can be used as a movement alert.
You can read about it here http://www.theorycircuit.com/hb100-microwave-motion-sensor-interfacing-arduino/
I have made the electrical circuit described there to amplify the signal, added a voltage level converter (2 resistors of 5 kohm and 10kohm) to connect it to WEMOS (which connects to a server).
I connected the output to A0 pin.
I tried first to use the sketch but it didn't work for me... so I wrote a little sub to measure the output.
It is all experimental and probably needs calibration due to many variations in the complete device.
The sensors output is not a steady voltage but some kind of waveform so I made the following:
1. Measure the mean value of the output.
2. Measure some sample of the frequency by counting every time that the value is above mean and the next value is below. I got a count of about 50-60 for a loop of 10000.
3. The counted sample drops meaningfully when a movement is detected (both directions), so I have defined a number as a lower limit to define as detection.
Notes:
1. The antenna's face is the flat side of the sensor.
2. The measured values are affected by the power supply's voltage and the position of the sensor so you need to define the values in the intended location and with the final power supply.
3. The attached code is partial for the sensor's part only.
B4X:
Sub Process_Globals
Public Serial1 As Serial
Public sensepin, ledpin As Pin
Private D1 As D1Pins
Private mean As UInt = 490
...
end sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
sensepin.Initialize(sensepin.A0 , sensepin.MODE_INPUT)
ledpin.Initialize(D1.D7, ledpin.MODE_OUTPUT)
tmr.Initialize("tmr_Tick",1000)
...
end sub
Sub tmr_tick
Dim x As Int
Dim flag As Boolean = False
Dim count As UInt = 0
For i = 0 To 10000
x = sensepin.AnalogRead
If x > mean Then
flag = True
End If
If x < mean And flag = True Then
count = count + 1
flag = False
End If
Next
Log(count)
If count < 40 Then
ledpin.DigitalWrite(True)
If RFClient.Connected Then
astream.Write(Array As Byte(1))
Delay(1000)
End If
Else
ledpin.DigitalWrite(False)
End If
' Measure mean value
'Dim x As Double = 0
'For i = 0 To 15000
' x = x + sensepin.AnalogRead
'Next
'mean = x/15000
'Log(mean)
End Sub
Last edited: