Drivers for temperature and humidity sensor SHF15. Modified for EDE_PRO2_team1
Fork of PRO2_SHT15_Example by
Revision 6:d17b645ed2a5, committed 2017-05-18
- Comitter:
- OlgaHoeyer
- Date:
- Thu May 18 21:21:13 2017 +0000
- Parent:
- 5:40f3f713bba0
- Commit message:
- modulus structure_first try
Changed in this revision
diff -r 40f3f713bba0 -r d17b645ed2a5 get_humid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get_humid.cpp Thu May 18 21:21:13 2017 +0000 @@ -0,0 +1,38 @@ +//Author : Olga Hoeyer +//Date : 18 May 2017 +//Version : 2.0 +//Changes: Structure changed to modular, to ease future use of the funktion. +//Copyright : Open for everyone +// +// Description : Function will get a humidity value from the SHF-15 sensor +// Output is relative humidity (float). + + +#include "mbed.h" +#include "SHTx/sht15.hpp" + +DigitalOut busy(LED1); +//ports on the Nucleo: PB_8, PB_9 +SHTx::SHT15 sensor(PB_8, PB_9); + +float GetHumid() +{ +//VARIABLES: + float humidity; //this will be data read from sensor + +// Speed things up a bit. + sensor.setOTPReload(false); + sensor.setResolution(true); + + busy = true; + sensor.update(); + busy = false; + + // Temperature in celcius + sensor.setScale(false); + humidity=sensor.getHumidity(); //don't know if it works + + wait(5); + return (humidity); + +} \ No newline at end of file
diff -r 40f3f713bba0 -r d17b645ed2a5 get_humid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get_humid.h Thu May 18 21:21:13 2017 +0000 @@ -0,0 +1,12 @@ +//Author : Olga Hoeyer +//Date : 18 May 2017 +//Version : 2.0 +//Changes: Structure changed to modular, to ease future use of the funktion. +//Copyright : Open for everyone +// +// Description : Function will get a humidity value from the SHF-15 sensor +// Output is relative humidity (float). +// +// Usage: GetHumid() + +float GetHumid(); \ No newline at end of file
diff -r 40f3f713bba0 -r d17b645ed2a5 get_temp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get_temp.cpp Thu May 18 21:21:13 2017 +0000 @@ -0,0 +1,38 @@ +//Author : Olga Hoeyer +//Date : 18 May 2017 +//Version : 2.0 +//Changes: Structure changed to modular, to ease future use of the funktion. +//Copyright : Open for everyone +// +//Description : Function will get a temperature value from the SHF-15 sensor +//Output is value in Celsius (float). + + +#include "mbed.h" +#include "SHTx/sht15.hpp" + +DigitalOut busy(LED1); +//ports on the Nucleo: PB_8, PB_9 +SHTx::SHT15 sensor(PB_8, PB_9); + +float GetTemperature() +{ +//VARIABLES: + float temperature; //this will be data read from sensor + + // Speed things up a bit. + sensor.setOTPReload(false); + sensor.setResolution(true); + + busy = true; + sensor.update(); + busy = false; + + // Temperature in celcius + sensor.setScale(false); + temperature=sensor.getTemperature(); + + wait(5); + return (temperature); + +} \ No newline at end of file
diff -r 40f3f713bba0 -r d17b645ed2a5 get_temp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/get_temp.h Thu May 18 21:21:13 2017 +0000 @@ -0,0 +1,12 @@ +//Author : Olga Hoeyer +//Date : 18 May 2017 +//Version : 2.0 +//Changes: Structure changed to modular, to ease future use of the funktion. +//Copyright : Open for everyone +// +// Description : Function will get a temperature value from the SHF-15 sensor +// Output is value in Celsius (float). +// +// Usage: GetTemperature() + +float GetTemperature(); \ No newline at end of file
diff -r 40f3f713bba0 -r d17b645ed2a5 main.cpp --- a/main.cpp Wed May 10 20:14:37 2017 +0000 +++ b/main.cpp Thu May 18 21:21:13 2017 +0000 @@ -5,46 +5,17 @@ * Original Copyright (c) 2010 Roy van Dam <roy@negative-black.org> **/ -#include "mbed.h" //NOTE. Compiler gives an error: -#include "SHTx/sht15.hpp" //"CMSIS Target not recognised" +#include "mbed.h" +#include <get_temp.h> +#include <get_humid.h> //GLOBAL VARIABLES: -float temperature, humidity; //this will be data read from sensor -void GetTemperatureAndHumidity(); - -Serial pc(USBTX, USBRX); -DigitalOut busy(LED1); //Don't think we need it. - -//ports on the Nucleo: PB_8, PB_9 -SHTx::SHT15 sensor(PB_8, PB_9); +float temp, hum; //this will be data read from sensor -int -main() +int main() { - GetTemperatureAndHumidity(); + temp =GetTemperature(); + hum=GetHumid(); } -void GetTemperatureAndHumidity() -{ -// Speed things up a bit. -sensor.setOTPReload(false); -sensor.setResolution(true); - -while(1) -{ - busy = true; - sensor.update(); - busy = false; - - // Temperature in celcius - sensor.setScale(false); - temperature=sensor.getTemperature(); //don't know if it works - - // Relative Humidity - humidity=sensor.getHumidity(); //don't know if it works - - wait(5); - return; -} -} \ No newline at end of file