Modifications

Sauter à la navigation Sauter à la recherche
441 octets ajoutés ,  27 février 2022 à 03:13
Ligne 57 : Ligne 57 :  
== Testing the sensor ==
 
== Testing the sensor ==
   −
The Raspberry-Pico offers a 12 bits resolution ADC (effective 8mV resolution. 3.3V/4095).  
+
The Raspberry-Pico offers a 12 bits resolution ADC (effective 0.8mV resolution. 3.3V/4095).  
    
{{ambox|text=The MicroPython ADC expose an unified reading method named {{fname|read_u16()}} returning a 16 bits integer (between 0 and 65535).<br />
 
{{ambox|text=The MicroPython ADC expose an unified reading method named {{fname|read_u16()}} returning a 16 bits integer (between 0 and 65535).<br />
Ligne 63 : Ligne 63 :     
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
 +
# Read the TMP36 analog temperature sensor
 +
#    sensor wired to ADC0 (GP26)
 +
#
 +
from machine import ADC, Pin
    +
adc = ADC(Pin(26))
 +
while True:
 +
    value = adc.read_u16()
 +
    mv = 3300.0 * value / 65535
 +
    temp = (mv-500)/10
 +
    print( 'Temp: %5.2f °C, Voltage: %4i mV' % (temp,mv) )
 +
</syntaxhighlight>
   −
</syntaxhighlight>
+
Which produce the following results
 +
 
 +
<nowiki>Temp: 15.19 °C, Voltage:  651 mV
 +
Temp: 14.87 °C, Voltage:  648 mV
 +
Temp: 14.71 °C, Voltage:  647 mV
 +
</nowiki>
    
{{ENG-CANSAT-PICO-TRAILER}}
 
{{ENG-CANSAT-PICO-TRAILER}}
29 917

modifications

Menu de navigation