This program demonstrates the use of MAX32630HSP3 board with the MAX30205 sensor which provides accurate clinical body temperature with an accuracy of 0.1°C (37°C to 39°C).
Dependencies: MAX30205 max32630hsp3
Run the Code
- Import it into the mbed online compiler.
- Compile the program.
- It will automatically download the .bin file.
- Drag-drop or copy-paste the .bin file to the programmer drive. (PICO DAPLINK).
- Open a serial terminal (Putty, Tera Term, etc.)
- Find the COM port that the device is connected to and set that COM port in the terminal. Adjust the baudrate to 9600.
- Press the reset button on the microcontroller board.
- You should now see the temperature values on the terminal with 0.5-second intervals.
main.cpp@7:9a0214badf2b, 2018-07-09 (annotated)
- Committer:
- Emre.Eken
- Date:
- Mon Jul 09 17:24:08 2018 +0300
- Revision:
- 7:9a0214badf2b
- Parent:
- 3:73a73c9ba847
mbed-os.lib version is changed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EmreE | 0:5ff3e9115682 | 1 | #include "mbed.h" |
EmreE | 0:5ff3e9115682 | 2 | #include "MAX30205.h" |
EmreE | 0:5ff3e9115682 | 3 | #include "max32630hsp.h" |
EmreE | 0:5ff3e9115682 | 4 | |
EmreE | 0:5ff3e9115682 | 5 | //PC serial connection: |
Emre.Eken | 2:88d3b848b5a4 | 6 | Serial pc(USBTX,USBRX); |
EmreE | 0:5ff3e9115682 | 7 | |
EmreE | 0:5ff3e9115682 | 8 | //Enable pin to convert 3V3 to 3V for MAX30205: |
EmreE | 0:5ff3e9115682 | 9 | DigitalOut max30205_LDO_EN(P7_1,1); |
EmreE | 0:5ff3e9115682 | 10 | |
EmreE | 0:5ff3e9115682 | 11 | //Board Initializations: (This also initializes PMIC) |
EmreE | 0:5ff3e9115682 | 12 | MAX32630HSP icarus(MAX32630HSP::VIO_3V3); |
EmreE | 0:5ff3e9115682 | 13 | |
EmreE | 0:5ff3e9115682 | 14 | //Get I2C instance |
Emre.Eken | 3:73a73c9ba847 | 15 | I2C i2cBus(I2C1_SDA, I2C1_SCL); |
EmreE | 0:5ff3e9115682 | 16 | |
EmreE | 0:5ff3e9115682 | 17 | //Get temp sensor instance |
EmreE | 0:5ff3e9115682 | 18 | MAX30205 bodyTempSensor(i2cBus, (0x90 >> 1)); |
EmreE | 0:5ff3e9115682 | 19 | |
EmreE | 0:5ff3e9115682 | 20 | int main(void) |
EmreE | 0:5ff3e9115682 | 21 | { |
EmreE | 0:5ff3e9115682 | 22 | //use sensor |
EmreE | 0:5ff3e9115682 | 23 | uint16_t TemperatureValue; |
EmreE | 0:5ff3e9115682 | 24 | uint32_t ExpandTemperatureValue=0; |
EmreE | 0:5ff3e9115682 | 25 | float Celsius; |
EmreE | 0:5ff3e9115682 | 26 | |
EmreE | 0:5ff3e9115682 | 27 | while(1) |
EmreE | 0:5ff3e9115682 | 28 | { |
EmreE | 0:5ff3e9115682 | 29 | if(!bodyTempSensor.readTemperature(TemperatureValue)) |
EmreE | 0:5ff3e9115682 | 30 | { |
EmreE | 0:5ff3e9115682 | 31 | ExpandTemperatureValue = (uint32_t)TemperatureValue; |
EmreE | 0:5ff3e9115682 | 32 | Celsius = bodyTempSensor.toCelsius(ExpandTemperatureValue); |
EmreE | 0:5ff3e9115682 | 33 | pc.printf("The temperature is %f Celsius\r\n",Celsius); |
EmreE | 0:5ff3e9115682 | 34 | } |
EmreE | 0:5ff3e9115682 | 35 | wait(0.5); |
EmreE | 0:5ff3e9115682 | 36 | } |
EmreE | 0:5ff3e9115682 | 37 | } |