Modifications
Sauter à la navigation
Sauter à la recherche
← Modification précédente
ENG-CANSAT-PICO-TMP36
(voir la source)
Version du 8 décembre 2022 à 21:50
422 octets ajoutés
,
8 décembre 2022 à 21:50
→Improving the code
Ligne 105 :
Ligne 105 :
A good way to improve stability in the readings is to preform a means calculation over several reading.
A good way to improve stability in the readings is to preform a means calculation over several reading.
+
<syntaxhighlight lang="python">
+
# Mean read the TMP36 analog temperature
+
# sensor wired to ADC0 (GP26)
+
#
+
from machine import ADC, Pin
+
import time
+
adc = ADC(Pin(26))
+
while True:
+
value = 0
+
for i in range(10):
+
value += adc.read_u16()
+
value /= 10
+
mv = 3300.0 * value / 65535
+
temp = (mv-500)/10
+
print( 'Temp: %5.2f °C, Voltage: %4i mV' % (temp,mv) )
+
time.sleep(0.100 )
+
</syntaxhighlight>
{{ENG-CANSAT-PICO-TRAILER}}
{{ENG-CANSAT-PICO-TRAILER}}
Admin
Bureaucrates
,
Administrateurs
29 917
modifications
Menu de navigation
Outils personnels
Se connecter
Espaces de noms
Page
Discussion
Variantes
Affichages
Lire
Voir le texte source
Voir l’historique
Plus
Rechercher
Navigation
ARDUINO
RASPBERRY-PI
[:: PI Hacking ::]
Particle.IO
Micro Python
Imprimante 3D
Actualités
Modifications récentes
Page au hasard
Aide
Outils
Pages spéciales
Version imprimable