test code for hdc1080 humidity sensor

Dependencies:   hdc1080 mbed

Fork of Nucleo-F303K8-SSD1306_OLED by Joseph Ellsworth

Committer:
joeata2wh
Date:
Wed Sep 14 02:37:29 2016 +0000
Revision:
6:c5430cdc9861
Parent:
5:3c91772b714e
working version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joeata2wh 4:53d68b18bd43 1 /* Example of Reading TI HDC1080 sensor using STM F303K8 dev board
joeata2wh 4:53d68b18bd43 2
joeata2wh 3:47148198f5f2 3 By Joseph Ellsworth CTO of A2WH
joeata2wh 3:47148198f5f2 4 Take a look at A2WH.com Producing Water from Air using Solar Energy
joeata2wh 4:53d68b18bd43 5 March-2016 License: https://developer.mbed.org/handbook/MIT-Licence
joeata2wh 3:47148198f5f2 6 Please contact us http://a2wh.com for help with custom design projects.
joeata2wh 1:90d213185462 7 */
joeata2wh 0:fa185766e039 8
joeata2wh 0:fa185766e039 9 #include "mbed.h"
joeata2wh 4:53d68b18bd43 10 #include <stdint.h>
joeata2wh 2:dc3e84d595c3 11
joeata2wh 2:dc3e84d595c3 12 //Pin Defines for I2C Bus
joeata2wh 2:dc3e84d595c3 13 #define D_SDA PB_7 // specific for Nucleo-F303K8
joeata2wh 2:dc3e84d595c3 14 #define D_SCL PB_6 // specific for Nucleo-F303K8
joeata2wh 5:3c91772b714e 15 I2C hdc_i2c(D_SDA, D_SCL);
joeata2wh 4:53d68b18bd43 16 #include "hdc1080.h"
joeata2wh 4:53d68b18bd43 17
joeata2wh 2:dc3e84d595c3 18 // Host PC Communication channels
joeata2wh 2:dc3e84d595c3 19 Serial pc(USBTX, USBRX); // tx, rx
joeata2wh 0:fa185766e039 20 DigitalOut myled(LED1);
joeata2wh 2:dc3e84d595c3 21
joeata2wh 2:dc3e84d595c3 22 int main()
joeata2wh 2:dc3e84d595c3 23 {
joeata2wh 3:47148198f5f2 24 pc.baud(9600);
joeata2wh 5:3c91772b714e 25 printf("\r\\nHDC1080 Test\r\n");
joeata2wh 5:3c91772b714e 26 while(1) {
joeata2wh 5:3c91772b714e 27 myled = !myled;
joeata2wh 4:53d68b18bd43 28 hdc_begin();
joeata2wh 5:3c91772b714e 29 uint16_t manId = hdc_readManufactId();
joeata2wh 5:3c91772b714e 30 float tempC = hdc_readTemp();
joeata2wh 5:3c91772b714e 31 float humid = hdc_readHumid();
joeata2wh 5:3c91772b714e 32 unsigned long serNum = hdc_readSerial();
joeata2wh 5:3c91772b714e 33 printf("manId=x%x, tempC=%0.3f humid=%0.3f serfNum=%lu\r\n",
joeata2wh 5:3c91772b714e 34 manId, tempC, humid, serNum);
joeata2wh 5:3c91772b714e 35 wait(3.0f);
joeata2wh 0:fa185766e039 36 }
joeata2wh 0:fa185766e039 37 }
joeata2wh 5:3c91772b714e 38