Skip to content

Commit

Permalink
Merge pull request #1 from SamEureka/refactor-oled
Browse files Browse the repository at this point in the history
oled_waiting function done
  • Loading branch information
SamEureka authored Feb 3, 2022
2 parents 812f6bd + 8abf458 commit 6b6c4c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
32 changes: 18 additions & 14 deletions code.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,33 @@
# Init PM2.5 sensor over UART
pm25 = PM25_UART(uart, reset_pin)

def oled_waiting(wait_seconds):
counter = wait_seconds /5
place = 4
for _ in range(counter):
print(place)
oled.text('.', place, 24 , 1)
oled.show()
place = place + 6
time.sleep(5)

# Wait while sensor initializes. 30 seconds works
oled.fill(0)
oled.text('Found PM2.5 sensor,', 4,4,1)
oled.text('initializing.......', 4,14,1)
oled.show()
time.sleep(5)
oled.text('.', 4,24,1)
oled.show()
time.sleep(5)
oled.text('.', 10,24,1)
oled.show()
time.sleep(5)
oled.text('.', 16,24,1)
oled.show()
time.sleep(5)
oled.text('.', 22,24,1)
oled.show()
time.sleep(10)
oled_waiting(5)



while True:
try:
aqdata = pm25.read()
# print(aqdata)
if aqdata["particles 03um"] == 0:
oled.fill(0)
oled.text("ain't shit here, Hoss...",4,4,1)
oled.show()
print(aqdata)
except RuntimeError:
oled.fill(0)
oled.text('mistakes were made...', 4,4,1)
Expand Down
14 changes: 14 additions & 0 deletions output_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pm10 env": 7,
"pm100 env": 10,
"pm100 standard": 10,
"particles 03um": 1326,
"pm25 standard": 10,
"particles 10um": 46,
"pm10 standard": 7,
"pm25 env": 10,
"particles 05um": 371,
"particles 25um": 4,
"particles 100um": 0,
"particles 50um": 0
}

0 comments on commit 6b6c4c4

Please sign in to comment.