From 403ff7f550059473ea86acde23164e2f0e9ef5e6 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Fri, 3 Aug 2018 15:35:03 +0200 Subject: [PATCH] Add : cut power to the GPS module if gps_enable if False to save battery --- circuitpython/code/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/circuitpython/code/main.py b/circuitpython/code/main.py index 1fb70a6..5984f5d 100644 --- a/circuitpython/code/main.py +++ b/circuitpython/code/main.py @@ -50,6 +50,7 @@ import gc, os import time, rtc from busio import I2C, UART from analogio import AnalogIn +from digitalio import DigitalInOut, Direction from adafruit_bme280 import Adafruit_BME280_I2C from adafruit_gps import GPS @@ -237,13 +238,20 @@ bme280 = Adafruit_BME280_I2C(i2c, address=0x76) # Battery voltage vbat = AnalogIn(board.D9, ) +gps_en_pin = DigitalInOut(board.A5) +gps_en_pin.direction = Direction.OUTPUT + # GPS on FeatherWing board +gps_en_pin.value = not gps_enable if gps_enable: gps_uart = UART(board.TX, board.RX, baudrate=9600, timeout=3000) gps = GPS(gps_uart) # Turn on the basic GGA and RMC info gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') gps.send_command('PMTK220,1000') # 1000 ms refresh rate +else: + print("GPS dis") + gps_en_pin = False # Integrated Neopixel if data_to_neopixel: