So you're a Noob? Post your questions here until you graduate! Don't be shy.
User avatar
By ionu
#64493 I am trying to send a simple msg from an arduino+HC-12 to a NodeMcu V1.0 a2-e + HC-12. Nothing happens. Any suggestions please?

My code for both is:
Code: Select all#include <SoftwareSerial.h>

SoftwareSerial mySerial(7,8 ); //RX, TX

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
}

void loop() {
  if(Serial.available() > 0){//Read from serial monitor and send over HC-12
    String input = Serial.readString();
    mySerial.println(input);   
  }
 
  if(mySerial.available() > 1){//Read from HC-12 and send to serial monitor
    String input = mySerial.readString();
    Serial.println(input);   
  }
  delay(2000);
}


Schmatics
Image
Image
User avatar
By daniel_ezsbc
#64563 Since you put this in the newbie section I'll try to explain why it won't ever work (reliably). You have an HC12 receiver connected to the UART pins of the ESP8266 without any means of ensuring that you don't send junk to the ESP8266. By junk I include noise from the rf when you are not transmitting. How do you guarantee that the signal you send to the ESP8266 is high (the required default for the UART input) when there's no data on the readio channel? How do you guarantee that the radio channel doesn't break the bit timing of the data that you send? What happens to the ESP8266 when noise changes a valid command to an unrecognised command?

What is the default baud rate of the ESP8266? Are you sure its 9600 bps? The HC-12 is half-duplex, the ESP8266 is full-duplex so some things are going to get lost at least some of the time.

To have a chance of making this work you should begin by removing the radios between the Arduino and the ESP8266 and get that working so that you know you are speaking to the ESP8266 in the correct way. Then you can remove the ESP8266 and put the radios back with an arduino in place of the 8266 and see that the radio link works. Then you can attach the ESP8266 to the arduino and debug that setup.

It's the easiest to write the code for the Arduino and HC-12 directly on the ESP8266 and completely bypass the HC-12.
User avatar
By ionu
#64663 Ok I think I see what you are saying.

One cannot interface directly from the ESP8266 to the HC-12. I have tested communication with x2 Arduino and HC-12 setups and they work. Was hoping to use the ESP8266 mcu part to avoid using the Arduino but it appears you are indicating that one would need an Arduino between the NodeMcu and the HC-12 for this to work?

Thanks for your reply
User avatar
By MildaGenius
#64715 Today successfully tested connection between Arduino Uno + HC12 and NodeMCU + HC12.

If you use the same code, you have wrong connection on NodeMCU side. For your connecting, you must change pins to 13, 15 in your code.

Check this:
http://www.esp8266.com/viewtopic.php?f=32&t=6602