Drivers for temperature and humidity sensor SHF15. Modified for EDE_PRO2_team1

Dependencies:   SHTx mbed

Fork of PRO2_SHT15_Example by Olga Høyer

Committer:
OlgaHoeyer
Date:
Tue May 09 21:18:57 2017 +0000
Revision:
4:6d85c470d101
Parent:
3:0759c60f116b
Child:
5:40f3f713bba0
added some comments

Who changed what in which revision?

UserRevisionLine numberNew 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 2:4fba73b78e1c 29 // Speed things up a bit.
OlgaHoeyer 2:4fba73b78e1c 30 sensor.setOTPReload(false);
OlgaHoeyer 2:4fba73b78e1c 31 sensor.setResolution(true);
OlgaHoeyer 2:4fba73b78e1c 32
OlgaHoeyer 2:4fba73b78e1c 33 while(1)
OlgaHoeyer 2:4fba73b78e1c 34 {
OlgaHoeyer 2:4fba73b78e1c 35 busy = true;
OlgaHoeyer 2:4fba73b78e1c 36 sensor.update();
OlgaHoeyer 2:4fba73b78e1c 37 busy = false;
OlgaHoeyer 2:4fba73b78e1c 38
OlgaHoeyer 2:4fba73b78e1c 39 // Temperature in celcius
OlgaHoeyer 2:4fba73b78e1c 40 sensor.setScale(false);
OlgaHoeyer 3:0759c60f116b 41 temperature=sensor.getTemperature(); //don't know if it works
OlgaHoeyer 2:4fba73b78e1c 42
OlgaHoeyer 2:4fba73b78e1c 43 // Relative Humidity
OlgaHoeyer 3:0759c60f116b 44 humidity=sensor.getHumidity(); //don't know if it works
OlgaHoeyer 2:4fba73b78e1c 45
OlgaHoeyer 2:4fba73b78e1c 46 wait(5);
OlgaHoeyer 2:4fba73b78e1c 47 return ();
OlgaHoeyer 2:4fba73b78e1c 48 }