I have written the some sample code, I know I have a connection to Blynk dashboard, I know my SHTC3 read, and print is working (I also know the code is working as extracted from an INflux DB example program i wrote).
However when I pass this to the Blynk write function
Blynk.virtualWrite(V0, temperature); // Virtual pin V0 for temperature
Blynk.virtualWrite(V1, humidity.relative_humidity); // Virtual pin V1 for humidity
I do not see the values for temperature and Humidty. all I get is 1 (Which is what I see coming through on the blynk dashboard.) I also proved this by printing to the serial port the value of V0 and V1 both come back as 1.
I am guessing there is a configuration issue? or is there a different blynk function?
ESP32, Code written under VSCODE platformIO.
I doubt its any version issue?
Read this before creating new topic:
#define BLYNK_TEMPLATE_ID "TMPL5sgXXht3-"
#define BLYNK_TEMPLATE_NAME "RH"
#define BLYNK_AUTH_TOKEN "SQJ5kFVM1VbWPAaW8IYGxcFTsPjJE0oJ"
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_SHTC3.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
float temperature;
float humidity;
float humidityValue;
/*
#define BLYNK_FIRMWARE_VERSION "0.1.0"
#define BLYNK_PRINT Serial
*/
// SHTC3 sensor instance
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
// Blynk credentials
//char auth[] = "SQJ5kFVM1VbWPAaW8IYGxcFTsPjJE0oJ"; // Replace with your Blynk auth token
char ssid[] = "Heybroadband3"; // Replace with your WiFi SSID
char pass[] = "123123123"; // Replace with your WiFi password
Adafruit_SHTC3 gSHTC3Sensor;
bool setupSHTC3Sensor() {
if (!gSHTC3Sensor.begin()) {
Serial.println("SHTC3.begin() failed1st");
return false;
}
return true;
}
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
// Initialize Blynk
//Blynk.begin(auth, ssid, pass);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
// Initialize I2C and SHTC3 sensor
Wire.begin();
// Initialize SHTC3 sensor
if (!setupSHTC3Sensor()) {
Serial.println("Couldn't find SHTC3 sensor");
return;
} else {
Serial.println("Found SHTC3 sensor");
}
}
void loop() {
sensors_event_t humidity, temp;
//shtc3.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
//sensors_event_t humidity, temp;
if (gSHTC3Sensor.getEvent( &humidity, &temp)) {
// successful read, do something with the values:
Serial.print("Temp:"); Serial.print(temp.temperature); Serial.println(" degrees C");
Serial.print(" RH:"); Serial.print(humidity.relative_humidity); Serial.println("% rH");
}
temperature = temp.temperature;
humidityValue = humidity.relative_humidity;
// Print temperature and humidity to the Serial Monitor
Serial.print("Temperature: "); Serial.print(temp.temperature); Serial.println(" °C");
Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println(" %");
//Start Blynk run loop
Blynk.run();
// Send temperature and humidity to Blynk virtual pins
Blynk.virtualWrite(V0, temperature); // Virtual pin V0 for temperature
Blynk.virtualWrite(V1, humidity.relative_humidity); // Virtual pin V1 for humidity
Serial.print("blynk V0 " ); Serial.print(V0);
Serial.print(" Blynk V1 "); Serial.print(V1);
//
// Wait for 2 seconds before the next reading
delay(2000);
}