Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / HIH-4030 Programming question on: June 10, 2013, 02:28:23 pm
Hi,

Sorry if I'm asking stupid questions, but I don't understand. I could use some help.

I'm doing a project where I am reporting the relative humidity and then sending that value to Xively data logging website. https://xively.com. I'm able to successfully connect to the website and send it data. However the data that I'm sending to the site is the raw data from the sensor. A raw value may look like anywhere from 375 to 650. I want to send a value like 47% relative humidity. In the code its calculating the voltage and relative humidity and displaying in the serial monitor, it's just not being sent to the website, which is what I want. How do I send to Xively the relative humidty value?
The serial monitor displays the following text.

Starting single datastream upload to Xively...
Read sensor value 635.00

Uncalibrated: Sensor Voltage = 2.59V Relative Humidity = 52.73%
Calibrated: Uploading to Xivelyxivelyclient.put returned200


Thanks,

Chris

2  Using Arduino / Programming Questions / HIH-4030 on: June 10, 2013, 09:54:13 am
Hi,

Sorry if I'm asking stupid questions, but I don't understand. I could use some help.

I'm doing a project where I am reporting the relative humidity and then sending that value to Xively data logging website. https://xively.com. I'm able to successfully connect to the website and send it data. However the data that I'm sending to the site is the raw data from the sensor. A raw value may look like anywhere from 375 to 650. I want to send a value like 47% relative humidity. In the code its calculating the voltage and relative humidity and displaying in the serial monitor, it's just not being sent to the website, which is what I want. How do I send to Xively the relative humidty value?

The serial monitor displays the following text.

Starting single datastream upload to Xively...
Read sensor value 635.00

Uncalibrated: Sensor Voltage = 2.59V Relative Humidity = 52.73%
Calibrated: Uploading to Xivelyxivelyclient.put returned200


Thanks,

Chris

3  Using Arduino / Sensors / Re: HIH-4030 Humidity Sensor - need help assigning a fixed temp value on: January 25, 2013, 10:40:36 am

Any idea if you use the Pachube client code and make some tweaks would it work with Cosm.com, which is the newer version of Pachube?
Has anyone tried this?

Thanks,

Chris
4  Using Arduino / Sensors / Re: HIH-4030 Humidity Sensor - need help assigning a fixed temp value on: January 18, 2013, 11:58:45 am


Found a library for the HIH4030 sensor.

http://angryelectron.com/hih4030-libs/ <--details are here.

https://github.com/angryelectron/tweetpot/tree/master/arduino/HIH4030 <--library and documentation located here.

5  Using Arduino / Sensors / HIH-4030 Humidity Sensor - need help assigning a fixed temp value on: January 17, 2013, 11:35:56 pm

Hi,

I'm new to programming hence my confusion.

I'm using the HIH-4030 relative humidity sensor with an Arduino Uno an Ethernet shield and feeding the data to Cosm.com. The values that the sensor is returning don't make sense. It's been ranging from 600-800. I found some sample code on a website that Sparkfun linked to where they used a fix temperature value to calculate the relative humidity. Below I've included that code in the Code 1 section.

In the section Code 2 below that's the code I'm currently using to stream data to Cosm. How can I combine the fixed temperature value from Code 1 to the code in Code 2? If someone would be willing to explain I'd greatly appreciate it.

Thanks for the help

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Code 1

//From the bildr article http://bildr.org/2012/11/hih4030-arduino/

int HIH4030_Pin = A0; //analog pin 0

void setup(){
Serial.begin(9600);
}

void loop(){

//To properly caculate relative humidity, we need the temperature.
float temperature = 25; //replace with a thermometer reading if you have it
float relativeHumidity = getHumidity(temperature);

Serial.println(relativeHumidity);

delay(100); //just here to slow it down so you can read it
}

float getHumidity(float degreesCelsius){
//caculate relative humidity
float supplyVolt = 5.0;

// read the value from the sensor:
int HIH4030_Value = analogRead(HIH4030_Pin);
float voltage = HIH4030_Value/1023. * supplyVolt; // convert to voltage value

// convert the voltage to a relative humidity
// - the equation is derived from the HIH-4030/31 datasheet
// - it is not calibrated to your individual sensor
// Table 2 of the sheet shows the may deviate from this line
float sensorRH = 161.0 * voltage / supplyVolt - 25.8;
float trueRH = sensorRH / (1.0546 - 0.0026 * degreesCelsius); //temperature adjustment

return trueRH;
}

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Code 2

/**
* Cosm Arduino sensor client example.
*
* This sketch demonstrates connecting an Arduino to Cosm (https://cosm.com),
* using the new Arduino library to send and receive data.
*
* Requirements
* * Arduino with Ethernet shield or Arduino Ethernet (board must use the
* Wiznet Ethernet chipset)
* * Arduino software with version >= 1.0
* * An account at Cosm (https://cosm.com)
*
* Optional
* * An analog sensor connected to pin 2 (note we can still read a value from
* the pin without this)
*
* Created 8th January, 2013 using code written by Adrian McEwen with
* modifications by Sam Mulube
*
* Full tutorial available here: https://cosm.com/docs/quickstart/arduino.html
*
* This code is in the public domain.
*/

#include <SPI.h>
#include <Ethernet.h>
#include <HttpClient.h>
#include <Cosm.h>

#define API_KEY "key goes here" // your Cosm API key
#define FEED_ID ##### // your Cosm feed ID

// MAC address for your Ethernet shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
int sensorPin = 2;

unsigned long lastConnectionTime = 0; // last time we connected to Cosm
const unsigned long connectionInterval = 15000; // delay between connecting to Cosm in milliseconds

// Initialize the Cosm library

// Define the string for our datastream ID
char sensorId[] = "sensor_reading";

CosmDatastream datastreams[] = {
CosmDatastream(sensorId, strlen(sensorId), DATASTREAM_FLOAT),
};

// Wrap the datastream into a feed
CosmFeed feed(FEED_ID, datastreams, 1 /* number of datastreams */);

EthernetClient client;
CosmClient cosmclient(client);

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);

Serial.println("Cosm Sensor Client Example");
Serial.println("==========================");

Serial.println("Initializing network");
while (Ethernet.begin(mac) != 1) {
Serial.println("Error getting IP address via DHCP, trying again...");
delay(15000);
}

Serial.println("Network initialized");
Serial.println();
}

void loop() {
// main program loop
if (millis() - lastConnectionTime > connectionInterval) {
// read a value from the pin
int sensorValue = analogRead(sensorPin);
// send it to Cosm
sendData(sensorValue);
// read the datastream back from Cosm
getData();
// update connection time so we wait before connecting again
lastConnectionTime = millis();
}
}

// send the supplied value to Cosm, printing some debug information as we go
void sendData(int sensorValue) {
datastreams[0].setFloat(sensorValue);

Serial.print("Read sensor value ");
Serial.println(datastreams[0].getFloat());

Serial.println("Uploading to Cosm");
int ret = cosmclient.put(feed, API_KEY);
Serial.print("PUT return code: ");
Serial.println(ret);

Serial.println();
}

// get the value of the datastream from Cosm, printing out the value we received
void getData() {
Serial.println("Reading data from Cosm");

int ret = cosmclient.get(feed, API_KEY);
Serial.print("GET return code: ");
Serial.println(ret);

if (ret > 0) {
Serial.print("Datastream is: ");
Serial.println(feed[0]);

Serial.print("Sensor value is: ");
Serial.println(feed[0].getFloat());
}

Serial.println();
}
Pages: [1]