Shop OBEX P1 Docs P2 Docs Learn Events
Connecting P2 to LM334Z temperature sensor - MicroPython / Mu demo — Parallax Forums

Connecting P2 to LM334Z temperature sensor - MicroPython / Mu demo

Here's some code and screenshots from todays zoom demo

Connect the LM334Z between 3v3 and Pin 19. Tune the resistor for around 635 ohms to place output around midpoint (1.65v), allowing zoom in

1920 x 1080 - 189K
1280 x 720 - 116K
1920 x 1080 - 244K

Comments

  • also Emesystems did a great tutorial on constructing small LM334Z probes @"Tracy Allen"
    https://www.emesystems.com/OLDSITE/EarthM/TK334fab.pdf

    1920 x 1080 - 513K
  • Here's the MicroPython code for putting into Mu
    # 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()
    
Sign In or Register to comment.