Joseph Ellsworth / Mbed 2 deprecated xj-Nucleo-F303K8-hdc1080-test

Dependencies:   hdc1080 mbed

Fork of Nucleo-F303K8-SSD1306_OLED by Joseph Ellsworth

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Example of Reading  TI HDC1080 sensor using STM F303K8 dev board
00002 
00003   By Joseph Ellsworth CTO of A2WH
00004   Take a look at A2WH.com Producing Water from Air using Solar Energy
00005   March-2016 License: https://developer.mbed.org/handbook/MIT-Licence
00006   Please contact us http://a2wh.com for help with custom design projects.
00007  */
00008 
00009 #include "mbed.h"
00010 #include <stdint.h>
00011 
00012 //Pin Defines for I2C Bus
00013 #define D_SDA                  PB_7 // specific for Nucleo-F303K8
00014 #define D_SCL                  PB_6 // specific for Nucleo-F303K8
00015 I2C hdc_i2c(D_SDA, D_SCL);
00016 #include "hdc1080.h"
00017 
00018 // Host PC Communication channels
00019 Serial pc(USBTX, USBRX); // tx, rx
00020 DigitalOut myled(LED1);
00021 
00022 int main()
00023 {
00024     pc.baud(9600);
00025     printf("\r\\nHDC1080 Test\r\n");
00026     while(1) {        
00027         myled = !myled;
00028         hdc_begin();
00029         uint16_t manId = hdc_readManufactId();
00030         float tempC = hdc_readTemp();     
00031         float humid = hdc_readHumid();  
00032         unsigned long  serNum = hdc_readSerial();
00033         printf("manId=x%x, tempC=%0.3f humid=%0.3f serfNum=%lu\r\n",
00034           manId, tempC, humid, serNum);
00035         wait(3.0f);
00036     }
00037 }
00038