Syggestions

Dependencies:   CheckRTC LPS25H hts221

Fork of ELEC350-extended-referral2 by satbir panesar

Committer:
martinsimpson
Date:
Wed May 03 09:29:32 2017 +0000
Revision:
37:bfe26c8c0793
Parent:
36:c2fd1cd2434f
Child:
38:10aadcc9a2dd
Back to Orignal

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jonathan Austin 0:2757d7abb7d9 1 #include "mbed.h"
martinsimpson 32:260a288be58f 2 #include "rtos.h"
noutram 35:af125862c33e 3 #include "hts221.h"
martinsimpson 32:260a288be58f 4 #include "LPS25H.h"
martinsimpson 32:260a288be58f 5
martinsimpson 32:260a288be58f 6 DigitalOut myled(LED1);
martinsimpson 32:260a288be58f 7 I2C i2c2(I2C_SDA, I2C_SCL);
noutram 35:af125862c33e 8
noutram 35:af125862c33e 9 float tempCelsius = 25.50;
noutram 35:af125862c33e 10 float humi = 55;
noutram 35:af125862c33e 11 int humiMax = 100;
noutram 35:af125862c33e 12 char cmd=0;
noutram 35:af125862c33e 13 uint32_t seconds = 0, minutes=0, hours=0;
martinsimpson 32:260a288be58f 14
noutram 35:af125862c33e 15 LPS25H barometer(i2c2, LPS25H_V_CHIP_ADDR);
noutram 35:af125862c33e 16 HTS221 humidity(I2C_SDA, I2C_SCL);
noutram 35:af125862c33e 17
noutram 35:af125862c33e 18
noutram 35:af125862c33e 19 int main()
noutram 35:af125862c33e 20 {
noutram 35:af125862c33e 21 humidity.init();
noutram 35:af125862c33e 22 humidity.calib();
noutram 35:af125862c33e 23 printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
noutram 35:af125862c33e 24 printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
noutram 35:af125862c33e 25 //printf("%#x\n\r",barometer.read_id());
martinsimpson 32:260a288be58f 26
noutram 35:af125862c33e 27 while(1)
noutram 35:af125862c33e 28 {
noutram 35:af125862c33e 29 cmd=NULL;
noutram 35:af125862c33e 30 while(cmd==NULL){cmd=getchar();}
noutram 35:af125862c33e 31 if(cmd=='?'){
noutram 35:af125862c33e 32 printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
noutram 35:af125862c33e 33 printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
noutram 35:af125862c33e 34 }
noutram 35:af125862c33e 35 if(cmd=='A'){
noutram 35:af125862c33e 36 humidity.ReadTempHumi(&tempCelsius, &humi);
noutram 35:af125862c33e 37 printf("%4.2fC %3.1f%%", tempCelsius, humi);
noutram 35:af125862c33e 38 barometer.get();
noutram 35:af125862c33e 39 printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature());
noutram 35:af125862c33e 40 myled = 1; // LED is ON
noutram 35:af125862c33e 41 Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds!
noutram 35:af125862c33e 42 myled = 0; // LED is OFF
noutram 35:af125862c33e 43 Thread::wait(100); // 100 ms
noutram 35:af125862c33e 44 }
FairyMental 34:62aae7d507e2 45 }
noutram 35:af125862c33e 46 }
noutram 35:af125862c33e 47
noutram 35:af125862c33e 48
noutram 35:af125862c33e 49
noutram 35:af125862c33e 50 /*#include "mbed.h"
noutram 35:af125862c33e 51
noutram 35:af125862c33e 52 DigitalOut led1(LED1);
noutram 35:af125862c33e 53
noutram 35:af125862c33e 54 // main() runs in its own thread in the OS
noutram 35:af125862c33e 55 int main() {
FairyMental 34:62aae7d507e2 56 while (true) {
noutram 35:af125862c33e 57 led1 = !led1;
noutram 35:af125862c33e 58 wait(0.5);
noutram 35:af125862c33e 59 }
FairyMental 34:62aae7d507e2 60 }
noutram 35:af125862c33e 61 */