Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

MAX30205 Human Body Temperature Sensor

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here
View previous topic :: View next topic  
Author Message
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 338
Location: Japan

japan.gif
PostPosted: Thu Jun 24, 2021 3:58 am    Post subject: MAX30205 Human Body Temperature Sensor Reply with quote

The MAX30205 is a highly accurate temperature sensor with a guaranteed accuracy within ±0.1 C in the human body temperature range (37 C to 39 C).
The temperature can be obtained with a simple command of the I2C serial interface.

Circuit diagram
https://drive.google.com/file/d/1eIoKm8PlfzCX5TCtokTTotaQz77qkPRc/view?usp=sharing

Sensor board
https://drive.google.com/file/d/1zcVIdVt1YplOy2dNvS3POxFd_vQGxA_1/view?usp=sharing

Connection test
https://drive.google.com/file/d/1UNakjz8Iyx0sj_T70JU5eeWTd63xjhRq/view?usp=sharing

Output to serial terminal
https://drive.google.com/file/d/1xe00_q6tyEtnWawX9eSWjDIUp92FNLkf/view?usp=sharing

Data sheet
https://datasheets.maximintegrated.com/en/ds/MAX30205.pdf

Code:
$programmer = 22                                            'ARDUINO (using stk500v1 protocol)

   '
   '  ********************************************
   '  *  MAX30205 Human Body Temperature Sensor  *
   '  *           Arduino LCD Keypad Shield      *
   '  *                          2021. 6.22      *
   '  ********************************************
   '

$regfile = "m328pdef.dat"                                   'Set the AVR to use.
$crystal = 16000000                                         'Set the AVR clock.
   '
$hwstack = 64                                               'Set the capacity of the hardware stack.
$swstack = 10                                               'Set the capacity of the software stack.
$framesize = 24                                             'Set the capacity of the frame area.

   '
   '  * Variable declaration *
   '
   Dim Temperature As Long                                  'MAX30205 Sensor temperature value.
   Dim I2cbuff(5) As Byte                                   'I2C send / receive data buffer.
   '
   Dim Tempi1 As Integer                                    'General-purpose temporary.
   Dim Tempstr As String * 20                               'General-purpose temporary.


   '
   '  * Port initialization *
   '
   Config Portb.2 = Output                                  'Set the LCD backlight control connection port to output.
   Set Portb.2                                              'Turn on the LCD backlight.
   '
   '  * LCD initial settings *
   '
   Config Lcdmode = Port                                    'Set LCD to 4-bit port mode.
   Config Lcdbus = 4                                        'Set the LCD data bus to 4bit.
   Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5      'LCD port assignment.
   Config Lcdpin = Pin , Db6 = Portd.6 , Db7 = Portd.7
   Config Lcdpin = Pin , E = Portb.1 , Rs = Portb.0
   Config Lcd = 16 * 2                                      'Set the LCD display to 16 characters and 2 lines.
   Cls                                                      'Erase all LCD display.
   '
   Deflcdchar 0 , &H08 , &H14 , &H08 , &H06 , &H09 , &H08 , &H09 , &H06       'Write the custom character [C] to the LCD.
   Cursor Off                                               'Turn off the LCD cursor.

   '
   '  * Serial port settings *
   '
   Config Com1 = 9600 , Parity = None , Stopbits = 1 , Databits = 8       'Hardware UART settings.

   '
   '  * I2C initial settings *
   '
   Const I2c_select = 1                                     '0:Software I2C , 1:TWI
#if I2c_select = 0
   '------[For software I2C]------
   Config Scl = Portc.5                                     'Set the port pin to connect the SCL line of the I2C bus.
   Config Sda = Portc.4                                     'Set the port pin to connect the SDA line of the I2C bus.
   I2cinit                                                  'Initialize the SCL and SDA lines of the I2C bus.
   '-------------------------------
#else
   '------[For TWI]------------------
   $lib "i2c_twi.lib"                                       'Incorporate the hardware I2C/TWI library.
   Config Twi = 400000                                      'I2C bus clock = 400KHz
   Config Scl = Portc.5                                     'You must specify the SCL pin name.
   Config Sda = Portc.4                                     'You must specify the SDA pin name.
   I2cinit                                                  'Initialize the SCL and SDA lines of the I2C bus.
   '-------------------------------
#endif
   '
   Const Max30205_address = &H90                            'The slave address of the MAX30205.


