TMP144 Texas Instruments UART #13058
-
Hello everyone, right now I am working on a project with the TMP144 temperature sensor from Texas Instruments and I cant seem to get it working. My driver so far: from machine import UART, Pin
from time import sleep_ms
CMD_SOFT_RESET=0xB4
CMD_GLOBAL_INIT=0x8C
CMD_GLOBAL_ADDRESS_ASSIGN=0x90
CMD_GLOBAL_READ_TEMP=0xF1
CALIBRATION_BYTE=0x55
class TMP144:
def __init__(self, tx_pin=12, rx_pin=13, baud_rate=9600):
self.uart = UART(0, baudrate=baud_rate, tx=Pin(tx_pin), rx=Pin(rx_pin))
self._reset()
self._setup()
def _reset(self):
self.uart.write(bytes([CALIBRATION_BYTE, CMD_SOFT_RESET]))
self.uart.flush()
def _setup(self):
databuf = bytes([
CALIBRATION_BYTE,
CMD_GLOBAL_INIT,
CMD_GLOBAL_ADDRESS_ASSIGN
])
self.uart.write(databuf)
self.uart.flush()
sleep_ms(10)
print(self.uart.read())
def read_temp(self):
buffer = bytes([CALIBRATION_BYTE, CMD_GLOBAL_READ_TEMP])
self.uart.write(buffer)
data = self.uart.read()
return data
sensor = TMP144()
print(sensor.read_temp()) The output I am currently getting is
Anyone that might have experience with this sensor that is able to help me? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
a) You surely considered that GPIO pin 12 is board pin 16, GPIO pin 13 is board pin 17. |
Beta Was this translation helpful? Give feedback.
-
I just played with TMP144 so I wrote basic class as example
|
Beta Was this translation helpful? Give feedback.
I just played with TMP144 so I wrote basic class as example