Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: heatseeknyc/heatseek-esp32-s2-circuitpy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.5-fona
Choose a base ref
...
head repository: heatseeknyc/heatseek-esp32-s2-circuitpy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: es/fona-support
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Nov 15, 2022

  1. Copy the full SHA
    60991b8 View commit details

Commits on Nov 19, 2022

  1. Copy the full SHA
    a0935f2 View commit details

Commits on Nov 22, 2022

  1. VOLT_DIFF_FOR_CHARGE = 0.06

    ericskiff committed Nov 22, 2022
    Copy the full SHA
    4a0ebea View commit details

Commits on Nov 28, 2022

  1. Copy the full SHA
    7a86dd5 View commit details
Showing with 40 additions and 37 deletions.
  1. +39 −36 code.py
  2. BIN lib/neopixel.mpy
  3. +1 −1 secrets.py.example
75 changes: 39 additions & 36 deletions code.py
Original file line number Diff line number Diff line change
@@ -22,16 +22,6 @@

pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)


# SKIFF NOTES 2022-11-06
# When testing on the REPL, to paste code segments, ctrl-e puts you into paste mode
# then paste your code with cmd-c/cmd-v
# then hit ctrl-d and hit enter.

# DONE: refactor to skip networking stuff and send SMS instead
# TODO: handle queue
# TODO: SMS receiver

##################
## Set pins to safe values in case the sms board is attached
###################
@@ -58,8 +48,8 @@

## URL
HEATSEEK_URL = "http://relay.heatseek.org/temperatures"
CODE_VERSION = "F-ESP-1.3.2"
VOLT_DIFF_FOR_CHARGE = 0.03
CODE_VERSION = "F-ESP-1.3.3"
VOLT_DIFF_FOR_CHARGE = 0.06
QUIET_MODE_SLEEP_LENGTH = 600

## FUNCTIONS
@@ -74,7 +64,7 @@ def init_sms_board():
time.sleep(LTE_SHIELD_POWER_PULSE_PERIOD)
# power_pin.switch_to_input()

uart = busio.UART(board.TX, board.RX, baudrate=9600)
uart = busio.UART(board.TX, board.RX, baudrate=115200)
# uart = board.UART()
global fona
fona = FONA(uart, reset_pin)
@@ -272,7 +262,7 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
pixels.fill((0, 0, 0))

## MAIN CODE BLOCK

reading_interval = int(secrets["reading_interval"])
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

@@ -283,29 +273,38 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
time.sleep(0.5)
for x in range(8):
led.value = not led.value
time.sleep(0.5)
time.sleep(0.25)

print("Blinking done, now startinging the program")
## Set up the realtime clock
r = rtc.RTC()
print(f"Time at start: {r.datetime}")

if (secrets['sms_mode'] == "true"):
init_sms_board()
try:
r.datetime = time.localtime(fona.get_timestamp())
except:
flash_warning()
print(f"Time after getting fona time: {r.datetime}")
try:
print("Blinking done, now startinging the program")
## Set up the realtime clock
r = rtc.RTC()
print(f"Time at start: {r.datetime}")

## Check on the battery
print("LC709203F simple test")
print("Make sure LiPoly battery is plugged into the board!")
if (secrets['sms_mode'] == "true"):
init_sms_board()
try:
r.datetime = time.localtime(fona.get_timestamp())
except:
flash_warning()
print(f"Time after getting fona time: {r.datetime}")

## Check on the battery
print("LC709203F simple test")
print("Make sure LiPoly battery is plugged into the board!")

battery_sensor = LC709203F(board.I2C())
battery_sensor = LC709203F(board.I2C())

print("IC version:", hex(battery_sensor.ic_version))
print("Battery: Mode: %s / %0.3f Volts / %0.1f %%" % (battery_sensor.power_mode, battery_sensor.cell_voltage, battery_sensor.cell_percent))
print("IC version:", hex(battery_sensor.ic_version))
print("Battery: Mode: %s / %0.3f Volts / %0.1f %%" % (battery_sensor.power_mode, battery_sensor.cell_voltage, battery_sensor.cell_percent))
except Exception as e:
flash_warning()
print("\nERROR: Problem during startup.")
print('Error message: {}'.format(e))
print("Check your connections.")
print('Deep sleep for reading interval ({}) and try again'.format(reading_interval))
deep_sleep(reading_interval)

try:
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):
except ValueError:
print("\nNO SENSOR, not writing to temperatures.txt CIRCUITPY is writeable by computer")
flash_status(0,0,128,1,1)
except Exception as e:
flash_warning()
print("\nERROR: Problem during sensor startup.")
print('Error message: {}'.format(e))
print("Check your connections.")
print('Deep sleep for reading interval ({}) and try again'.format(reading_interval))
deep_sleep(reading_interval)

reading_interval = int(secrets["reading_interval"])
net_connected = False
if (secrets['sms_mode'] != "true"):
try:
@@ -429,9 +434,7 @@ def fade_up_status(red=128, green=128, blue=128, fade_length=2, repeat=1):
# Create an alarm that will trigger at the next reading interval seconds from now.
print('Deep sleep for reading interval ({}) until the next send'.format( reading_interval))
deep_sleep(reading_interval)
except OSError as e: # Typically when the filesystem isn't writeable...
if e.args[0] == 28: # If the file system is full...
print("\nERROR: filesystem full\n")
except Exception as e: # Typically when the filesystem isn't writeable...
flash_warning()
print("\nWARN: not writing temp to file, or sending to Heat Seek")
print("This is likely because sensor is not attached and the filesystem was writable by USB")
Binary file added lib/neopixel.mpy
Binary file not shown.
2 changes: 1 addition & 1 deletion secrets.py.example
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ secrets = {
"timezone": "America/New_York", # Check http://worldtimeapi.org/timezones
"cell_id": "feather_AAA",
"reading_interval": "3601",
"sms_mode": "false",
"sms_mode": "true",
}

## NOTE: Before sending a device to a user, enable "quiet mode" by creating