My project use 2 Node MCU ( Node MCU 1 and Node MCU 2).Node MCU 2 revieved the sensor value from Photoresister(@A0 Pin).But If don’not edit code and run code following below
Haha I’m weak in English I want to use sensor value @A0 pin form Node MCU 2 to controll PWM @ D2 pin in Node MCU 1 But I dob’t Know to Edit my code? what should I do.
Now I want to use the value from V5 pin to program in void loop .In this case I use V4 pin to connect between 2 loop BLYNK_WRITE(V5){…} loop and void loop{…} loop. But when slide V5 in app to 255 V4 does not respond .
What should I do.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "cc0e05e8371e4a858e07c69c611116dd";
int sensorPin = A0;
int sensorValue =0;
WidgetBridge bridge1(V1);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "Connectify-", "ap1234567");
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("2a97e454d9de4fd791844b92bae8a7e9"); // Token of the hardware B
}
BLYNK_WRITE(V5)
{
int value = param.asInt();
Serial.print("V5 value in loop ;");
Serial.println(value);
Blynk.virtualWrite(V4, value);
}
void loop()
{
int sensorValue = analogRead(sensorPin);
Serial.println("sensorValue MAIN loop ;");
Serial.println(sensorValue);
bridge1.analogWrite(4,sensorValue);
int value1=analogRead(V4);
Serial.println("V4 value OUT loop ;");
Serial.println(value1);
Blynk.run();
}
@ap10127700 before I look at your code can you please confirm you have the Bridge widget in each of the projects on the Smartphone.
Also:
Why have you got more than 2 lines in the loop() when almost all the Blynk examples only have 2?
Do you know what SimpleTimer is, i.e. one of the 4 libraries that you must install (manually) if you want to use Blynk for anything more than blinking an LED?
Why is you sketch so badly commented, what is V4 , V5, hardware A, hardware B?
1.Get sensor (Analog input) value and sent this value to device B to dimming RED LED(@D2 PIn)--------complete
2.Get the value from BLYNK_WRITE(V5) and promgram for automatic dimming and command automatic dimming to DEVICE B to BLUE LED (@D3 Pin) I will add BLUE LED in future
-------------------------------------------------------------------------------------------------------------------------------------------not complete!!!
(I want to program automatic dimming in void loop use the value from V5 Pin in DEVICE A)
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "cc0e05e8371e4a858e07c69c611116dd";
int sensorPin = A0;
int sensorValue =0;
WidgetBridge bridge1(V1);
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "Connectify-", "ap1234567");
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("2a97e454d9de4fd791844b92bae8a7e9"); // Token of the hardware B
}
BLYNK_WRITE(V5)
{
int value = param.asInt();
Serial.print("V5 value in loop ;");
Serial.println(value);
Blynk.virtualWrite(V4, value);
}
void loop()
{
int sensorValue = analogRead(sensorPin);
Serial.println("sensorValue MAIN loop ;");
Serial.println(sensorValue);
bridge1.analogWrite(4,sensorValue);
int value1=analogRead(V4);
Serial.println("V4 value OUT loop ;");
Serial.println(value1);
Blynk.run();
}
DEVICE B
1.GET value from DEVIE A to dimming RED and BLUE LED
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "2a97e454d9de4fd791844b92bae8a7e9";
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, "Connectify-", "ap1234567");
}
void loop()
{
Blynk.run();
}
BLYNK_WRITE(V5){
int pinData = param.asInt(); // pinData variable will store value that came via Bridge
if(pinData == 1){
// do something
}
else{
// do something different
}
}
You can pass integers, double, floats and strings.
Do not consider putting any of this, or anything else in loop().
With SimpleTimer and an interval of say 500ms call a function such as this:
void checkV5(){
Blynk.syncVirtualV5); // this "refreshes" V5
}
If you are physically connecting device A with device B you don’t actually need bridge but it is probably useful for you to learn how it works.