Hi All,
I am new to the particle system and C/C++ I come from a background in Fortran, VBA, and Python and figured I can pick up most of what I need from looking at working code and examples and modifying what I need. I am using the SparkFun HTU21D to read humidity and temperature. Tested the code on an Arduino board and the code works. I figured ok I get this. read up on publishing data to the cloud and the code lines needed. Well when I modified the code to reflect the what I thought was correct I do not get the same results as with the Arduino. instead I get 988.000. I did a second test were I just publish a integer “23” and that worked. Can someone help please. Below is the code that I modified in the sparkfun-htu21d-f.ino file
/*
HTU21D Humidity Sensor Example Code
By: Nathan Seidle
SparkFun Electronics
Date: September 15th, 2013
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
Uses the HTU21D library to display the current humidity and temperature
Open serial monitor at 9600 baud to see readings. Errors 998 if not sensor is detected. Error 999 if CRC is bad.
Hardware Connections (Breakoutboard to Arduino):
-VCC = 3.3V
-GND = GND
-SDA = A4 (use inline 330 ohm resistor if your board is 5V)
-SCL = A5 (use inline 330 ohm resistor if your board is 5V)
*/
#include <Wire.h>
#include "SparkFunHTU21D.h"
//Create an instance of the object
HTU21D myHumidity;
void setup()
{
Serial.begin(9600);
Serial.println("HTU21D Example!");
myHumidity.begin();
}
void loop()
{
float humd = myHumidity.readHumidity();
float temp = myHumidity.readTemperature();
//float temp1 = 5/9*(myHumidity.readTemperature()-32);
// Particle.publish(" time: ",millis, PUBLIC);
// Serial.print("Time:");
// Serial.print(millis());
Particle.publish(" Temperature:", (temp, 1), PUBLIC);
// Serial.print(" Temperature:");
// Serial.print(temp, 1);
// Serial.print("F");
Particle.publish("humidity", String(humd), PRIVATE);
// Serial.print(" Humidity:");
// Serial.print(humd, 1);
// Serial.print("%");
Serial.println();
delay(1000);
}