Was wondering if someone can help me? I’ve just started trying virtual pin codes and have uploaded -hardware sync state from app- off blynk example page but can’t get it working?
I can connect ok as i can switch onboard LED on and off but that’s all? what am I doing
wrong? Hardware is wemos D1 would appreciate any help!
@jeff10 did you mod the example from Ethernet use to ESP use?
Better to use Sketch Builder than the IDE examples as you can select which connection method you are using and the sketch provided covers all the required mods.
Paste your sketch.
Hey thanks for the response, Im getting connection as I can turn onboard LED on and off
code i’m using below
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "";
char pass[] = "";
// Keep this flag not to re-sync on every reconnection
bool isFirstConnect = true;
// This function will run every time Blynk connection is established
BLYNK_CONNECTED() {
if (isFirstConnect) {
// Request Blynk server to re-send latest values for all pins
Blynk.syncAll();
// You can also update individual virtual pins like this:
//Blynk.syncVirtual(V0, V2);
isFirstConnect = false;
}
// Let's write your hardware uptime to Virtual Pin 2
int value = millis() / 1000;
Blynk.virtualWrite(V2, value);
}
BLYNK_WRITE(V0)
{
// Use of syncAll() will cause this function to be called
// Parameter holds last slider value
int sliderValue0 = param.asInt();
}
BLYNK_WRITE(V2)
{
// You'll get uptime value here as result of syncAll()
int uptime = param.asInt();
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
}
The way it should work if you have all the widgets set up correctly is that uptime will be written to the server when you first compile the sketch. Once you have made the Blynk connection if you press the reset button on the WeMos the value will be retrieved from the server and be incremented by a few seconds .
Each reset will add a few seconds to the uptime but it’s not set to increase whilst the sketch is running, just once at each reset.
I think I’ve set my app widgets correctly as the sketch advises, I am getting some random
value on my Value Display on Blynk app? not sure what that’s about?
Project setup in the Blynk app:
Slider widget (0…1024) on V0
Value display (0…1024) on V2
Button widget on digital pin (connected to an LED)
Ah yes if value display is set with the standard READING FREQUENCY of 1s it will update the uptime. Many users have the frequency set to PUSH and control the widgets from the sketch.
Hi the uploaded sketch is from sketch builder also app is running on iPhone 6 .Yes I’ve tried on the app at 1 second frequency and with push mode and also tried with a different reading frequency time in sketch and app and also tried
different hardware.Please help