Button B beeps morse and records the milli second time stamp
Next make a buffered record of ON OFF button presses along with the time stamps so that a non interrupt function can determine which morse values have been entered. This can then be displayed on the screen. This is based on the PicoAirQ code atmo. In the fututre there may be a microphone amplified and filtered to only hear morse frquencies at audio. this pcb could then listen to morse being played and decode it. An RS-232 output could be used for logging to other computers etc.
This commit is contained in:
parent
88b6331b9a
commit
12846d5a8a
1225
PicoAirQuality.py
Normal file
1225
PicoAirQuality.py
Normal file
File diff suppressed because it is too large
Load Diff
115
main.py
Normal file
115
main.py
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
# A weather station program display the date, time, temperature and humidity on the OLED screen with Air Quality and eCO2 on ZIP LEDs (Red/Green)
|
||||
from PicoAirQuality import KitronikBME688, KitronikButton, KitronikDataLogger, \
|
||||
KitronikOLED, KitronikRTC, KitronikZIPLEDs,\
|
||||
KitronikBuzzer
|
||||
import time
|
||||
|
||||
#from datetime import datetime
|
||||
|
||||
logFileName = "atmosphere_log.txt"
|
||||
|
||||
|
||||
bme688 = KitronikBME688()
|
||||
oled = KitronikOLED()
|
||||
rtc = KitronikRTC()
|
||||
zipleds = KitronikZIPLEDs(3)
|
||||
# Python u arse hole sec = Integer()
|
||||
rtc.setDate(16, 7, 2022)
|
||||
rtc.setTime(12, 10, 0)
|
||||
|
||||
bme688.setupGasSensor()
|
||||
bme688.calcBaselines()
|
||||
sec = 0
|
||||
#f = open(logFileName, 'a')
|
||||
#f.write("# Data Logging: Date, Time, Temperature, Pressure, Humidity, AirQuality, CO2\n")
|
||||
|
||||
beeper = KitronikBuzzer()
|
||||
buttons = KitronikButton()
|
||||
|
||||
def ButtonB_r_IRQHandler(pin):
|
||||
global buttonB
|
||||
buttonB = 2*60
|
||||
print("button B pressed", buttonB)
|
||||
|
||||
def ButtonB_f_IRQHandler(pin):
|
||||
#now = time.now()
|
||||
global buttonB
|
||||
buttonB = 2*60
|
||||
print("button B released", buttonB, pin.value(),time.ticks_ms())
|
||||
if pin.value():
|
||||
beeper.playTone(600)
|
||||
else:
|
||||
beeper.stopTone()
|
||||
|
||||
|
||||
# FALLING DOES NOT WORK AND IRQ_LOW_LEVEL not recognised
|
||||
buttons.buttonB.irq(trigger=machine.Pin.IRQ_FALLING|machine.Pin.IRQ_RISING, handler=ButtonB_f_IRQHandler)
|
||||
#buttons.buttonB.irq(trigger=machine.Pin.IRQ_RISING, handler=ButtonB_r_IRQHandler)
|
||||
|
||||
while True:
|
||||
|
||||
if sec == 0:
|
||||
f = open(logFileName, 'a+')
|
||||
f.write("# Data Logging: Date, Time, Temperature, Pressure, Humidity, AirQuality, CO2\n")
|
||||
f.write('# Restarted ' + str(rtc.readDateString()) + ' ' + str(rtc.readTimeString()) + '\n' )
|
||||
time.sleep_ms(1000)
|
||||
bme688.measureData()
|
||||
oled.clear()
|
||||
|
||||
#oled.drawRect(4, 5, 120, 35)
|
||||
oled.displayText(rtc.readDateString(), 1, 25)
|
||||
oled.displayText(rtc.readTimeString(), 2, 33)
|
||||
#oled.drawLine(0, 48, 127, 48)
|
||||
#oled.drawLine(0, 49, 127, 49)
|
||||
oled.displayText(str(bme688.readTemperature()) + " oC", 3, 0)
|
||||
oled.displayText(str(bme688.readHumidity()) + " %H", 3, 80)
|
||||
eCO2 = bme688.readeCO2()
|
||||
oled.displayText(str(eCO2) + " CO2 ppm", 4, 0)
|
||||
IAQ = bme688.getAirQualityScore()
|
||||
oled.displayText(str(IAQ) + " AQ ", 5, 0)
|
||||
mbar = bme688.readPressure()/100.0
|
||||
oled.displayText(str(mbar) + " mB ", 5, 50)
|
||||
oled.show()
|
||||
|
||||
if (IAQ < 100):
|
||||
zipleds.setLED(0, zipleds.GREEN)
|
||||
else:
|
||||
zipleds.setLED(0, zipleds.RED)
|
||||
if (eCO2 < 800):
|
||||
zipleds.setLED(2, zipleds.GREEN)
|
||||
else:
|
||||
zipleds.setLED(2, zipleds.RED)
|
||||
zipleds.setBrightness(10)
|
||||
|
||||
|
||||
# ffs all I want is an action every minute I hate python scope shit
|
||||
#now = rtc.readTimeString();
|
||||
# log every minute, thats 1440 records a day
|
||||
sec = sec + 1
|
||||
secmod = sec % 29
|
||||
if (secmod) == 0:
|
||||
#log.setupDataFields("Date", "Time", "Temperature", "Pressure", "Humidity", "IAQ", "eCO2")
|
||||
log_string = (rtc.readDateString() + ',' + \
|
||||
rtc.readTimeString() + ',' + \
|
||||
str(bme688.readTemperature()) + ',' + \
|
||||
str(bme688.readPressure()) + ',' + \
|
||||
str(bme688.readHumidity())+ ',' + \
|
||||
str(bme688.getAirQualityScore()) + ',' + \
|
||||
str(bme688.readeCO2())) + '\n'
|
||||
#print (log_string)
|
||||
#print ("logging data\n")
|
||||
f.write(log_string)
|
||||
f.flush()
|
||||
zipleds.setLED(1, zipleds.RED)
|
||||
elif (secmod < 10):
|
||||
zipleds.setLED(1, zipleds.BLUE)
|
||||
elif (secmod > 10):
|
||||
s2 = secmod * 2
|
||||
zip_col = (secmod, s2, s2)
|
||||
zipleds.setLED(1, zip_col)
|
||||
|
||||
if ( (sec+1) % 2 ) == 0:
|
||||
zipleds.setLED(1, zipleds.BLACK)
|
||||
|
||||
zipleds.show()
|
Loading…
Reference in New Issue
Block a user