rpav wrote:I've ordered new module form Aliexpress and will report to this thread if it helps. I hope it will.
I confirm that with new MAX31855 module:
https://www.aliexpress.com/item/MAX3185 ... 99466.htmlit works like a charm.Even SPI transaction works well at nodemcu 2.1.
But I found, that (even on ESP07 with module used) there is a need to pulldown GPIO15 (HSPI CS). Otherwise ESP will boot only to flash mode and will not continue booting to user level.
Thank you for help and ideas.
Roman
Code: Select all-- MAX31855 to ESP8266 connection
-- Signal IO index ESP8266 pin
-- HSPI CLK 5 GPIO14
-- HSPI /CS 8 GPIO15
-- HSPI MISO 6 GPIO12
-- !!! WARNING !!! GPIO15 _must_ by HW PULL-DOWN by 4k7 resistor.
-- !!! If you do not do it, esp will not boot and you can see something like:
-- ets Jan 8 2013,rst cause:2, boot mode:(7,6)
--
-- waiting for host
-- Init SPI
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 32, 16, spi.HALFDUPLEX)
-- Thermocouple temperature
str1=""
temp1=0
-- Internal temperature
str2=""
temp2=0
-- err=""
function measure()
-- do transaction & read data from buffer
spi.transaction(1,0,0,0,0,0,0,32)
data = {spi.get_miso(1, 0, 1, 32)}
-- print(table.concat(data))
-- check error(s)
if data[16]==1 then -- error
err="ERROR: "
end
if data[30]==1 then -- error
err=err.."Short to VCC "
end
if data[31]==1 then -- error
err=err.."Short to GND "
end
if data[32]==1 then -- error
err=err.."Open Circuit "
end
-- read data for Thermocouple temperature
str1=table.concat(data,"",2,14) -- concat 13 bits to table, first is sign bit
t1=tonumber(str1,2) -- convert table of binaries to decimal number
if data[1]==1 then -- sign bit on, the number is negative, compute it
t1=t1-8192 -- sign binary, 1111111111111 = 8191
end
t1=t1*.25 -- step for Thermocouple temp is 0.25
str1="Thermocouple temp is: "..t1.."'C"
-- read data for Internal temperature
str2=table.concat(data,"",18,28) --concat 11 bits to table, first is sign bit
t2=tonumber(str2,2) -- convert table of binaries to decimal number
if data[17]==1 then -- sign bit on, the number is negative
t2=t2-2048 -- sign binary, 11111111111 = 2047
end
t2=t2*.0625 -- step for Internatl temp is 0.0625
str2="Internal temp is: "..t2.."'C"
end
tmr.alarm(1,10000,tmr.ALARM_AUTO,function()
measure()
print(err);
print(str1);
print(str2);
print("");
end)