'--------------------------------------------------------------------------------------------------

   '
   '  * Display the initial value of the MAX30205 register *
   '
   Print : Print "* MAX30205 *"                             'Title output.
   '
   I2cbuff(1) = &H01                                        'Register address = [Configuration register]
   I2creceive Max30205_address , I2cbuff(1) , 1 , 1         'Send 1 byte to MAX30205 and receive 1 byte.
   Locate 1 , 1
   Lcd "Config: "
   Locate 2 , 1
   Lcd Bin(i2cbuff(1))                                      'Display the contents of [Configuration Register] in binary on the LCD.
   '
   Print "-Configuration : " ; Bin(i2cbuff(1))              'Output the contents of [Configuration Register] to the terminal.
   '
   I2cbuff(1) = &H02                                        'Register address = [THYST register]
   I2creceive Max30205_address , I2cbuff(1) , 1 , 2         'Sends 1 byte to MAX30205 and receives 2 bytes.
   Tempi1 = Makeint(i2cbuff(2) , I2cbuff(1))                'Convert 2 bytes of [THYST register] to integer type.
   Locate 1 , 9
   Lcd "THY:" ; Hex(tempi1)                                 'HEX the contents of the [THYST register] on the LCD.
   '
   Print "-THYST : " ; Hex(tempi1)                          'Output the contents of [THYST register] to the terminal.
   '
   I2cbuff(1) = &H03                                        'Register address = [TOS register]
   I2creceive Max30205_address , I2cbuff(1) , 1 , 2         'Sends 1 byte to MAX30205 and receives 2 bytes.
   Tempi1 = Makeint(i2cbuff(2) , I2cbuff(1))                'Convert 2 bytes of [TOS register] to integer type.
   Locate 2 , 9
   Lcd "TOS:" ; Hex(tempi1)                                 'HEX the contents of the [TOS register] on the LCD.
   '
   Print "-TOS   : " ; Hex(tempi1)                          'Output the contents of [TOS register] to the terminal.
   Print
   '
   Wait 3

   '
   '  * Initial display of LCD screen *
   '
   Cls                                                      'Erase all LCD display.
   Locate 1 , 1
   Lcd "MAX30205"                                           'Display of title.
   Locate 2 , 3
   Lcd "temp:"

Main:
   '
   '  * Get the temperature value of the sensor *
   '
   Do
      I2cbuff(1) = &H00                                     'Register address = [Temperature register]
      I2creceive Max30205_address , I2cbuff(1) , 1 , 2      'Sends 1 byte to MAX30205 and receives 2 bytes.
      '
      Tempi1 = Makeint(i2cbuff(2) , I2cbuff(1))             'Converts 2 bytes of ADC value to integer type.
      Shift Tempi1 , Right , 1 , Signed                     'Drop the least significant bit. (Make it 15 bits)
      Temperature = Tempi1 * 78125                          'ADC value * 0.0078125 C (15-bit resolution).
      Temperature = Temperature / 1000000                   'Make it a 3-digit integer including a decimal point.
      '
      Tempstr = Str(temperature)                            'Convert numeric variables to character variables.
      Locate 2 , 9
      Lcd Format(tempstr , " 0.0") ; " " ; Chr(0) ; "  "    'Display the temperature value on the LCD.
      '
      Print " " ; Format(tempstr , " 0.0") ; " c"           'Output the temperature value to the terminal.
      '
      Waitms 500                                            'Waiting time for display interval.
   Loop

   End
 
Back to top
View user's profile Visit poster's website
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 1198
Location: France

france.gif
PostPosted: Thu Jun 24, 2021 11:37 am    Post subject: Reply with quote

Hello
Nice Work
I work with another sensor just as accurate, the TMP117 https://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=14790&highlight=tmp117
with the help of Ian Dobson who translated the example from C to bascom
I thank you for your publication I will publish my tests soon.
Who provided you the module?
as for the TMC117, I find it aberrant to place the sensor on the same side of the circuit as the other components

jp Wink

_________________
pleasure to learn, to teach, to create
Back to top
View user's profile Visit poster's website
O-Family

Bascom Expert



Joined: 23 May 2010
Posts: 338
Location: Japan

japan.gif
PostPosted: Thu Jun 24, 2021 1:58 pm    Post subject: Reply with quote

Hi,
The MAX30205 is a temperature sensor very similar to the TMP117.
The narrower operating temperature range of the MAX30205 seems to make it more accurate in measuring body temperature.

I also considered using the TMP117, but the Texas Instruments device is no longer sold for amateur use, so it would be difficult to obtain for personal use.
I got the MAX30205 module from AliExpress in China.

These devices seem to measure the temperature transmitted to the thermal pad on the backside of the chip.
Therefore, it seems to be more important to place the components in such a way that the temperature is easily transmitted to the thermal pad than the placement of the components.
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 6198
Location: Holland

blank.gif
PostPosted: Thu Jun 24, 2021 8:57 pm    Post subject: Reply with quote

Hello O-Family,

You always have these nice projects Very Happy
Thank you for sharing your project with all the details.

As usual good documented and clear coded.
Thanks !

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> Share your working BASCOM-AVR code here All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum