# P2 "Hello LM334Z" MicroPython demo, by Team-oz 23 DEC 2020
# Hook a LM334z from 3v3 to pin 19.
# Tune adjustment resistor to center around 1.65v at temperature of interest, so can zoom in (approx 635 ohms)
import machine # machine contains P2 specific functions, eg Pin for I/O pin access
import time # time contains time delay routines (sleep)
p=machine.Pin(19) # our LM334Z is on pin 19
p.wrpin(p.P_LOW_15K | p.P_ADC_10X| p.P_COUNT_HIGHS | p.P_TT_01 ) # bias the LM334Z with 15k resistor
p.wxpin(1000000) # each ADC bucket accumulates for 1 million clocks (~252 Hz)
p.off() # start the current source and observations
time.sleep_ms(300) # give it time to get first readings
r=range(121) # plot 100 readings to Mu plot window
baseline=p.rdpin()
print('baseline=' , baseline) # record a baseline ('zero point')
for i in r:
print('(',p.rdpin()-baseline,')') # Mu plotted needs values in normal braces to work. Offset towards zero
time.sleep_ms(150) # take around 3 readings per second (expt lasts 30 seconds)
p.float()
Comments
https://www.emesystems.com/OLDSITE/EarthM/TK334fab.pdf