Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: HC-12 Post ReplyPost New Topic
Page of 3 Next >>
Author
Message << Prev Topic | Next Topic >>
macca
Newbie
Newbie


Joined: 21 February 2017
Location: Australia
Online Status: Offline
Posts: 32
Posted: 03 July 2018 at 4:13pm | IP Logged Quote macca

Hi to all
I have 2 HC-12 one as a slave and one as a master. My question is if it is possible how can I get the master to send a request to the slave to send data and for the master to receive that data.
regards
John


Back to Top View macca's Profile Search for other posts by macca
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 564
Posted: 03 July 2018 at 4:34pm | IP Logged Quote panky

John,

The HC-12 is essentially a serial com port to 433MHz wireless converter. They are used in pairs and set up such that whatever one of the units transmits, the other receives and visa versa.

There is no 'MASTER' or 'SLAVE' as such but of course, you could operate like that within your program on the MM if you chose to do so. All transmission protocols such as Master/Slave, checksum etc. etc. are the responsibility of the program driving the HC-12.

Do a search on the Backshed for HC-12 and you will see several examples of how they are used.

panky.


__________________
DonTSM1,Duinomite,CGCMM1,CGCMM2,2xDimitech,3xWWuMites,MicksMuP,Grogster1A,4xPeterMuM+,Zonker DIP-600,3xCGuKits,CGuBoard2,SnadPic100,SCBP64 & Exp100,PMMZ144,PMMZ100 .. and loving it![:D
Back to Top View panky's Profile Search for other posts by panky
 
macca
Newbie
Newbie


Joined: 21 February 2017
Location: Australia
Online Status: Offline
Posts: 32
Posted: 03 July 2018 at 5:59pm | IP Logged Quote macca

Thank you Panky
I will have a look tonight
Regards
John
Back to Top View macca's Profile Search for other posts by macca
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 564
Posted: 03 July 2018 at 7:14pm | IP Logged Quote panky

John,

You might want to read Captainboing's excellent response to your original post about the HC-12 - he has given you all the info you need to get two HC-12'talking to one another.

panky


__________________
DonTSM1,Duinomite,CGCMM1,CGCMM2,2xDimitech,3xWWuMites,MicksMuP,Grogster1A,4xPeterMuM+,Zonker DIP-600,3xCGuKits,CGuBoard2,SnadPic100,SCBP64 & Exp100,PMMZ144,PMMZ100 .. and loving it![:D
Back to Top View panky's Profile Search for other posts by panky
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6228
Posted: 03 July 2018 at 7:17pm | IP Logged Quote Grogster

On one module, send data into ground and RXD(serial to send), and on the other, receive data out of ground and TXD(serial received).

Both need to be powered by 5v. Both need to be setup for the same channel.

Assuming that, data sent out of the transmitting end, will be received by the receiving end as if it was a wired serial link - as Panky says.

If you have the receiving HC12 connect to a MM COM port that has been opened, then the MM will buffer any data received and all you need to do, is read the buffer.

__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
Andrew_G
Senior Member
Senior Member


Joined: 18 October 2016
Location: Australia
Online Status: Offline
Posts: 247
Posted: 04 July 2018 at 1:46pm | IP Logged Quote Andrew_G

Hi John (and Panky and Grogster),
Panky and Grogster are spot on.
I've had a lot of stuffing around that you can easily avoid - they will work as a pair straight out of the box if:
- they are from the same batch/supplier, preferably genuine ones (see Grogster's thread here
- they are configured to the same frequency, speed and FU type (the default out of the box is fine - no need to alter it unless you need to and you know how to - eg use Rob.Rozee's config. program)
- 5V (I stuffed around with 3.8 to 4.2V which the data sheet says is OK - those at 5V all do much better)
- the supplied coil antennae are better than I gave them credit for (I have some 17cm external ones for critical legs - they are better, but try the coils first
- the antennae line of sight should not be obscured by any material that a radio signal won't go through (air, glass,wood, bricks, thin Fe are OK but onboard batteries, PCBs, and Faraday cages may not be)
- the two andtennae should be orientated the same way but I have found that they can work when not so
- on a MM170 you can use either COM1 or 2 - just get the Tx and Rx pair the right way around (I had no problem if I initially got it wrong - just swapped them around)

Good luck,

Andrew
Back to Top View Andrew_G's Profile Search for other posts by Andrew_G
 
plover
Senior Member
Senior Member


Joined: 18 April 2013
Location: Australia
Online Status: Offline
Posts: 239
Posted: 04 July 2018 at 2:09pm | IP Logged Quote plover

For my own record, as I am hoping to get stuck into something like that in the future:

Here is CaptainBoing and others previous contributions.

http://www.thebackshed.com/forum/forum_posts.asp?TID=10026
Back to Top View plover's Profile Search for other posts by plover
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6228
Posted: 04 July 2018 at 6:15pm | IP Logged Quote Grogster

Clickable link for plover's post above....

Andrew_G wrote:
I've had a lot of stuffing around that you can easily avoid - they will work as a pair straight out of the box if:
- they are from the same batch/supplier, preferably genuine ones


Indeed. I now sell the genuine ones from my website. These are guaranteed to be genuine, as I now buy them direct from the original manufacturer.

Andrew_G wrote:
- 5V (I stuffed around with 3.8 to 4.2V which the data sheet says is OK - those at 5V all do much better)


Agreed. You CAN run the HC12 as a RECEIVE ONLY node on 3v3, but if you try to transmit on 3v3, this often overwhelms the on-board 3v2 regulator as you only have 100mV(0.1V) headroom to play with, and transmitting takes current, so the voltage drops - and if it drops by more then 0.1V, the HC12 will reset and the transmission is lost. They work flawlessly at 5v as Andrew mentions.

Andrew_G wrote:
- the supplied coil antennae are better than I gave them credit for (I have some 17cm external ones for critical legs - they are better, but try the coils first


They are indeed. I have got about 2km of range THROUGH WALLS with the HC12's using the little helical on the transmitting node, and a roof antenna and amplifier on the receiving end. Truly amazing range for the size of the thing and helical transmitting antenna.

Andrew_G wrote:
- on a MM170 you can use either COM1 or 2 - just get the Tx and Rx pair the right way around (I had no problem if I initially got it wrong - just swapped them around)


Even now, after more then 25 years working with RS232 and serial, I am STILL getting the bloody COM port connections wrong. Serial out with respect to.....which end was it again?

Edited by Grogster on 04 July 2018 at 6:25pm


__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
macca
Newbie
Newbie


Joined: 21 February 2017
Location: Australia
Online Status: Offline
Posts: 32
Posted: 04 July 2018 at 6:44pm | IP Logged Quote macca

Hi again I have scanned the forum on HC-12 last night thanks Panky and now have it all working
next question
what is this error
[190] If CtrlVal(tempa) < CtrlVal(lowtemp) Then
Error: Incompatible types in expression

Is there such a thing as error codes that I can look up.?

Regards again
John
Back to Top View macca's Profile Search for other posts by macca
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6228
Posted: 04 July 2018 at 6:58pm | IP Logged Quote Grogster

No error-code list you can look up. I DID start to write an error glossary, but simply did not have the time, as there are lots and lots of different possible error messages.

That specific error message you are getting, is because either tempa or lowtemp are NOT numbers. One might be, but the other one is not, so the interpreter throws that error.

When you get that error, at the command-prompt, type the following commands and press ENTER:

? CTRLVAL(tempa):? CTRLVAL(lowtemp)

This will show you what those GUI controls CURRENTLY are. From that, you should be able to work out which one is causing the issue, and then dig deeper to find out why.

__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
macca
Newbie
Newbie


Joined: 21 February 2017
Location: Australia
Online Status: Offline
Posts: 32
Posted: 04 July 2018 at 7:13pm | IP Logged Quote macca

A big thank you Grogster
will try in a few minutes
regards
John
Back to Top View macca's Profile Search for other posts by macca
 
macca
Newbie
Newbie


Joined: 21 February 2017
Location: Australia
Online Status: Offline
Posts: 32
Posted: 04 July 2018 at 7:34pm | IP Logged Quote macca

Hi
I ran again and same error so typed in ctrlval etc etc
and this is the results
[190] If CtrlVal(tempa) < CtrlVal(lowtemp) Then
Error: Incompatible types in expression
> ? CTRLVAL(tempa):? CTRLVAL(lowtemp)
22.6
0
Both are numbers the Lowtemp is from a numberbox maybe this is where the problem is??
I will keep playing around
regards
John
Back to Top View macca's Profile Search for other posts by macca
 


Page of 3 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1338 seconds.
Privacy Policy     Process times : 0, 0.01, 0, 0.12