HC-12 433 mHz module + Ard + Kerui PIR

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hello

Re: roller door
For a few years I used the front gate controller based on Nano, however this project used an end-switches.

Re: 1527 based receiver
Would be interesting to see how it goes.

Re: rxb12 receiver
I see the next problems in my project:
- noisy AGC and ways of waiting until AGC level will drop after 1st of 2nd packet will pass
- problems with FC8 Timer reading microseconds (compare to Arduino IDE micros() function)
- separating code into two stages. 1: save TTL data into a buffer during reception. 2: process data after buffer is full.

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Processing the buffer will probably be the easiest part I think.

When I played earlier with the data I generated, albeit in Sim, it was easy enough to create "bits" from the stream (HHHL = 1 / HLLL=0) and from that the 20-bit address and 4-bit data.

Still waiting to hear if the neighbour is going ahead. My plan is to modify the Rx board to accept magnetic switches as limit switches but if that fails I'll knock up a PIC based controller using the Rx outputs as triggers.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Thanks
Would be interesting to see the results

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Parts ordered re garage door.

As mentioned the RF is generic 433MHz and based on the 1527 so I hope to get a scope on it soon. Will update with anything of interest.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

1527 protocl as Morze code

Post by viktor_au »

Hello

After thinking about the decoding method I have realised that (probably?) no need in measuring the duration of the pulse during the High state and the Low state. We can measure duration only during the Low state.
Just a suggestion.
We can decode the protocol measuring the duration during one of the states.
I tried to use the Low state of D2 input

Example
D2 input = Low (High state is changed to Low).
Timer1 -> Start
D2 input = High, Timer1-> Stop. Measure the microseconds.
-------------------------------

I couldn't find on www anybody with this idea (however some do try to calculate the previous High duration somehow and after having the High duration and Low duration filter out the Logic One or Logic Zero).
I think you can call it the Morze method.
Let us have a look at the Morze code:

___ _ ___ ___ _ _ ___ ___


If we use LL as LowLong and LS as Low Short, the above would be:
LL,LS,LL,LL,LS,LS,LL,LL
Because we know the 1527 protocol uses:
If we have LL after High state was detected we can say that it is a Logic Zero.
If we have LS after High state was detected we can say that it is a Logic One.
------------------------------------------
Errors
Looks like the errors will rise if we use the Low state only. The practice will show how good this idea is.

Finally I had a chance to use my scope.
As I have PIR sensors from two different Chinese manufacturers I noticed that even the 1527 protocol used by both companies the length of pulses are different.
--------------------------
Below example for Kerui PIR sensor.
Low Short and Low Long durations are less than the no-brand PIR sensor.
Attachments
LS=264uS_2.jpg
LS=264uS_2.jpg (39.58 KiB) Viewed 57614 times
LL=888uS_2.jpg
LL=888uS_2.jpg (39.18 KiB) Viewed 57614 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi Viktor

Those traces are quite interesting for all the wrong reasons :)

When I saw the first trace showing a low (part of transmitting a 1, 3xH + 1xL) of 264uS giving a presumed total bit length of 4 x 264 = 1056uS I thought not too bad, however when you look at the preceding High portion you can clearly see it is far more than three times the width of the Low (should be ~792uS for a Low of 264uS).

Your next trace shows a "0" (1xH + 3xL) which should give a Low of around 792 based on your previous trace, but you get 888uS.

I assume that the outputs are consistent, in that you are getting the same results each time, albeit not quite as expected? Of interest, is the total "bit" length the same or does it vary too (time taken to transmit 3H + 1L or 1H + 3L). If results are consistent then you can base around your empirical values and measuring the time from H/L transition until L/H could certainly be one way to capture.

I'm due to receive the remote control tomorrow sometime so quite keen to see what comes out of it.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi

Re: Pulse duration
I can be wrong but I can say that the Timer1 readings are not stable. This is the reason number 1.
Another problem is the amount of 'noise' during transmission and reception. Voltage as well.

Re: consistence of the pulse duration.
I don't think that duration is constant (again -> problem with Timer1, etc).
I noticed the next. I tried to capture the preamble and it wasn't easy as duration was changing after each reset of Nano.
I should add to another problem the steady +5v supply or +7-12v supply to Nano. If power supply is not good the duration will change all the time.
That is why people use the min/max values.
I didn't find time to finish reading the Kerui PIR sensor, but I think the:
1. Low Long duration should be apprx (p_us >= 700 && p_us < 1150)
2. Low Short duration should be apprx (p_us >= 150 && p_us < 350)
Note: the sensors from different manufacturers have different pulse duration.

