Testing SHT75 humidity sensor on STM F303K8 board.

Dependencies:   SHT75 mbed

Fork of Nucleo-F303K8-SSD1306_OLED by Joseph Ellsworth

Sample code to test SHT75 humidity sensor using STM F303K8 board. Uses a 3.3V from board to power sensor. 10K resistor Pull-up on data. Must not be on same pins as I2C. Uses D0 for Clk and D1 for Data.

I had to modify sample code supplied by https://developer.mbed.org/users/nimbusgb/code/SHT75/ because the sensor failed to read without the softReset() and readStatus() at beginning of measurement loop. I think this is caused by the 72Mhtz speed of the F303K8 but did not attempt to fully diagnose.

The readStatus() method from library seems to malfunction and always return a -1 which never changes even when sensor is unplugged.

See https://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/Humidity_Sensors/Sensirion_Humidity_Sensors_SHT7x_Datasheet_V5.pdf section 2.1 for wiring.

main.cpp

Committer:
joeata2wh
Date:
2016-03-19
Revision:
0:fa185766e039
Child:
1:90d213185462

File content as of revision 0:fa185766e039:

/* Example of Reading all the ADC pins available on the Nucleo_F303K8. 
 by Joseph Ellsworth CTO A2WH -  Free for all but no warranty, no promises */

#include "mbed.h"

// Initialize a pins to perform analog input and digital output fucntions
AnalogIn   aA7(PA_2);
AnalogIn   aA6(PA_7);
AnalogIn   aA5(PA_6);
AnalogIn   aA4(PA_5);
AnalogIn   aA3(PA_4);
AnalogIn   aA2(PA_3);
AnalogIn   aA1(PA_1); 
AnalogIn   aA0(PA_0); 
AnalogIn   aB0(PB_0); 
AnalogIn   aB1(PB_1); 
 
DigitalOut myled(LED1);
const float voltMeterARef = 3.3;

float readPrint(AnalogIn ain, char *label) {
  float tval = ain.read();
  float volts = tval * voltMeterARef;
  float perc = tval * 100.0;  
  unsigned short  tvalu16 = ain.read_u16 ();

  printf("adc %s R=%3.3f V=%3.3f%% U16=%u\r\n",label, tval, volts, tvalu16);
  
  return tval;
}
    

int main() {

    while(1) {
        myled = !myled; // toggle led 
        readPrint(aA7, "PA_7");
        readPrint(aA6, "PA_6");
        readPrint(aA5, "PA_5");
        readPrint(aA4, "PA_4");
        readPrint(aA3, "PA_3");
        readPrint(aA2, "PA_2");
        readPrint(aA1, "PA_1");
        readPrint(aA0, "PA_0");
        
        readPrint(aB0, "PB_0");
        readPrint(aB1, "PB_1");
        printf("\r\n\r\n");
        wait(7.0);
        
    }
}