Add : cut power to the GPS module if gps_enable if False to save battery

This commit is contained in:
Pierrick C 2018-08-03 15:35:03 +02:00
parent b08a56b204
commit 403ff7f550
1 changed files with 8 additions and 0 deletions

View File

@ -50,6 +50,7 @@ import gc, os
import time, rtc import time, rtc
from busio import I2C, UART from busio import I2C, UART
from analogio import AnalogIn from analogio import AnalogIn
from digitalio import DigitalInOut, Direction
from adafruit_bme280 import Adafruit_BME280_I2C from adafruit_bme280 import Adafruit_BME280_I2C
from adafruit_gps import GPS from adafruit_gps import GPS
@ -237,13 +238,20 @@ bme280 = Adafruit_BME280_I2C(i2c, address=0x76)
# Battery voltage # Battery voltage
vbat = AnalogIn(board.D9, ) vbat = AnalogIn(board.D9, )
gps_en_pin = DigitalInOut(board.A5)
gps_en_pin.direction = Direction.OUTPUT
# GPS on FeatherWing board # GPS on FeatherWing board
gps_en_pin.value = not gps_enable
if gps_enable: if gps_enable:
gps_uart = UART(board.TX, board.RX, baudrate=9600, timeout=3000) gps_uart = UART(board.TX, board.RX, baudrate=9600, timeout=3000)
gps = GPS(gps_uart) gps = GPS(gps_uart)
# Turn on the basic GGA and RMC info # 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('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 gps.send_command('PMTK220,1000') # 1000 ms refresh rate
else:
print("GPS dis")
gps_en_pin = False
# Integrated Neopixel # Integrated Neopixel
if data_to_neopixel: if data_to_neopixel: