Syggestions

Dependencies:   CheckRTC LPS25H hts221

Fork of ELEC350-extended-referral2 by satbir panesar

Committer:
noutram
Date:
Fri Sep 29 12:21:33 2017 +0000
Revision:
38:10aadcc9a2dd
Parent:
37:bfe26c8c0793
Child:
39:504f5dc30a33
ELEC350 Referral u

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 38:10aadcc9a2dd 23 printf("ELEC350/351 Simple Temperature Humidity and Pressure Sensor Monitor\n\r");
noutram 38:10aadcc9a2dd 24 printf("Using the X-NUCLEO-IKS01A1 shield and mbed-os Libraries\n\r");
noutram 38:10aadcc9a2dd 25 printf("Press A to take a measurement\n\r");
noutram 38:10aadcc9a2dd 26
noutram 38:10aadcc9a2dd 27 aA
noutram 35:af125862c33e 28 while(1)
noutram 35:af125862c33e 29 {
noutram 35:af125862c33e 30 cmd=NULL;
noutram 35:af125862c33e 31 while(cmd==NULL){cmd=getchar();}
noutram 35:af125862c33e 32 if(cmd=='?'){
noutram 35:af125862c33e 33 printf("SOFT253 simple Temperature Humidity and Pressure Sensor Monitor\n\r");
noutram 35:af125862c33e 34 printf("Using the X-NUCLEO-IKS01A1 shield and MBED Libraries\n\r");
noutram 38:10aadcc9a2dd 35
noutram 35:af125862c33e 36 }
noutram 35:af125862c33e 37 if(cmd=='A'){
noutram 35:af125862c33e 38 humidity.ReadTempHumi(&tempCelsius, &humi);
noutram 35:af125862c33e 39 printf("%4.2fC %3.1f%%", tempCelsius, humi);
noutram 35:af125862c33e 40 barometer.get();
noutram 35:af125862c33e 41 printf(" %6.1f %4.1f\r\n", barometer.pressure(), barometer.temperature());
noutram 35:af125862c33e 42 myled = 1; // LED is ON
noutram 35:af125862c33e 43 Thread::wait(200); // 200 ms NB 'Thread::wait(int d);' !!! d is in milliseconds!
noutram 35:af125862c33e 44 myled = 0; // LED is OFF
noutram 35:af125862c33e 45 Thread::wait(100); // 100 ms
noutram 35:af125862c33e 46 }
FairyMental 34:62aae7d507e2 47 }
noutram 35:af125862c33e 48 }
noutram 35:af125862c33e 49
noutram 35:af125862c33e 50
noutram 35:af125862c33e 51
noutram 35:af125862c33e 52 /*#include "mbed.h"
noutram 35:af125862c33e 53
noutram 35:af125862c33e 54 DigitalOut led1(LED1);
noutram 35:af125862c33e 55
noutram 35:af125862c33e 56 // main() runs in its own thread in the OS
noutram 35:af125862c33e 57 int main() {
FairyMental 34:62aae7d507e2 58 while (true) {
noutram 35:af125862c33e 59 led1 = !led1;
noutram 35:af125862c33e 60 wait(0.5);
noutram 35:af125862c33e 61 }
FairyMental 34:62aae7d507e2 62 }
noutram 35:af125862c33e 63 */