PDA

View Full Version : Ebay HC-12 wireless transceivers



n0yox
- 30th January 2017, 02:08
HC-12 wireless transceivers

Has anyone used the HC-12 wireless RS-232 modules on ebay? My modules seem to work fine with Arduino but I am having no luck using a 16F628A/16f616. Very simple code below returns
4
8
2
96
128
32
16
32
32
32
16
128
96
4
16
64
128
128

Transmitter Code 16F616:
Tx:
SEROUT PORTC.5,6,[2] 'sends 2 to the HC-12 every 3 seconds
PAUSE 3000
GOTO TX

Receiver Code 16F628A:
OVER:
SERIN2 PORTB.2,16468,3000,OVER,[V1]
IF V1 = 0 THEN GOTO OVER
SEROUT PORTB.5,6,[#V1,10] 'Output to serial Monitor
GOTO OVER

Charlie
- 30th January 2017, 14:21
Break down the problem - connect the 16F616 pin C.5 to the 16F628A pin B.2 with a piece of wire and make that work first.
GND on both devices should be tied together too.

n0yox
- 30th January 2017, 22:46
Break down the problem - connect the 16F616 pin C.5 to the 16F628A pin B.2 with a piece of wire and make that work first.
GND on both devices should be tied together too.

It works as expected when wired direct.

richard
- 30th January 2017, 23:03
It works as expected when wired direct.

which would be not at all


tx true level @38400 baud

SEROUT PORTC.5,6,[2] 'sends 2 to the HC-12 every 3 seconds

rx inverted @9600 baud

SERIN2 PORTB.2,16468,3000,OVER,[V1]

n0yox
- 30th January 2017, 23:38
which would be not at all


tx true level @38400 baud


rx inverted @9600 baud


It works for sure when wired direct.
If you take a look at the third 9600bps mode " http://melabs.com/resources/ser2modes.htm " you will find that 16468 is indeed 9600 inverted when using serin2 as is mode 6 when using serout. I am running inverted since I am wired direct and not thru a set of MAX232 ics.

richard
- 31st January 2017, 00:13
ok [I was thinking serout2]

are you sure the signal needs to be inverted , I have not used these modules but the code here is using true levels
http://www.picbasic.co.uk/forum/showthread.php?t=20869

there is also mention of setting the module correctly re baud rate and fu_x

n0yox
- 31st January 2017, 04:07
Thank you, Richard the link was helpful as was yours and Charlie’s comments .My project is back on track with the code below

Transmitter Code 16F616:
Tx:
SEROUT PORTC.5,2,[2] 'sends 2 to the HC-12 every 3 seconds
PAUSE 3000
GOTO TX

Receiver Code 16F628A:
OVER:
SERIN2 PORTB.2,84,3000,OVER,[V1]
IF V1 = 0 THEN GOTO OVER
SEROUT PORTB.5,6,[#V1,10] 'Output to serial Monitor
GOTO OVER

jeffer
- 12th November 2021, 21:02
buenas tardes tengo problemas mi hc 12 no se conecta no envía datos hice el código como está y no agradecería si alguien me puede ayudar

DEFINE OSC 4


include "modedefs.bas"


LEDS VAR BYTE


CMCON=7


TRISA=$FF


TRISB=%00000000


PORTB=0


PORTA=0


PAUSE 50


INICIO :


SEROUT PORTB.2,2,[2]
PAUSE 1000
GOTO INICIO


END

jeffer
- 12th November 2021, 21:03
y este es el codigo que uso para el receptor:

DEFINE OSC 4


include "modedefs.bas"


LEDS VAR BYTE


CMCON=7


TRISA=$FF


TRISB=%00000000


PORTB=0


PORTA=0


HIGH PORTB.0
PAUSE 1000
LOW PORTB.0


INICIO:


SERIN2 PORTB.1,84,300,INICIO,[LEDS]


IF LEDS=2 THEN


PORTB.0=1


PAUSE 500


ENDIF
goto inicio

Ioannis
- 13th November 2021, 10:26
Maybe you will have better luck in english...