mbed Weather Platform post to Pachube

Dependencies:   mbed NetServices

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SHT.h Source File

SHT.h

00001 /* mbed module to use a Sensirion SHT1x /SHT7x sensor
00002  * Copyright (c) 2007-2009 Stephen McGarry
00003  * Released under the MIT License: http://mbed.org/license/mit
00004  */
00005 #ifndef SHT_H
00006 #define SHT_H
00007 
00008 #include "mbed.h"
00009 
00010 enum SHT_acc {
00011     SHT_low=0,
00012     SHT_high=1
00013 };
00014 
00015 typedef unsigned char byte;
00016 
00017 class SHT : public Base {
00018 public:
00019     /* Constructor: SHT
00020      *  Creates an SHT interface connected to specific pins.
00021      *
00022      */
00023     SHT(PinName p_sclk, PinName p_data, SHT_acc p_accuracy);
00024 
00025     /* Functions
00026      */
00027     float get_temperature();     // get the most recent temp reading
00028     float get_humidity();        // get the most recent humidity reading
00029     float get_dewpoint();        // get the most recent dewpoint value
00030     void update(SHT_acc accuracy); // update stored values from sensor
00031 
00032 protected:
00033     byte read_byte(bool send_ack);
00034     char write_byte(byte value);
00035     void trans_start(void);
00036     void connection_reset(void);
00037     char soft_reset();
00038     char read_status(byte &value);
00039     char write_status(byte value);
00040     char measure(int &value, byte mode);
00041     void calculate();
00042 
00043     DigitalOut sclk;
00044     DigitalInOut data;
00045     SHT_acc accuracy;    // will we use high or low accuracy mode on the sensor
00046 
00047     float temperature;    // calculated from sensor reading
00048     float humidity;
00049     float dewpoint;
00050     int temp,hum;        // integer values from sensor before conversion
00051 
00052     enum commands {
00053         com_read_status_reg=0x06,
00054         com_write_status_reg=0x07,
00055         com_measure_temp=0x03,
00056         com_measure_humid=0x05,
00057         com_reset=0x1E
00058     };
00059 
00060     enum acks {
00061         no_ack=0,
00062         send_ack=1
00063     };
00064 };
00065 
00066 #endif