Re: RxB12 and HC-12
Even the topic has title HC-12 mHz module 90% of work is done with the module RxB12.
The reason is: HC-12 transmitter works with HC-12 receiver and I wasn't able to do anything as I have only one module (need two to do something).

Re: Hig/Low transition
You are right.

When D2 state = Low we start Timer1.
When D2 state = High we stop Timer1 and save value in microseconds.
Than we try to get preamble.
Example: Is duration > 10000?
Yes -> Is duration < 16000? flag it.
No -> flag_prmbl = 0

Re: Morze code method
I am not sure if this method will work, but in theory it should

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Received my module but only had a brief look so far.

Appears well made but much smaller than expected. Chips are all SMT and eentsy. Looks like they are using custom chips based on protocols too, as the numbers appear to be OEM. The RF section appears to be a very, very small board connected by a few pins marked Positive, Negative and DO (which may be two pins).

Reading up a little it appears pulse width can be anything from about 1100 to 1600uS. That's quite a discrepancy (~40% ish). However the rest of the board seems to care little.

Just guessing just now but perhaps it's waiting for a H/L transition and timing? With such discrepancies I think timing of Low could be the way to go.

My initial suggestion of sampling within each "time period" clearly won't work with such variance in width.

Maybe upon transition, start counting until it returns to High? Greater than "x" it's preamble, greater than "y" it's a "0" with greater than "z" being "1".

I'll try and get a scope on things.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hello

Can you please publish a photo of your module?
Is it a Rx only module?

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Got any vinegar? As per my moniker the chips are well and truly fried...... :(

The unit is from Qiachip (https://qiachip.com/) and is a two channel 220v controller https://qiachip.com/collections/ac-powe ... els-module

I am, or was going to use it to control a roller shutter.....

In a lapse of sanity I accidentally shorted out part of the board.... Cat wasn't best pleased with the bang :lol:

I then removed what appeared to be the RF unit which is marked RX217E and had +ve / -ve / DO markings on pins. The only chip was I assume OEM, marked 9080. Connecting DC across the terminals with a scope on DO showed a flat trace so I'm guessing I made a good job of destroying things.

Another on order.....

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi
Accidents... What can you do...

Can you please have a look at the Rx module chip?
I tried to find out on the web-site, but failed.

Is it SYN470R?

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

The board (KR2202) came as a complete control unit based on 1527 and appeared to have a small RF module attached at top right. After I blew it to bits I removed the RF module in the hope it could be recovered. The 90 degree headers were solidly jammed into the PCB holes then soldered (holes are probably a drill size too small). Freeing the module took considerable physical effort and it could have sustained damage in my doing so.

There is a single chip marked 9890, a crystal with the odd discrete or two. Unfortunately I don't know what the board outputs, RF or digital but I suspect it isn't RF.

RF_Front.JPG
RF_Front.JPG (154.99 KiB) Viewed 57409 times

RF_Rear.JPG
RF_Rear.JPG (138.68 KiB) Viewed 57409 times

The main board has a couple of chips which appear to be the brains of the unit marked (I think) FMD B2J4RKE and LK22221. Unfortunately I can't find any information for any of them. However the RF DO pin connects to Pin-2 of the FMD B2J4RKE so I guess it is doing decoding.

Controller-1.JPG
Controller-1.JPG (143.84 KiB) Viewed 57409 times

Kaboom :)

Controller-2.JPG
Controller-2.JPG (128.49 KiB) Viewed 57409 times

When I get the replacement controller I might gingerly have another poke..

Regards

EDIT...

New controller arrived and the DO output on the RF board is digital, therefore all RF processing is handled in the module by the 9890 chip. Output is high until it receives a transmission. I might connect a hand held scope if I get time, as I'm a bit wary of connecting anything that's actually grounded to this.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hello

Re: There is a single chip marked 9890, a crystal with the odd discrete or two.
I think it is a decoder chip. Probably not 9890, but 9896.

Re: Unfortunately I don't know what the board outputs, RF or digital but I suspect it isn't RF.
RF is an umbrella word.
RF covers all possible frequencies and modulations.
For 433.92 mHz (no licence freq) people use something like the Morse code system by changing the carrier as:
Amplitude Shift Keying or ASK.
On or 1 = RF is max
Off or 0 = RF is none
In Amplitude Shift Modulation the amplitude (i.e. the level) of the carrier wave is changed in response to the incoming data signal. This is sometimes called Binary Amplitude Shift Modulation as there really are only two levels to be concerned with:

Tx, Rx kit
I think you have two Rx modules.
One Rx module has two relays ( the one you need to control an AC motor).
You need another module -> the Tx module (button).
https://qiachip.com/collections/ac-powe ... els-module
Attachments
Rx+2relays_3.jpg
Rx+2relays_3.jpg (61.99 KiB) Viewed 57390 times
Rx+2relays.jpg
Rx+2relays.jpg (73.63 KiB) Viewed 57390 times
Kit_AC_1.jpg
Kit_AC_1.jpg (47.72 KiB) Viewed 57390 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

You could be right. That chip is very possibly 9896, the writing is so very small and it appears to do everything regarding processing the RF signal and outputting a digital pulse. Without a scope on the pin I can't say for certain what it actually outputs when receiving however it is a stable High (+5v) in standby, dropping Low (approx 2.2v) during reception (as measured on a multimeter which obviously can't respond fast enough).

