[SOLVED] I2C reliability reading second byte issue
Posted: Fri Sep 01, 2017 2:08 pm
Been learning how to use i2c under Micropython. I've figured most of it out, but I have a frustrating issue with reliably receiving the second temperature data byte from my temperature sensor. I've even lowered the i2c frequency down to 1KHz and I'm still not receiving the second data byte occasionally.
I did a very similar configuration a while back under the Arduino IDE, and everything was rock-solid.
My configuration:
Wemos D1 Mini
DS1631+ i2c temp sensor (https://datasheets.maximintegrated.com/ ... DS1731.pdf)
4.7k pull-ups and a .1uF cap near the sensor
a sample of the output:
I did a very similar configuration a while back under the Arduino IDE, and everything was rock-solid.
My configuration:
Wemos D1 Mini
DS1631+ i2c temp sensor (https://datasheets.maximintegrated.com/ ... DS1731.pdf)
4.7k pull-ups and a .1uF cap near the sensor
Code: Select all
import time
import machine
from machine import Pin, I2C
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=1000) # pins d1 for clk and D2 for sda
time.sleep(2)
i2c.writeto(76,b'\x51') #set advanced temp sense to startup
def read_advanced_temp():
i2c.writeto(76,b'\xAA')
temp = i2c.readfrom(76,2)
print(temp)
while True:
time.sleep(3)
read_advanced_temp()
Code: Select all
b'\x1a\xd0'
b'\x1b\x80'
b'\x1c0'
b'\x1c\xb0'
b'\x1c\xa0'