Read MAX6675 with ESP8266

Place code snippets and demo code here
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: Read MAX6675 with ESP8266

Post by cicciocb »

HI mezjoc,
please let us know if this code was successful for you.

cicciocb
mezjoc
Posts: 24
Joined: Tue Mar 09, 2021 4:26 pm
Location: Fót / Hungary
Has thanked: 16 times
Been thanked: 8 times

Re: Read MAX6675 with ESP8266

Post by mezjoc »

Dear cicciocb!
The program works perfectly. I just do not understand how? I tested up to about 400 ° C. I couldn't measure the accuracy. Thank you very much for your help: mezjoc

Code: [Local Link Removed for Guests]

'/program/spi_max6675_2.bas
spi.setup 1000000,0,1    'bit/sec, data_mode(0-1-2-3), lsb_first(0)-msb_first(1)
'MAX6675/SO-->GPIO12/D6
'MAX6675/CS-->GPIO16/D0
'MAX6675/SCK-->GPIO14/D5
'POWER-->+3V3-GND
pin.mode 16, output ' CS-->GPIO16
timer0 2000,mytimer
wait

mytimer:
i=i+1
pin(16) = 0    'CS=LOW
v0 = spi.byte(0)          '0000 0000 0011=3D
v1 = v0 << 8              '0011 0000 0000=768D
v2 = v1 or spi.byte(0)    '0011 0000 0011=771D ???
pin(16) = 1    'CS=HIGH

if (v2 and &h4) then    '
  wlog "no thermocouple attached!"
else
  v3 = v2 >> 3
  wlog i;".",v0,v1,v2,v3,"Temperature "; v3 * 0.25 ; "°C"
end if
return
mezjoc
Posts: 24
Joined: Tue Mar 09, 2021 4:26 pm
Location: Fót / Hungary
Has thanked: 16 times
Been thanked: 8 times

Re: Read MAX6675 with ESP8266

Post by mezjoc »

Dear cicciocb!
Here are the wlog values (at room temperature). I'm trying to decipher: mezjoc

Code: [Local Link Removed for Guests]

1.    3    768    784    98    Temperature 24.5°C
2.    3    768    776    97    Temperature 24.25°C
3.    3    768    768    96    Temperature 24°C
4.    3    768    792    99    Temperature 24.75°C
5.    2    512    760    95    Temperature 23.75°C
6.    3    768    776    97    Temperature 24.25°C
7.    3    768    768    96    Temperature 24°C
8.    3    768    776    97    Temperature 24.25°C
9.    3    768    784    98    Temperature 24.5°C
10.    3    768    776    97    Temperature 24.25°C
11.    3    768    776    97    Temperature 24.25°C
12.    3    768    768    96    Temperature 24°C
13.    3    768    792    99    Temperature 24.75°C
14.    3    768    792    99    Temperature 24.75°C
15.    2    512    760    95    Temperature 23.75°C
16.    3    768    776    97    Temperature 24.25°C
17.    3    768    776    97    Temperature 24.25°C
18.    2    512    760    95    Temperature 23.75°C
19.    3    768    768    96    Temperature 24°C
20.    3    768    776    97    Temperature 24.25°C
21.    3    768    784    98    Temperature 24.5°C
22.    3    768    784    98    Temperature 24.5°C
23.    3    768    768    96    Temperature 24°C
24.    3    768    776    97    Temperature 24.25°C
25.    3    768    768    96    Temperature 24°C
26.    3    768    784    98    Temperature 24.5°C
27.    3    768    776    97    Temperature 24.25°C
28.    3    768    776    97    Temperature 24.25°C
29.    3    768    768    96    Temperature 24°C
30.    3    768    776    97    Temperature 24.25°C
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: Read MAX6675 with ESP8266

Post by cicciocb »

What do you need to decipher ? :D

If you look at the datasheet https://datasheets.maximintegrated.com/ ... AX6675.pdf

In particular at the page containing the output format
image.png
You can see that the output contains 16 bits (2 bytes) and that the whole must be shifted right of 3 bits to obtain the 12 bits reading.

this code

Code: [Local Link Removed for Guests]

v0 = spi.byte(0)
v1 = v0 << 8  
v2 = v1 or spi.byte(0)  
simply read the 2 bytes shifting the first one of 8 bits to the left to compose a 16 bits number.

As the resolution is 0.25°C, the value is simply multiplied by 0.25
You do not have the required permissions to view the files attached to this post.
mezjoc
Posts: 24
Joined: Tue Mar 09, 2021 4:26 pm
Location: Fót / Hungary
Has thanked: 16 times
Been thanked: 8 times

Re: Read MAX6675 with ESP8266

Post by mezjoc »

Dear CiccioCB!
I don't want to waste your time.
The value of spi.byte (0) is the same for both inputs (line 14, line 16). Value = 3D = 0000 0011B. Why does the value of v2 change? (768D ... 784D)?
Other!
Line 20 is never active.
Regards: mezjoc
bugs
Posts: 142
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 44 times
Been thanked: 50 times

Re: Read MAX6675 with ESP8266

Post by bugs »

Hi mezjoc,

Excuse me butting in but maybe this can help.
There are 16 bits sent by the device.
Line 16 reads the second 8 bits
v2 = v1 or spi.byte(0)
so spibyte(0) is a different value to v0
mezjoc
Posts: 24
Joined: Tue Mar 09, 2021 4:26 pm
Location: Fót / Hungary
Has thanked: 16 times
Been thanked: 8 times

Re: Read MAX6675 with ESP8266

Post by mezjoc »

Which is accurate?
Heat blower vs ESP8266?
Image
You do not have the required permissions to view the files attached to this post.
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Re: Read MAX6675 with ESP8266

Post by Electroguard »

Ha... 552.25

Be interesting to to see how 2 thermocouples might compare at the same time.
User avatar
cicciocb
Site Admin
Posts: 1900
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 407 times
Been thanked: 1271 times
Contact:

Re: Read MAX6675 with ESP8266

Post by cicciocb »

The datasheet says that the accuracy is 8LSB (that is 8*0.25 = 2°C)
image.png
You do not have the required permissions to view the files attached to this post.
mezjoc
Posts: 24
Joined: Tue Mar 09, 2021 4:26 pm
Location: Fót / Hungary
Has thanked: 16 times
Been thanked: 8 times

Re: Read MAX6675 with ESP8266

Post by mezjoc »

I AM 70 YEARS OLD. I am very glad to be a member of the forum.
Mezei József (mezjoc) / Hungary. :D
Post Reply