2017年2月28日 星期二

Micropython PM2.5 Sensor Sharp GP2Y1010AU0F











#https://laurentblogs.wordpress.com/2017/01/09/capteur-de-poussieres-et-micropython-partie-1/


UMesure ADC
12345678910
0.003334333333
0.2586868686868686868686
0.50170170170170171170171170170170
1.00334334334334334334334334334334
1.50502502502502502502502502502502

La configuration de l’entrée adc :
import machine
adc = machine.ADC(0)
Lecture du convertisseur :
adc.read()


U(V)ADC
0.003
0.2586
0.50170
0.75254
1.00334
1.25416
1.50502
1.75585
2.00666
2.25750
2.50833
2.75915
3.001000
3.051017
3.061021
3.071024
3.081024
3.091024
3.101024
3.081024
3.091024
3.101024












































































# ADC : A0
# ILED : D3 / GIPO00
#=====================================================================
from machine import Pin, ADC
import time
p0 = Pin(5, Pin.OUT)
adc = ADC(0)
def measure():
p0.high()                       # d?but du cr?neau
time.sleep_us(280)         # les 0.28 ms
readvalue = adc.read()    # lecture de l’adc
time.sleep_us(40)           # compl?ment du cr?neau ? 0.32 ms
p0.low()                        # fin du cr?neau
time.sleep_us(9680)       # compl?ment du cycle ? 10 ms
return readvalue
#--------------------------------------
print('PM2.5 Result:')
t,tot,t1=0,0,0
ppm=0.0
t1=measure()
print('Test measure Value :  ',t1,'---- this value always too low')
for i in range(10): # on fait 10 mesures
t=measure()
print(i,"---",t)
tot=tot+t
ppm=tot/10
tot2='PM2.5 Value = '+str(ppm)[:5]
print(tot2)
print('Finish.....')

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...