So you're a Noob? Post your questions here until you graduate! Don't be shy.
User avatar
By ionu
#64991 Thanks for the reply I only saw this today as it seem I am not getting the baord to tell me when someone replies.

MildaGenius wrote:For your connecting, you must change pins to 13, 15 in your code.


I do not see D13 or D15 or are your probably referring to GPIO13 & GPIO15?
Do you have a diagram for the NodeMcu wiring?

THanks
User avatar
By MildaGenius
#65074 According to private message from ionu, I add more specifications:

Arduino UNO code:
Code: Select all//HC-12 messenger send/receive
//autor Tom Heylen tomtomheylen.com

//UNO            HC-12
//10               TXD
//11               RXD
//5V               VCC
//GND            GND


#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);//RX, TX

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

  delay(50);
}

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

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


NodeMCU code:
Code: Select all//HC-12 messenger send/receive
//autor Tom Heylen tomtomheylen.com

//NodeMCU       HC-12
//D2                 TXD
//D3                 RXD
//3V3               VCC
//GND                GND

#include <SoftwareSerial.h>

SoftwareSerial mySerial(4, 0);//TX, RX on NodeMCU its pin D2 and D3

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

  delay(50);
}

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

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


I tested it on ArduinoMega too and there was problem, that some pins can do interruptions. So after changed to pin 10, 11 it starts working.

Because you use Arduino Mini, there should be the same problem. Try to use pins 2 and 3.
https://www.arduino.cc/en/Main/arduinoBoardProMini
User avatar
By MildaGenius
#65108
ionu wrote:Thanks for the reply I only saw this today as it seem I am not getting the baord to tell me when someone replies.

MildaGenius wrote:For your connecting, you must change pins to 13, 15 in your code.


I do not see D13 or D15 or are your probably referring to GPIO13 & GPIO15?
Do you have a diagram for the NodeMcu wiring?

THanks


You have connected HC-12 on NodeMCU to pins D7, D8 (according to your schema), which are in arduino code pins 13, 15 (GPIO).

So in NodeMCU code change this line from:
Code: Select allSoftwareSerial mySerial(7,8 ); //RX, TX


to:
Code: Select all// real GPIO pins
SoftwareSerial mySerial(13,15 ); //RX, TX


or:
Code: Select all//mapped GPIO pins to NodeMCU pins
SoftwareSerial mySerial(D7,D8 ); //RX, TX