Ebay HC-12 wireless transceivers
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
Re: Ebay HC-12 wireless transceivers
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.
Re: Ebay HC-12 wireless transceivers
Quote:
Originally Posted by
Charlie
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.
Re: Ebay HC-12 wireless transceivers
Quote:
It works as expected when wired direct.
which would be not at all
tx true level @38400 baud
Quote:
SEROUT PORTC.5,6,[2] 'sends 2 to the HC-12 every 3 seconds
rx inverted @9600 baud
Quote:
SERIN2 PORTB.2,16468,3000,OVER,[V1]
Re: Ebay HC-12 wireless transceivers
Quote:
Originally Posted by
richard
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.
Re: Ebay HC-12 wireless transceivers
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
Re: Ebay HC-12 wireless transceivers
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
Re: Ebay HC-12 wireless transceivers
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
Re: Ebay HC-12 wireless transceivers
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
Re: Ebay HC-12 wireless transceivers
Maybe you will have better luck in english...