Weird/Wrong values for Particle Variables

For Real Alt and Blue Temp variables I get “(int32) = 536871936” when I click “get”.
I am using DHT11 Temperature and Humidy Sensor and BMP180 Barometer.
The Serial Output shows the correct values.
Help?

// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT.h"

// This #include statement was automatically added by the Particle IDE.

#if !defined(PARTICLE)
 #include <Wire.h>
#endif
#include <Adafruit_BMP085.h>

#define DHTPIN 2     // what pin we're connected to

#define DHTTYPE DHT11		// DHT 11 

// Connect VCC of the BMP085 sensor to 3.3V (NOT 5.0V!)
// Connect GND to Ground
// Connect SCL to i2c clock - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 5, Particle on D1
// Connect SDA to i2c data - on '168/'328 Arduino Uno/Duemilanove/etc thats Analog 4, Particle on D0
// EOC is not used, it signifies an end of conversion
// XCLR is a reset pin, also not used here

Adafruit_BMP085 bmp;
DHT dht(DHTPIN, DHTTYPE);

void callback(char* topic, byte* payload, unsigned int length);

int pres;
int alt;
double temp;
double humu;
int btemp;

void setup() {
  Serial.begin(9600);
  if (!bmp.begin()) {
	Serial.println("Could not find a valid BMP085 sensor, check wiring!");
	while (1) {}
  }
  dht.begin();
  Particle.variable("Pressure", pres);
  Particle.variable("Real Alt", alt);
  Particle.variable("BarTemp", temp);
  Particle.variable("Humidity", humu);
  Particle.variable("Blue Temp", btemp);
}
  
void loop() {
    Serial.print("Temperature = ");
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");
    
    Serial.print("Pressure = ");
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");
    
    // Calculate altitude assuming 'standard' barometric
    // pressure of 1013.25 millibar = 101325 Pascal
    Serial.print("Altitude = ");
    Serial.print(bmp.readAltitude());
    Serial.println(" meters");

    Serial.print("Pressure at sealevel (calculated) = ");
    Serial.print(bmp.readSealevelPressure());
    Serial.println(" Pa");

  // you can get a more precise measurement of altitude
  // if you know the current sea level pressure which will
  // vary with weather and such. If it is 1015 millibars
  // that is equal to 101500 Pascals.
    Serial.print("Real altitude = ");
    Serial.print(bmp.readAltitude(101500));
    Serial.println(" meters");
    
    Serial.println();
    float h = dht.getHumidity();
// Read temperature as Celsius
	float t = dht.getTempCelcius();
// Read temperature as Farenheit
	float f = dht.getTempFarenheit();
	float a = bmp.readAltitude(101500);
  
// Check if any reads failed and exit early (to try again).
	if (isnan(h) || isnan(t) || isnan(f)) {
		Serial.println("Failed to read from DHT sensor!");
		return;
	}

// Compute heat index
// Must send in temp in Fahrenheit!
	float hi = dht.getHeatIndex();
	float dp = dht.getDewPoint();
	float k = dht.getTempKelvin();
	
	
	Serial.print("Humid: "); 
	Serial.print(h);
	Serial.print("% - ");
	Serial.print("Temp: "); 
	Serial.print(t);
	Serial.print("*C ");
	Serial.print(f);
	Serial.print("*F ");
	Serial.print(k);
	Serial.print("*K - ");
	Serial.print("DewP: ");
	Serial.print(dp);
	Serial.print("*C - ");
	Serial.print("HeatI: ");
	Serial.print(hi);
	Serial.println("*C");
	Serial.println(Time.timeStr());
	
    pres = bmp.readPressure();
    alt = a;
    temp = bmp.readTemperature();
    humu = h;
    btemp = dht.getTempCelcius();
    delay(300);
}

How about reading the docs before posting on the forum?
https://docs.particle.io/reference/device-os/firmware/xenon/#particle-variable-

3 Likes

Oh wow, I guess i just didn’t read that part. Thanks!

1 Like

:joy: don’t feel bad about it. we’ve all been there :+1: