![](/media/cache/profiles/20200518_163046.jpg.50x50_q85.jpg)
Adafruit i2c SHT40 example
main.cpp@0:02e74947940b, 2022-02-07 (annotated)
- Committer:
- reedas
- Date:
- Mon Feb 07 15:12:28 2022 +0000
- Revision:
- 0:02e74947940b
Example project using SHT40 basic library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
reedas | 0:02e74947940b | 1 | /** Sample program to read temperature and humidity |
reedas | 0:02e74947940b | 2 | * |
reedas | 0:02e74947940b | 3 | * @author Alex Lipford |
reedas | 0:02e74947940b | 4 | * Georgia Institute of Technology |
reedas | 0:02e74947940b | 5 | * ECE 4180 Embeded Systems Design |
reedas | 0:02e74947940b | 6 | * Professor Hamblen |
reedas | 0:02e74947940b | 7 | * 10/19/2014 |
reedas | 0:02e74947940b | 8 | * |
reedas | 0:02e74947940b | 9 | * @section LICENSE |
reedas | 0:02e74947940b | 10 | * ---------------------------------------------------------------------------- |
reedas | 0:02e74947940b | 11 | * "THE BEER-WARE LICENSE" (Revision 42): |
reedas | 0:02e74947940b | 12 | * <alexlipford@gmail.com> wrote this file. As long as you retain this notice you |
reedas | 0:02e74947940b | 13 | * can do whatever you want with this stuff. If we meet some day, and you think |
reedas | 0:02e74947940b | 14 | * this stuff is worth it, you can buy me a beer in return. |
reedas | 0:02e74947940b | 15 | * ---------------------------------------------------------------------------- |
reedas | 0:02e74947940b | 16 | * |
reedas | 0:02e74947940b | 17 | * |
reedas | 0:02e74947940b | 18 | * @section DESCRIPTION |
reedas | 0:02e74947940b | 19 | * |
reedas | 0:02e74947940b | 20 | * Honeywell HTU21D Humidity and Temperature sensor. |
reedas | 0:02e74947940b | 21 | * |
reedas | 0:02e74947940b | 22 | * Datasheet, specs, and information: |
reedas | 0:02e74947940b | 23 | * |
reedas | 0:02e74947940b | 24 | * https://www.sparkfun.com/products/12064 |
reedas | 0:02e74947940b | 25 | */ |
reedas | 0:02e74947940b | 26 | |
reedas | 0:02e74947940b | 27 | #include "mbed.h" |
reedas | 0:02e74947940b | 28 | #include "SHT40.h" |
reedas | 0:02e74947940b | 29 | #include "platform/mbed_thread.h" |
reedas | 0:02e74947940b | 30 | |
reedas | 0:02e74947940b | 31 | SHT40 temphumid(P6_1, P6_0); //Temp humid sensor || SDA, SCL |
reedas | 0:02e74947940b | 32 | |
reedas | 0:02e74947940b | 33 | int tempC; |
reedas | 0:02e74947940b | 34 | int relHumid; |
reedas | 0:02e74947940b | 35 | |
reedas | 0:02e74947940b | 36 | int main() { |
reedas | 0:02e74947940b | 37 | printf("Starting humidity and temperature Sensor"); |
reedas | 0:02e74947940b | 38 | while(1) { |
reedas | 0:02e74947940b | 39 | tempC = temphumid.tempC(); |
reedas | 0:02e74947940b | 40 | thread_sleep_for(1000); |
reedas | 0:02e74947940b | 41 | relHumid = temphumid.relHumid(); |
reedas | 0:02e74947940b | 42 | printf("Temperature: %d C\n\r", tempC); |
reedas | 0:02e74947940b | 43 | printf("Reative Humidity: %d %%\n\r", relHumid); |
reedas | 0:02e74947940b | 44 | printf("\n\r"); |
reedas | 0:02e74947940b | 45 | thread_sleep_for(1000); |
reedas | 0:02e74947940b | 46 | } |
reedas | 0:02e74947940b | 47 | } |