Re: Read MAX6675 with ESP8266
Posted: Tue May 25, 2021 1:41 pm
HI mezjoc,
please let us know if this code was successful for you.
cicciocb
please let us know if this code was successful for you.
cicciocb
All around Annex RDS for ESP8266 and ESP32
https://cicciocb.com/forum/
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
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
Code: [Local Link Removed for Guests]
v0 = spi.byte(0)
v1 = v0 << 8
v2 = v1 or spi.byte(0)