Hampus Lundberg / Mbed 2 deprecated analogtemperature

Dependencies:   mbed

main.cpp

Committer:
hample
Date:
2019-01-08
Revision:
0:91a5544963d7

File content as of revision 0:91a5544963d7:

#include "mbed.h"

using namespace std;

AnalogIn read_temp(PD4);

float temp;
uint16_t temp_hex;
float temp_volt;
float temp_ambient;

int main()
{
    while(1)
    {
        temp = read_temp.read();
        temp_hex = read_temp.read_u16();
        temp_volt = temp*3.3;
        
        temp_ambient = (temp_volt - 0.5)/0.01;
        
        //printf("%f \r\n", temp);
        printf("Hex: 0x%04X \r\n", temp_hex);
        
        printf("Voltage in: %.2f \r\n", temp_volt);
        
        printf("Ambient temperature: %.2f \r\n", temp_ambient);
        
        
        
        wait(1);
    }
}

// 0.739