Quite correct in that I have two transmitter units too (well, four now :) ), but didn't mention them. Very easy to pair and set up the controller to respond how I wish. I have the two relays toggling depending on button pressed ("A" = Relay 1 On, Relay 2 Off/ "B" = Relay 1 Off, Relay 2 On)

I'm more annoyed at destroying the RF module itself than the whole controller though, as it seems a capable little board.

Charging up my hand held scopes so hopefully I can capture the DO pin. Not sure if the batteries will hold a charge though.... it's been a while.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi

Re: I have two transmitter units
If you have two transmitters, what kind are they?
Is it the two-button module or just one button module?

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Each controller came with 2 x Two Button Fobs on a little chain. Can't honestly fault it really, although I haven't done any range testing. I'll post a picture later.

My little Velleman scope, is to be fair very basic indeed, and I bought it precisely due to its compact size and lasting a while on a charge. It was bought to connect with a current clamp so I could "see" inside a cable and did the job very well indeed (I was looking for random transient inductions).

I connected it to the RF DO terminal and can confirm that in the presence of a transmission from any Tx unit whether paired or not, it outputs a clearly defined square wave along the lines of what's expected.

I didn't have time to measure any parameter before it died though. It's now on charge alongside a Tektronix so hopefully tomorrow I'll be able to capture.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi

I am not sure why do you want to measure the RF TTL signal.
As I understood you have the complete system to control the AC garage door: the button Tx module and Rx module with two relays.
If you connect the Rx module output to MC input you can control the opening and closing of the garage door by waiting for the end-switch state change (or some other methods).
What is the block-diagram of your project?

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi

A link to my old project (the automatic gate) with 433mHz Tx->Rx module.
http://www.geocities.ws/viktor_au/proje ... oller.html

chipfryer27
Valued Contributor
Valued Contributor
Posts: 618
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by chipfryer27 »

Hi

Thanks for the link. Quite good timing as a builder friend wants his gate automated. A simple swing gate was installed, but due to space restrictions he then pivoted it in the middle..... Now he hopes a "bog standard" gate motor can be retro fitted and guess who he wants to attempt it... Lovely.... :( Monitoring the motor current is something I think could be a very prudent inclusion. I assume you monitored the voltage over a low value series resistor?

With regards to the controller I mentioned in previous posts, I don't actually need to do anything at all with it as it works as a turnkey unit straight out of the box. However as it uses the same protocol as the system you are having some issues with, I thought it could be helpful to document the output of the unit, especially as it appears the RF module accepts all relevant transmissions and subsequently outputs a clear digital signal.

It's cheap, so perhaps you could use it to help decode your Kerui signal by providing a clear digital signal whenever your PIR communicates? I appreciate you still need to decode the signal, but it looks like this RF module provides a cleaner output than the signals you posted earlier.

At present I'm still favouring timing the Low period, but if I capture repeatable outputs with regards to High/Low then I might reconsider.

Tektronix scope batteries are beyond help (new over 15 years ago at least) but I'm not hugely inclined to connect it to a 240v Chinese board anyway. My two other battery scopes should be helpful enough though.

Regards

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: HC-12 433 mHz module + Ard + Kerui PIR

Post by viktor_au »

Hi

Re: motor current monitoring

I used the AC712 module first, but due to a lot of unstable readings I changed it to a simple 2A fuse.
I think a hand resistance (try to stop the gate by one hand) will blow it.

1527 protocol

Sure. Understood. I think I am close to read the PIR sensors, but due to some problems I have moved to the smoke detector project (Mq135). After I finish it I will move back to 1527 protocol. I have used my scope to take pulse durations out of RxB12 module. Now at least I know the min/max values to work with.

Measuring the Low durations

I am going in this directions as RxB12 on board chip (SYN470R) 'goes' into high level due to AGC has no signal. A lot of 'pulse-like-noise' generated out of AGC.
I can see on my scope that (after first packet arrived) -> it is corrupted.
I do beleive that I need only a few days to finish with decoding 1527 protocol. Will do it soon.

Post Reply