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**"); } } } }
#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);
}
}
}
Yes..you can definitely use bluetooth terminal application to transfer data from mobile to nodemcu.No problem
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!
Debasis Parida
PermalinkThe 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.
- Log in or register to post comments
Joined August 22, 2019 125Thursday at 12:29 PM