- LICENSE AND COPYRIGHT
RF::HC12 - Interface to the 433 MHz HC-12 Radio Frequency serial trancievers
Interfaces with the HC-12 433MHz Radio Frequency serial data transceivers.
NOTE: Currently, this distribution can only be used to configure the devices, in the future, I'll incorporate the ability to use it to actually communicate between them.
HC-12 transceivers are designed to operate in pairs. The settings on one device must match the other device or communication will fail.
use RF::HC12; my $rf = RF::HC12->new('/dev/ttyUSB0'); $rf->sleep; $rf->wake; print $rf->baud; print $rf->power; print $rf->mode; print $rf->channel; print $rf->config;
Instantiates a new RF::HC12 module over the serial interface, and returns it.
Mandatory, String: The path and file name of your UART serial TTY device. (eg:
Sends a test command to the HC-12 transceiver. If everything is configured correctly, this method will return the string
Returns all of the various configuration settings as they are currently set. Here's an example containing the configuration of a unit set to factory defaults:
OK+B9600 # 9600 baud OK+RC001 # RF channel 001 (this is the min) OK+RP:+20dBm # +20dBm power (this is the max) OK+FU3 # transmission mode
Resets the HC-12 unit to factory defaults. See "config" for details on what the defaults are.
OK+DEFAULT on success.
Set/get the baud rate of the HC-12.
Optional, Integer: The baud rate that the HC-12 will communicate over. Valid values:
1200 2400 4800 9600 19200 38400 57600 115200
Return, String: The current baud rate, eg.
Sets/gets the channel the device operates on.
Optional, Integer: The channel to operate under. Valid values are
1 (default) through
127. All channels above channel
100 are likely to be flaky, so unless you're testing or having communication problems using lower channels, don't use them.
Return, String: The current operating channel, eg.
Sets/gets the transmission power (dB) of the HC-12.
Optional, Integer: The associated mapping to the value to set. Valid values (1-8):
Param Value (dB) 1 -1 2 2 3 5 4 8 5 11 6 14 7 17 8 20
Return, String: The current value, eg.
Sets/gets the transmission mode of the HC-12. This setting is transparent for the most part, and relies on other settings. I'd recomment reading the datasheet for the device before modifying this setting.
Optional, Integer: The mode to set the device to. Valid values are
Return, String: The current mode, eg.
Puts the HC-12 into a sleep mode. In this mode, no RF communication is possible, and the device will operate at
0.22 micro Amp working current.
The opposite of "sleep". Wakes the device back up for wireless communication.
Returns the current version information from the HC-12's firmware.
<steveb at cpan.org>
Copyright 2019 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at: