22
22
23
23
pixels = neopixel .NeoPixel (board .NEOPIXEL , 1 )
24
24
25
-
26
- # SKIFF NOTES 2022-11-06
27
- # When testing on the REPL, to paste code segments, ctrl-e puts you into paste mode
28
- # then paste your code with cmd-c/cmd-v
29
- # then hit ctrl-d and hit enter.
30
-
31
- # DONE: refactor to skip networking stuff and send SMS instead
32
- # TODO: handle queue
33
- # TODO: SMS receiver
34
-
35
25
##################
36
26
## Set pins to safe values in case the sms board is attached
37
27
###################
@@ -272,7 +262,7 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
272
262
pixels .fill ((0 , 0 , 0 ))
273
263
274
264
## MAIN CODE BLOCK
275
-
265
+ reading_interval = int ( secrets [ "reading_interval" ])
276
266
led = digitalio .DigitalInOut (board .LED )
277
267
led .direction = digitalio .Direction .OUTPUT
278
268
@@ -283,29 +273,38 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
283
273
time .sleep (0.5 )
284
274
for x in range (8 ):
285
275
led .value = not led .value
286
- time .sleep (0.5 )
276
+ time .sleep (0.25 )
287
277
288
- print ("Blinking done, now startinging the program" )
289
- ## Set up the realtime clock
290
- r = rtc .RTC ()
291
- print (f"Time at start: { r .datetime } " )
292
278
293
- if (secrets ['sms_mode' ] == "true" ):
294
- init_sms_board ()
295
- try :
296
- r .datetime = time .localtime (fona .get_timestamp ())
297
- except :
298
- flash_warning ()
299
- print (f"Time after getting fona time: { r .datetime } " )
279
+ try :
280
+ print ("Blinking done, now startinging the program" )
281
+ ## Set up the realtime clock
282
+ r = rtc .RTC ()
283
+ print (f"Time at start: { r .datetime } " )
300
284
301
- ## Check on the battery
302
- print ("LC709203F simple test" )
303
- print ("Make sure LiPoly battery is plugged into the board!" )
285
+ if (secrets ['sms_mode' ] == "true" ):
286
+ init_sms_board ()
287
+ try :
288
+ r .datetime = time .localtime (fona .get_timestamp ())
289
+ except :
290
+ flash_warning ()
291
+ print (f"Time after getting fona time: { r .datetime } " )
292
+
293
+ ## Check on the battery
294
+ print ("LC709203F simple test" )
295
+ print ("Make sure LiPoly battery is plugged into the board!" )
304
296
305
- battery_sensor = LC709203F (board .I2C ())
297
+ battery_sensor = LC709203F (board .I2C ())
306
298
307
- print ("IC version:" , hex (battery_sensor .ic_version ))
308
- print ("Battery: Mode: %s / %0.3f Volts / %0.1f %%" % (battery_sensor .power_mode , battery_sensor .cell_voltage , battery_sensor .cell_percent ))
299
+ print ("IC version:" , hex (battery_sensor .ic_version ))
300
+ print ("Battery: Mode: %s / %0.3f Volts / %0.1f %%" % (battery_sensor .power_mode , battery_sensor .cell_voltage , battery_sensor .cell_percent ))
301
+ except Exception as e :
302
+ flash_warning ()
303
+ print ("\n ERROR: Problem during startup." )
304
+ print ('Error message: {}' .format (e ))
305
+ print ("Check your connections." )
306
+ print ('Deep sleep for reading interval ({}) and try again' .format (reading_interval ))
307
+ deep_sleep (reading_interval )
309
308
310
309
try :
311
310
i2c = board .I2C () # uses board.SCL and board.SDA
@@ -317,8 +316,14 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
317
316
except ValueError :
318
317
print ("\n NO SENSOR, not writing to temperatures.txt CIRCUITPY is writeable by computer" )
319
318
flash_status (0 ,0 ,128 ,1 ,1 )
319
+ except Exception as e :
320
+ flash_warning ()
321
+ print ("\n ERROR: Problem during sensor startup." )
322
+ print ('Error message: {}' .format (e ))
323
+ print ("Check your connections." )
324
+ print ('Deep sleep for reading interval ({}) and try again' .format (reading_interval ))
325
+ deep_sleep (reading_interval )
320
326
321
- reading_interval = int (secrets ["reading_interval" ])
322
327
net_connected = False
323
328
if (secrets ['sms_mode' ] != "true" ):
324
329
try :
@@ -429,9 +434,7 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
429
434
# Create an alarm that will trigger at the next reading interval seconds from now.
430
435
print ('Deep sleep for reading interval ({}) until the next send' .format ( reading_interval ))
431
436
deep_sleep (reading_interval )
432
- except OSError as e : # Typically when the filesystem isn't writeable...
433
- if e .args [0 ] == 28 : # If the file system is full...
434
- print ("\n ERROR: filesystem full\n " )
437
+ except Exception as e : # Typically when the filesystem isn't writeable...
435
438
flash_warning ()
436
439
print ("\n WARN: not writing temp to file, or sending to Heat Seek" )
437
440
print ("This is likely because sensor is not attached and the filesystem was writable by USB" )
0 commit comments