Si7021 sparkfun Blynk Board

Hello,

I’m trying to convert si7021 code example to work with blynk. On Blynk app i’m able to see seconds counting, but temp and humidity values showing something wrong.

#include "Adafruit_Si7021.h"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

Adafruit_Si7021 sensor = Adafruit_Si7021();

char auth[] = "";
char ssid[] = "";
char pass[] = "";
BlynkTimer timer;
void myTimerEvent()

{
  sensor.begin();
  float temp = (sensor.readTemperature(), 2);
  float hum = (sensor.readHumidity(), 2);

  Blynk.virtualWrite(V5, millis() / 1000);
  Blynk.virtualWrite(V6, temp);
  Blynk.virtualWrite(V7, hum);
}
  
void setup() 
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(1000L, myTimerEvent);
}
void loop() 
{
  Blynk.run();
  timer.run(); // Initiates BlynkTimer  
 // Serial.print("Humidity:    "); Serial.print(sensor.readHumidity(), 2);
 // Serial.print("\tTemperature: "); Serial.println(sensor.readTemperature(), 2);
 // delay(1000);
}

Define “wrong”… No values? Constant but incorrect value? Variable but incorrect values compared to ambient? Random poetry quotes?

Is your sensor hooked up correctly?

PS sensor.begin() usually goes in the void setup() not called repeatedly in a loop.

1 Like

With this code i’m recieving %.3f every second,

i changed to this:

  int temp = sensor.readTemperature();
  int hum = sensor.readHumidity();

and it’s working fine, now. Thank you for support :slight_smile:

Glad you got it working. For others, visiting this thread -> You need to use the latest Blynk library and ESP8266 Arduino Core.

1 Like

I’m using Sparkfun Blynk board, and downloaded newest library. Or do i need additionally ESP8266 library? Because after download ESP8266 library in boards list no sparkfun blynk board was found.

thanx

@Evaldas_Narusis You can select NodeMCU board (it is very similar)