0

I want to transfer analog readings i.e. variable values from a NodeMCU to an Arduino Uno so that on the Arduino side I can check those values using an if condition and make a buzzer sound. Please help with the connections of the RX and TX pin wires and also with the code.

NODEMCU CODE:

int mq6 = A0; 
int d = 0;
 
void setup() {
  Serial.begin(9600);
  Serial1.begin(9600);   
  pinMode(mq6, INPUT);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
}
     
void loop() {
  Blynk.run();
  d = analogRead(mq6);
  Serial.println();
  Serial.print(d);
  Blynk.virtualWrite(V0, d);
  Serial1.println(String(d));

  if (d > 500) {
    Blynk.logEvent("warning_leakage", "Temp above 30 degree");
  }      
}

ARDUINO CODE:

void setup() {
  // Serial Begin at 9600 Baud 
  Serial.begin(9600);
  Serial1.begin(9600);
}
    
void loop() {
  int d = Serial1.parseInt();
  Serial.println(d);
  delay(100);
}
5
  • what problem are you having?
    – jsotola
    Dec 28, 2022 at 7:49
  • put the code in Uno loop() into if (Serial1.available()) { so it doesn't print a 0 every second
    – Juraj
    Dec 28, 2022 at 8:13
  • you can't call Blynk write every loop. the Blynk server will block you
    – Juraj
    Dec 28, 2022 at 8:14
  • could you please give solution to it like by pointing out the changes that i have to do @Juraj
    – Tanishq C
    Dec 28, 2022 at 12:30
  • i need send my gas sensor readings from nodemcu to arduino board(Arduino uno R3) but in my arduino code it is thorwing error that Serial1 is not declared in the local scope. So could u please help me with code because i tried learning about SoftwareSerial but its hard to do one way communication between them.
    – Tanishq C
    Dec 28, 2022 at 12:33

0

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.

Browse other questions tagged or ask your own question.