BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

"Keep your void loop() clean" code not showing any data!

Using Arduino IDE and ESP32.
Iphone 6 iOS 14.2
Blynk Server (I think)
Blynk Library 0.6.1
Example is using
Board ESP32
Connection ESP32 WiFi
Auth Token left empty
Example Push data
Using code from “Keep you void loop() clean”, Blynk logo and then data from sensorValue is written to Serial Monitor, but nothing seems to appear in the Blynk App. I think I have followed what was said in the example
This is my first go, so maybe I don’t understand the app - apologies!
Blynk App is called Testing and just shows a blank screen under the green header.

code:

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "SagGBdQ5-2Pv3T9cuCbB_77hY0drmutM";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "BT-25AHS2";
char pass[] = "*******"; // my actual pWord entered here; not included for safety!

int sensorValue;

BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  sensorValue = analogRead(A5);
  Blynk.virtualWrite(V5, millis() / 1000);
  Serial.print("Sensor is: ");
  Serial.println(sensorValue);
}

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", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer
}

What widgets have you added to your project, and what pins are they attached to?

Pete.

None and None!
I was allowing pin A5 to float (it reads “0” on the serial monitor). Don’t yet know about widgets, thought I would just get the App showing something first.

I fear I am missing something very simple about the app!

I’ve added a Value display set to V5.
Added code

  Blynk.virtualWrite(V5, "5");

thinking that this would display “5” in the Blynk app screen. But it’s blank.

What am I missing?

It depends where you’ve put that piece of code.
The code you posted earlier expects a value or labelled value widget on V5 and it writes the elapsed time in seconds since the board was booted-up to this pin…

This code is called by a timer once a second, so the seconds count should increment once per second.

Is the app showing as connected, and have you put the app in ‘play’ mode?

Pete.

Oh how dim!

I didn’t actually set the Value Widget to V5.
When I added it, I saw “PIN” next to a dark grey box with ‘0’ in it, then there is a green wavy line to another box with ‘1023’ (I assume that’s the maximum number allowed). So I set the first grey box to 5.
Just occurred to me that that might just be the starting number or something, so I touched the PIN box and Lo and Behold, saw the options.
Now it is displaying properly!!!

Is there a way to resize the ValueDisplay? It doesn’t seem to let me.

If I add a new one there are 2 green dots, but if I drag them larger they just spring back

The value widget can be resisted to the full width of the screen, the granularity is quite coarse, so only about 4 positions where it will ‘stick’.
A long press will make the handles appear in iOS.

Pete.