Blynk..BME280...ESP32.. reading data from "Virtual pins" SDA/SCL I2C

I have done my research, but it is limited based on my knowledge (and very basic understanding) and I have been at this for “too long” with out any results.

I will gladly help you understand what “Volumetric efficiency” is as it relates to an internal combustion engine, naturally aspirated or forced induction if you can help me (LOL)

This is a code that I pieced together… I removed most of my Blynk statements because they would not work.

I am simply trying to figure out this whole “virtual PIN” deal and I am losing my mind! The wording is “confusing” especially when you know very little programming…

I can see all my data on the serial port… but I am having trouble getting them to show up on my Blynk app.

I am a “car” guy that is trying to learn the basic programming stuff just to “tinker”…

I am attempting to monitor my environment and see the data just to get an idea of how all this IOT stuff works…

#include <Wire.h>
#include "Adafruit_VEML6070.h"
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
unsigned long delayTime;
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = "1";
char ssid[] = "1";
char pass[] = "1";
Adafruit_VEML6070 uv = Adafruit_VEML6070();
#include <SimpleDHT.h>
int pinDHT22 = 5;
SimpleDHT22 dht22(pinDHT22);
void setup() {

  Blynk.begin(auth, ssid, pass);
  bool status;
  status = bme.begin(0x76);
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  Serial.println("-- Default Test --");
  delayTime = 1000;
  Serial.println("VEML6070 Test");
  uv.begin(VEML6070_1_T);  // pass in the integration time constant
void loop() {
  Serial.println("Sample DHT22...");
  float temperature = 0;
  float humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read2(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    Serial.print("Read DHT22 failed, err="); Serial.println(err);delay(500);
  Blynk.virtualWrite(V5, bme.readHumidity());
  Blynk.virtualWrite(V6, 1.8 * bme.readTemperature() + 32);
  Blynk.virtualWrite(V7, bme.readAltitude(SEALEVELPRESSURE_HPA));
  Blynk.virtualWrite(V8, bme.readPressure() / 100.0F);
  Blynk.virtualWrite(V9, uv.readUV());
  Blynk.virtualWrite(V10, (float)temperature);
  Blynk.virtualWrite(V11, (float)humidity);
void printValues() {
  Serial.print("Temperature = ");
  Serial.print(1.8 * bme.readTemperature() + 32);
  Serial.println(" *F");
  Serial.print("Pressure = ");
  Serial.print(bme.readPressure() / 100.0F);
  Serial.println(" hPa");
  Serial.print("Approx. Altitude = ");
  Serial.println(" m");
  Serial.print("Humidity = ");
  Serial.println(" %");
  Serial.print("UV light level: "); Serial.println(uv.readUV());


I am trying to add all the correct info before i get “Virtually SLAPPED” for my lack of experience…

My BME280 is wired for I2C… How do i get the data to my Virtual pins

I am confused on how to retrieve the DATA on my Blynk app

Hi James,

Please edit your original post (little pencil at bottom of post) - add three “backtick” character before and after your code (```cpp) - this will format the code and make it MUCH easier to read.

Thanks bill… especially for saying it so “nicely” LOL

1 Like

It’s promising that you have your BME280 working to Serial.print. Good.

Now you simply Write the same data to a Virtual pin, on a widget, on your Blynk App.

I assume you have made a basic Blynk Project (on the APP); with a number of display widgets? Each of these widgets should be assigned a unique Virtual PIn.

In your ESP32 code, you then write the value yo need to the allocated Virtual Pin.

eg: Blynk.virtualWrite(V5, bme.readHumidity());

Things to check in your Blynk Project:

  1. That you have selected the correct device in Project Settings (ESP32)
  2. That you have assigned Virtual pins for each widget.


The reformatting didnt take :wink:

Check out this guide . .


hehe NP, I remember when I start with Blynk . . . once you “get” it it’s actually very straightforward. get the first couple of widgets working and you’re away!

Thanks again Bill…

Just to see what happened i added “Blynk.virtualWrite(V5, bme.readHumidity());”

I get a code that says “Blynk does not name a type” when i try to upload… is there something else I need to add?

Oops… I put it in the wrong location … I am fixing it NOW and I am putting down my MARGARITA !!!

Thanks BILL !!!

Once you get the writing to Virtual pins done, you’ll need to clean up your code by removing from your void loop();

Blynk doesn’t work well with delays. It’s easily done with timers, but thats for another day . . .

@James007Moore despite Bill asking you nicely (twice), you still have not formatted your code correctly.
You have commas at the beginning and end, not backticks.
Please edit your code and use the correct symbols. They look like this, and if you’re struggling to fine the correct character in your keyboard (its probably above the tab key) the just copy and paste these characters:

Note that the triple backticks need to be on a line of their own, above and below the block of code.


Thank you Pete… I didnt even know that “character” existed on the keyboard.

You are an extremely helpful person and you are very much appreciated!

The sketch has been updated and I can see (some) Data on my blynk app.

I know there are issues with “delays” as well as a few other things…I am interested in learning how to clean up this sketch and gather better data.

I am using this to monitor a home HVAC system and I used a variety of sensors for comparison and learning.

ESP32 Dev kit

If you read this document you’ll understand how to avoid using delays and how to move the stuff out of your void loop…


Thank you … and GOOD MORNING :cowboy_hat_face:

As far as sensors are concerned, I like the BME280, It’s certainly much better than the DHT range.

Hopefully you’ve worked-out that (when you’re displaying data) its best to treat the Blynk widgets like the serial monitor. You do your data collection and analysis in your code running on the ESP, then write it out to the widget(s) via a virtual pin. Don’t try to do more than 10 virtual writes per second, but if you’re measuring temperature and humidity then taking a reading every 5-10 seconds is usually more than adequate. Obviously, using a timer to call the routine that takes the reading and writes that to Blynk and/or the serial monitor is the way to structure the code.