|ADT7410 I2C temp sensor works only after a power cycle
|Page 1 of 1|
|Author:||kimi [ 28 Oct 2016, 05:00 ]|
|Post subject:||ADT7410 I2C temp sensor works only after a power cycle|
I have an ADT7410 temperature sensor connected to an ESP8266 running nodemcu.
The issue I am having is that I can only get good changing data after power cycling the ADT7410. Until that I get either an reasonable fixed temp reading which doesn't change even if I heat/cool down the sensor or 0x0000 (a disconnected sensor results in 0xFFFF). I tried resetting the IC over I2C but it doesn't change anything.
The system consists of a mainboard/daughterboard. This schematic shows the connections between the boards. Unrelated things on the mainboard have been removed.
How could I solve this so that the device starts working after I plug in power without adding a fet to power cycle the daughter board?
NodeMCU lua code:
-- Wifi connection --
return wifi.sta.status() == 5
while not is_connected() do
print("Waiting for connection")
-- I2C & Sensor --
I2C_ID = 0
I2C_PIN_SDA = 2
I2C_PIN_SCL = 1
I2C_ADDRESS = 0x48
I2C_TEMP_REG_MSB = 0x00
I2C_TEMP_REG_LSB = 0x01
I2C_STATUS_REG = 0x02
I2C_CONF_REG = 0x03
i2c.address(I2C_ID, 0x00, i2c.TRANSMITTER)
i2c.address(I2C_ID, I2C_ADDRESS, i2c.TRANSMITTER)
function read_reg(id, dev_addr, reg_addr)
i2c.address(id, dev_addr ,i2c.TRANSMITTER)
msb = read_reg(I2C_ID, I2C_ADDRESS, I2C_TEMP_REG_MSB)
lsb = read_reg(I2C_ID, I2C_ADDRESS, I2C_TEMP_REG_LSB)
val = bit.lshift(msb, 8) + lsb
if bit.isset(msb, 7) then
return (val - 65536)/128
-- MQTT Connection --
MQTT_HOST = "rabbitmq-sysd.containers.ikioma"
MQTT_PORT = 1883
MQTT_CLIENTID = "temp-" .. node.chipid()
MQTT_KEEPALIVE = 120
MQTT_USER = "guest"
MQTT_PASS = "guest"
MQTT_QOS = 1
MQTT_RETAIN = 0
mqtt_connected = false
m = mqtt.Client(MQTT_CLIENTID, MQTT_KEEPALIVE, MQTT_USER, MQTT_PASS)
mqtt_connected = true
m:publish("/connections", MQTT_CLIENTID, MQTT_QOS, MQTT_RETAIN)
mqtt_connected = false
m:lwt("/lwt", MQTT_CLIENTID, MQTT_QOS, MQTT_RETAIN)
m:on("connect", function(con) print ("connected?") end)
mqtt_ip = ""
m:connect(mqtt_ip, MQTT_PORT, 0, 0, mqtt_connected)
mqtt_ip = ip
if mqtt_get_connected() then
m:publish("/" .. MQTT_CLIENTID, get_temp(), MQTT_QOS, MQTT_RETAIN, function(conn) print("sent") end)
if to_advertisement == 0 then
m:publish("/devices", MQTT_CLIENTID, MQTT_QOS, MQTT_RETAIN)
to_advertisement = ADVERTISE_INTERVAL
to_advertisement = to_advertisement - 1
-- MAIN --
i2c.setup(I2C_ID, I2C_PIN_SDA, I2C_PIN_SCL, i2c.SLOW)
sk = net.createConnection(net.TCP, 0)
sk:dns(MQTT_HOST, function(conn, ip) mqtt_connect_with_ip(ip) end)
sk = nil
ADVERTISE_INTERVAL = 10
to_advertisement = 0
-- run "loop" every 10s
tmr.alarm(0, 5000, 1, main_loop)
The datasheet of the ADT7410 temperature sensor can be seen at http://www.kynix.com/Parts/2540563/ADT7410TRZ-REEL.html
|Author:||KevinA [ 28 Oct 2016, 11:06 ]|
|Post subject:||Re: ADT7410 I2C temp sensor works only after a power cycle|
Is the part in shutdown?
The ADT7410 can be placed in shutdown mode by writing 1
to Bit 5 and 1 to Bit 6 of the configuration register (Register
Address 0x03), in which case the entire IC is shut down and
no further conversions are initiated until the ADT7410 is
taken out of shutdown mode. The ADT7410 can be taken
out of shutdown mode by writing 0 to Bit 5 and 0 to Bit 6 in
the configuration register (Register Address 0x03). The
ADT7410 typically takes 1 ms (with a 0.1 μF decoupling
capacitor) to come out of shutdown mode. The conversion
result from the last conversion prior to shutdown can still be
read from the ADT7410 even when it is in shutdown mode.
When the part is taken out of shutdown mode, the internal
clock is started and a conversion is initiated.
I do not see where you're setting up the device with 0x2F.
To reset the ADT7410 without having to reset the entire I2
an explicit reset command is provided. This uses a particular
address pointer word as a command word to reset the part and
upload all default settings. The ADT7410 does not respond to
C bus commands (do not acknowledge) during the default
values upload for approximately 200 μs.
The reset command address word is 0x2F.
Why a $4 part (or $7 for the ADT7420) What is the goal of this design?
Have you looked at VDD of the ADT7410 during power up?
Look at GPIO5/4 - are the lines active during boot before your code?
Generate firmware for the ESP with nothing but a test loop for the ADT.
Does the ADT get VDD from VR1?
What size part is C2 (0402?)
The 'Reset the Part and Upload all default settings' doesn't appear to be happening with the code you have listed.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group