![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Drivers for temperature and humidity sensor SHF15. Modified for EDE_PRO2_team1
Fork of PRO2_SHT15_Example by
main.cpp@5:40f3f713bba0, 2017-05-10 (annotated)
- Committer:
- OlgaHoeyer
- Date:
- Wed May 10 20:14:37 2017 +0000
- Revision:
- 5:40f3f713bba0
- Parent:
- 4:6d85c470d101
minor changes:; { } around the user defined function and "return".; Updated libraries.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NegativeBlack | 0:f850dfb07e93 | 1 | /** |
OlgaHoeyer | 3:0759c60f116b | 2 | * Program for reading temperature and humidity from SHT15 |
OlgaHoeyer | 3:0759c60f116b | 3 | * Modified to fit to EDE Pro2 Team 1 project. |
OlgaHoeyer | 3:0759c60f116b | 4 | * Author Olga Høyer |
OlgaHoeyer | 3:0759c60f116b | 5 | * Original Copyright (c) 2010 Roy van Dam <roy@negative-black.org> |
OlgaHoeyer | 1:4c7450d9de9d | 6 | **/ |
NegativeBlack | 0:f850dfb07e93 | 7 | |
OlgaHoeyer | 3:0759c60f116b | 8 | #include "mbed.h" //NOTE. Compiler gives an error: |
OlgaHoeyer | 3:0759c60f116b | 9 | #include "SHTx/sht15.hpp" //"CMSIS Target not recognised" |
NegativeBlack | 0:f850dfb07e93 | 10 | |
OlgaHoeyer | 2:4fba73b78e1c | 11 | //GLOBAL VARIABLES: |
OlgaHoeyer | 4:6d85c470d101 | 12 | float temperature, humidity; //this will be data read from sensor |
OlgaHoeyer | 2:4fba73b78e1c | 13 | void GetTemperatureAndHumidity(); |
NegativeBlack | 0:f850dfb07e93 | 14 | |
OlgaHoeyer | 2:4fba73b78e1c | 15 | Serial pc(USBTX, USBRX); |
OlgaHoeyer | 2:4fba73b78e1c | 16 | DigitalOut busy(LED1); //Don't think we need it. |
OlgaHoeyer | 2:4fba73b78e1c | 17 | |
OlgaHoeyer | 2:4fba73b78e1c | 18 | //ports on the Nucleo: PB_8, PB_9 |
OlgaHoeyer | 2:4fba73b78e1c | 19 | SHTx::SHT15 sensor(PB_8, PB_9); |
OlgaHoeyer | 1:4c7450d9de9d | 20 | |
NegativeBlack | 0:f850dfb07e93 | 21 | |
NegativeBlack | 0:f850dfb07e93 | 22 | int |
OlgaHoeyer | 2:4fba73b78e1c | 23 | main() |
OlgaHoeyer | 2:4fba73b78e1c | 24 | { |
OlgaHoeyer | 2:4fba73b78e1c | 25 | GetTemperatureAndHumidity(); |
NegativeBlack | 0:f850dfb07e93 | 26 | } |
OlgaHoeyer | 2:4fba73b78e1c | 27 | |
OlgaHoeyer | 2:4fba73b78e1c | 28 | void GetTemperatureAndHumidity() |
OlgaHoeyer | 5:40f3f713bba0 | 29 | { |
OlgaHoeyer | 2:4fba73b78e1c | 30 | // Speed things up a bit. |
OlgaHoeyer | 2:4fba73b78e1c | 31 | sensor.setOTPReload(false); |
OlgaHoeyer | 2:4fba73b78e1c | 32 | sensor.setResolution(true); |
OlgaHoeyer | 2:4fba73b78e1c | 33 | |
OlgaHoeyer | 2:4fba73b78e1c | 34 | while(1) |
OlgaHoeyer | 2:4fba73b78e1c | 35 | { |
OlgaHoeyer | 2:4fba73b78e1c | 36 | busy = true; |
OlgaHoeyer | 2:4fba73b78e1c | 37 | sensor.update(); |
OlgaHoeyer | 2:4fba73b78e1c | 38 | busy = false; |
OlgaHoeyer | 2:4fba73b78e1c | 39 | |
OlgaHoeyer | 2:4fba73b78e1c | 40 | // Temperature in celcius |
OlgaHoeyer | 2:4fba73b78e1c | 41 | sensor.setScale(false); |
OlgaHoeyer | 3:0759c60f116b | 42 | temperature=sensor.getTemperature(); //don't know if it works |
OlgaHoeyer | 2:4fba73b78e1c | 43 | |
OlgaHoeyer | 2:4fba73b78e1c | 44 | // Relative Humidity |
OlgaHoeyer | 3:0759c60f116b | 45 | humidity=sensor.getHumidity(); //don't know if it works |
OlgaHoeyer | 2:4fba73b78e1c | 46 | |
OlgaHoeyer | 2:4fba73b78e1c | 47 | wait(5); |
OlgaHoeyer | 5:40f3f713bba0 | 48 | return; |
OlgaHoeyer | 5:40f3f713bba0 | 49 | } |
OlgaHoeyer | 2:4fba73b78e1c | 50 | } |