0

[first time usage]

I'm checking this config out with a simple sketch derived from one @ https://www.allaboutcircuits.com/projects/understanding-and-implementing-the-hc-12-wireless-transceiver-module/.

The sketch acknowledges a command from the Serial Monitor and responds accordingly along with an "OK". I have used this sketch countless times before with numerous HC-12 and UNO, and this particular HC-12 functions properly when connected to such.

For the Pro Micro, the command is echoed back instead, which, in my experience, indicates that the HC-12 is not receiving/responding.

The Pro Micro test config is very basic: Pro Micro, HC-12, USB connection, 5 direct jumper connections for vcc, gnd, pins 4-6. Vcc output reads 4.2 volts.

I specify:

const byte HC12RxdPin = 4; // "RXD" Pin on HC12
const byte HC12TxdPin = 5; // "TXD" Pin on HC12
const byte HC12SetPin = 6; // "SET" Pin on HC12

SoftwareSerial HC12(HC12TxdPin, HC12RxdPin)

I have also tested with an IN4007 in the power connect for the HC-12, but results are the same.

I've swapped HC-12s, and checked out the requisite pins by using another sketch that toggles an led on each. The Arduino IDE is 1.8.2, and I am specifying a Leonardo board. This is the suggestion I found whilst researching.

I have seen a few projects using the HC-12 with the Pro Micro and other small boards, but noticed no special considerations for such.

Have you any suggestions or solutions [even better]?

3
  • mico Thanks to the reference cited, I think I finally comprehend the situation. Reading was easy, comprehension more difficult. Based upon the reference, I removed the HC-12 specifications, then specified Serial1 for the reads, writes and available check. I then changed connections, such that the HC-12 RXD pin connects to the Pro Micro TXD pin, and the HC-12 TXD pin connects to the Pro Micro RXD pin. This works for my the sketch I was using as well as other test cases of mine.
    – KC Tucker
    Apr 2, 2017 at 20:58
  • Have you seen the Q&A on providing adequate power? The HC-12 needs more than 100 mA to work, into the Vin, for all types of Arduino.. It will not work at all if the power is only coming from a USB port. Have you tried this? arduino.stackexchange.com/questions/33668/…
    – SDsolar
    Sep 29, 2017 at 8:54

1 Answer 1

0

Solution to problem is as follows: For the Arduino Pro Micro [as for the Leonardo], Serial1 must be used instead of a SoftwareSerial specification, e.g.,

SoftwareSerial HC12(HC12TxdPin, HC12RxdPin).

Code is to be modified by changing HC12.available() to Serial1.available(). The same holds true for the reads and writes. Pins are to be wired such that the HC-12 RXD pin connects to the Pro Micro TXD pin, and the HC-12 TXD pin connects to the Pro Micro RXD pin. My thanks to @mico for providing the reference that explains it all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.