SI7021 show full range temperature and humidity

Hi all. I want to showing full range of temperature and humidity in blynk. for example showing temp as 28.56 not only showing 28 or showing humidity 56.85% not only showing 56%. if anyone know how to solve please help.
thanks

the code I wrote:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

#include <Wire.h>
#include <SI7021.h>

float temp, hum;
bool SI7021_present = true;


#define I2C_SCL 12      
#define I2C_SDA 13
SI7021 sensor;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "16feb1e7ad784f77b0d83b26f22a4825";
char ssid[] = "MikroTik Home";
char pass[] = "12345678";
char server[] = "10.5.51.3";


SimpleTimer timer;

void setup()
{

  Wire.begin();
  sensor.begin(SDA,SCL);
  Wire.begin(I2C_SDA, I2C_SCL);
  Serial.begin(115200); // See the connection status in Serial Monitor
  Blynk.begin(auth, ssid, pass, server, 8080); //insert here your SSID and password
 
 timer.setInterval(1000L,sendUptime);

}

void sendUptime()
{
int temperature = sensor.getCelsiusHundredths()/100;
int humidity = sensor.getHumidityPercent();

Blynk.virtualWrite(5, temperature); // virtual pin
Blynk.virtualWrite(6, humidity); // virtual pin

}

void loop()
{
  Blynk.run();
  timer.run();
}

Well, you’re using integer variable types for your temp and humidity. So there will never be any decimal places. If you change to float variables and ensure that your widget is configured to display the desired decimal resolution then it should work correctly.

Pete.

1 Like

thanks for reply. OK I set to float but problem is not solved and now temp cannot be showing

the sketch:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

#include <Wire.h>
#include <SI7021.h>

float temp, hum;
bool SI7021_present = true;


#define I2C_SCL 12      // Barometric Pressure Sensor (BMP085)
#define I2C_SDA 13
SI7021 sensor;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "16feb1e7ad784f77b0d83b26f22a4825";
char ssid[] = "MikroTik Home";
char pass[] = "12345678";
char server[] = "10.5.51.3";


SimpleTimer timer;

void setup()
{

  Wire.begin();
  sensor.begin(SDA,SCL);
  Wire.begin(I2C_SDA, I2C_SCL);
  Serial.begin(115200); // See the connection status in Serial Monitor
  Blynk.begin(auth, ssid, pass, server, 8080); //insert here your SSID and password
 
 timer.setInterval(1000L,sendUptime);

}

void sendUptime()
{
float tempe = sensor.getCelsiusHundredths();
float hum = sensor.getHumidityPercent();

Blynk.virtualWrite(5, (float)temp/100, 2); 
Blynk.virtualWrite(6, hum); // virtual pin

}

void loop()
{
  Blynk.run();
  timer.run();
}

Which one? Tempe…or Temp? :wink:

1 Like

thanks. I changed that to temp. but temperature cannot be showing in widget :disappointed_relieved:

Damn it. thanks the problem is solved. thats working only with value display widget not working in gauge widget :heart_eyes:

what happens if you change this to:

Blynk.virtualWrite(5, temp/100); 

Pete.

1 Like

thanks. problem solved with value display widget.

1 Like