Combining blynk code and Bluetooth codes to control one relay together

Submitted by Cjjjjjjj on

Hell how can I combine my code from blynk code to Bluetooth codes to control one relay, the relay is connected to nodemcu I just want to control it using blynk and Bluetooth terminal app is it possible? Thank you! Here's my code in blynk. #define BLYNK_PRINT Serial #include #include char auth[] = "xxxxxxx"; char ssid[] = "xxxxxxx"; char pass[] = "xxxxxxx"; void setup() { Serial.begin(9600); Blynk.begin(auth, ssid, pwd); } void loop() { Blynk.run(); Here's my code in Bluetooth. #include SoftwareSerial btSerial(D2, D3); // Rx,Tx void setup() { pinMode(11, OUTPUT); pinMode(10, OUTPUT); Serial.begin(9600) } void loop() { if (Serial.available() > 0) { char c = Serial.read(); if (c == 'a') { Serial.print("in a code"); digitalWrite(10,HIGH); digitalWrite(11,LOW); Serial.print("10 HIGH"); lcd.clear(); lcd.print("**BULB1 ON**"); } if(c=='b') { digitalWrite(11,HIGH); digitalWrite(10,LOW); Serial.print("11 HIGH"); lcd.clear(); lcd.print("**BULB2 ON**"); } if(c=='c') { digitalWrite(10,HIGH); digitalWrite(11,HIGH); lcd.clear(); lcd.print("**BULB 1,2 ON**"); } if(c=='d') { digitalWrite(10,LOW); digitalWrite(11,LOW); lcd.clear(); lcd.print("**BULB 1,2 OFF**"); } } } }

The bluetooth control code is correct.just merge the blynk control code to this.That means, send a data via a virtual terminal from blynk and receive it in your code, and as per that control the relay.

  Joined August 22, 2019      125
Thursday at 12:29 PM

Here's my blynk code
#define BLYNK_PRINT Serial
#include
#include
int Relay1 16; // D0 of nodemcu
int Relay2 5; // D1 of nodemcu
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pwd);
}

void loop()
{
Blynk.run();

}

  Joined February 21, 2020      7
Friday at 09:50 AM

Here's my blynk code
#define BLYNK_PRINT Serial
#include
#include
int Relay1 16; // D0 of nodemcu
int Relay2 5; // D1 of nodemcu
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pwd);
}

void loop()
{
Blynk.run();

}

  Joined February 21, 2020      7
Friday at 09:50 AM

Can we talk in email sir Debasis Parida?

  Joined February 21, 2020      7
Friday at 09:50 AM

#define BLYNK_PRINT Serial
#include
#include
int Relay1 16; // D0 of nodemcu
int Relay2 5; // D1 of nodemcu
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pwd);
}

void loop()
{
Blynk.run();

if(Serial.available>0)

{

char data=Serial.read();

if(data= ='a')

{

digitalWrite(16,HIGH);

}

else

{

digitalWrite(16,LOW);

}

}

}

  Joined August 22, 2019      125
Thursday at 12:29 PM

Can i use bluetooth terminal app sir?

  Joined February 21, 2020      7
Friday at 09:50 AM

Yes..you can definitely use bluetooth terminal application to transfer data from mobile to nodemcu.No problem

  Joined August 22, 2019      125
Thursday at 12:29 PM

Sir according to blynk community I need to use ESPSoftwareserial in order to use Bluetooth on nodemcu than the regular softwareserial but I don't know how to use the ESPSoftwareserial can you help me sir? Thank you!

  Joined February 21, 2020      7
Friday at 09:50 AM