Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: temp xj-Nucleo-F303K8-SHT75-TEST
sht75.h@0:f401474a3e96, 2010-10-27 (annotated)
- Committer:
- nimbusgb
- Date:
- Wed Oct 27 15:27:38 2010 +0000
- Revision:
- 0:f401474a3e96
0.8
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| nimbusgb | 0:f401474a3e96 | 1 | /* mbed Sensiron SHT7x temperature and humidity sensor library |
| nimbusgb | 0:f401474a3e96 | 2 | * |
| nimbusgb | 0:f401474a3e96 | 3 | * Sensiron data at http://www.sensirion.com/en/01_humidity_sensors/06_humidity_sensor_sht75.htm |
| nimbusgb | 0:f401474a3e96 | 4 | * |
| nimbusgb | 0:f401474a3e96 | 5 | * Copyright (c) Ian Molesworth October 2010 |
| nimbusgb | 0:f401474a3e96 | 6 | * |
| nimbusgb | 0:f401474a3e96 | 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| nimbusgb | 0:f401474a3e96 | 8 | * of this software and associated documentation files (the "Software"), to use |
| nimbusgb | 0:f401474a3e96 | 9 | * copy or modify the software for private or non-commercial purposes only. |
| nimbusgb | 0:f401474a3e96 | 10 | * |
| nimbusgb | 0:f401474a3e96 | 11 | * The above copyright notice and this permission notice shall be included in |
| nimbusgb | 0:f401474a3e96 | 12 | * all copies or substantial portions of the Software. |
| nimbusgb | 0:f401474a3e96 | 13 | * |
| nimbusgb | 0:f401474a3e96 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| nimbusgb | 0:f401474a3e96 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| nimbusgb | 0:f401474a3e96 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| nimbusgb | 0:f401474a3e96 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| nimbusgb | 0:f401474a3e96 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| nimbusgb | 0:f401474a3e96 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| nimbusgb | 0:f401474a3e96 | 20 | * THE SOFTWARE. |
| nimbusgb | 0:f401474a3e96 | 21 | */ |
| nimbusgb | 0:f401474a3e96 | 22 | |
| nimbusgb | 0:f401474a3e96 | 23 | |
| nimbusgb | 0:f401474a3e96 | 24 | #ifndef SHT75_H |
| nimbusgb | 0:f401474a3e96 | 25 | #define SHT75_H |
| nimbusgb | 0:f401474a3e96 | 26 | |
| nimbusgb | 0:f401474a3e96 | 27 | #include "mbed.h" |
| nimbusgb | 0:f401474a3e96 | 28 | |
| nimbusgb | 0:f401474a3e96 | 29 | const float C1= -4.0; // for 12 Bit humi |
| nimbusgb | 0:f401474a3e96 | 30 | const float C2= +0.0405; // for 12 Bit humi |
| nimbusgb | 0:f401474a3e96 | 31 | const float C3= -0.0000028; // for 12 Bit hum |
| nimbusgb | 0:f401474a3e96 | 32 | const float TL= -39.61; // 3v 14 bit |
| nimbusgb | 0:f401474a3e96 | 33 | const float T1= +0.01; // for 14 Bit @ 5V |
| nimbusgb | 0:f401474a3e96 | 34 | const float T2= +0.00008; // for 14 Bit @ 5V |
| nimbusgb | 0:f401474a3e96 | 35 | |
| nimbusgb | 0:f401474a3e96 | 36 | class SHT75 |
| nimbusgb | 0:f401474a3e96 | 37 | { |
| nimbusgb | 0:f401474a3e96 | 38 | public: |
| nimbusgb | 0:f401474a3e96 | 39 | /** Create an SHT object connected to the specified Digital pins |
| nimbusgb | 0:f401474a3e96 | 40 | * |
| nimbusgb | 0:f401474a3e96 | 41 | * @param pclock digital pin to use as clock |
| nimbusgb | 0:f401474a3e96 | 42 | * @param pdata digital pin to use as data bus ( bidirectional ) |
| nimbusgb | 0:f401474a3e96 | 43 | */ |
| nimbusgb | 0:f401474a3e96 | 44 | SHT75(PinName pclock, PinName pdata): _clock(pclock), _data(pdata) {}; |
| nimbusgb | 0:f401474a3e96 | 45 | /** read the temperature ticks value 14 bit resolution |
| nimbusgb | 0:f401474a3e96 | 46 | * |
| nimbusgb | 0:f401474a3e96 | 47 | * @param int *temp pointer to an integer to hold the tick value |
| nimbusgb | 0:f401474a3e96 | 48 | * @returns boolean true if read acknowledges |
| nimbusgb | 0:f401474a3e96 | 49 | */ |
| nimbusgb | 0:f401474a3e96 | 50 | bool readTempTicks(int* temp); |
| nimbusgb | 0:f401474a3e96 | 51 | /** read the humidity ticks value 12 bit resolution |
| nimbusgb | 0:f401474a3e96 | 52 | * |
| nimbusgb | 0:f401474a3e96 | 53 | * @param int *temp pointer to an integer to hold the tick value |
| nimbusgb | 0:f401474a3e96 | 54 | * @returns boolean true if read acknowledges |
| nimbusgb | 0:f401474a3e96 | 55 | */ |
| nimbusgb | 0:f401474a3e96 | 56 | bool readHumidityTicks(int* temp); |
| nimbusgb | 0:f401474a3e96 | 57 | /** start up reset |
| nimbusgb | 0:f401474a3e96 | 58 | * |
| nimbusgb | 0:f401474a3e96 | 59 | * call to resync or abort current operation. |
| nimbusgb | 0:f401474a3e96 | 60 | * worth calling every now and then to make sure your system is not hung. |
| nimbusgb | 0:f401474a3e96 | 61 | */ |
| nimbusgb | 0:f401474a3e96 | 62 | void reset(void); |
| nimbusgb | 0:f401474a3e96 | 63 | void softReset(void); |
| nimbusgb | 0:f401474a3e96 | 64 | int readStatus(void); |
| nimbusgb | 0:f401474a3e96 | 65 | |
| nimbusgb | 0:f401474a3e96 | 66 | private: |
| nimbusgb | 0:f401474a3e96 | 67 | DigitalInOut _data; |
| nimbusgb | 0:f401474a3e96 | 68 | DigitalOut _clock; |
| nimbusgb | 0:f401474a3e96 | 69 | |
| nimbusgb | 0:f401474a3e96 | 70 | void start(void); |
| nimbusgb | 0:f401474a3e96 | 71 | int read(char); |
| nimbusgb | 0:f401474a3e96 | 72 | bool write(char); |
| nimbusgb | 0:f401474a3e96 | 73 | }; |
| nimbusgb | 0:f401474a3e96 | 74 | |
| nimbusgb | 0:f401474a3e96 | 75 | #endif |