HC-12 remote

JPB33

Senior Member
I have been using the HC-12 as a very simple remote for a while, works ok. However I dont understand why my variable b0 which is transmitted as a 1 becomes 6 on the receive side?

I have found like others that the newer HC-12 can only be used as pairs are discussed elsewhere. When I use an older HC-12 I get a number of 64 for b0?

Not sure what I've got wrong, can anyone guide me please. Peter

Code:
output C.0,C.2
	input C.3,C.4,C.5, C.1
	 
	
	'TX Same program below working on both TOGGLE and HIGH OUTPUT when SWITCH PRESSED 3-5-18. THIS VERSION IS SWITCH ON/OFF ONLY 
	
	do
	If pinc.4 = 1 then 		'press c.4 switch to operate
	b0 = 1  pinc.2 = 1 else b0 = 0  pinc.2 = 0  endif		'Checking b0 to put C.2 high to confirm b0 is 1
 	sertxd("The value of b0 is ",#b0,13,10)
	serout C.1, N2400, (b0)                   
	loop

	'RX below for high output on C.2 only when input switched on WORKING 3-5-18

	do 
	b0 = 0
	serin c.4, N2400,  b0 
	sertxd("The value of b0 is ",#b0,13,10)
	if b0 = 0 then low C.2 else high C.2 endif 	 'Checking b0 number, should be 1 but why 6? LED on and relay switched by C.2
	pause 100
	loop
 

hippy

Technical Support
Staff member
Are you using the right polarity and baud rate ? Should it be N2400 or something else ?
 

Jeremy Harris

Senior Member
When I've used them as a remote control, I've used handshaking between the "transmitter" and the "receiver" to improve reliability, together with an LED on the "transmitter" that lights when the "receiver" has correctly received the command and activated the controlled device. I've also used a password-like ASCII string as the command word, with verification of this string as a part of the confirmation that the "receiver" has operated correctly.

I wrote this up here: http://www.picaxeforum.co.uk/showthread.php?28893-HC-11-and-HC-12-transceiver-modules&p=300229&viewfull=1#post300229 and here: http://www.picaxeforum.co.uk/showthread.php?28893-HC-11-and-HC-12-transceiver-modules&p=300232&viewfull=1#post300232

Note that there is an omission in the transmitter schematic, in that I connected an LED and current limiting resistor to pin C.0 in the final version, to indicate that the signal had been received and acted on (the code is correct - I just forgot to amend the schematic).
 

JPB33

Senior Member
Many thanks everyone, dead right it was the N I had instead of T.

As the unit it is operating is in the same room I know when it is working so hadnt attempted a handshake but think on reflection its is a good idea to improve security so thanks for the link.

When I use PE6 to simulate the RX by putting a 1 or 0 into the serial terminal window it loops a couple of extra times and I get a 1 initially and then 13 followed by 10, 0 produces 0 then 13 then 10?

My latest HC-12 are clones, wondered if anything else has emerged to replace the HC-12 in view of the various problems?

Screen shot  b0  4-5-18.jpg
 

hippy

Technical Support
Staff member
I get a 1 initially and then 13 followed by 10, 0 produces 0 then 13 then 10?
CR ($0D,13) and LF ($0A,10) being sent after the data. In Terminal, untick the Settings option; "Add CR-LF on send".
 
Top