PySense hardware versions 1.0 vs 1.1 with Lopy - battery lifetime issue
b3da last edited by
Hi, I'm working on a prototype with Pysense + Lopy + 3xAA batteries as power source.
When I'm using a Lopy (Firmware 1.17.5.b6) on my Pysense V1.1 (Firmware 0.0.8), the power consumption looks ok and the battery slowly drains.
If I take the exact same Lopy with no Software changes and put it on a Pysense V1.0 the battery drains much faster.
I have no idea how this is possible, since there should be no difference between V1 and V1.1!?
I just want to send temperature + humidity to my gateway and go back to deepsleep.
Here is my code:
(there a some useless parts - temp1, temp2, temp3 etc which I am sending over LORA, because if everything is working correctly, I want to send more data. But first I have to find my battery issue)
from pysense import Pysense from SI7006A20 import SI7006A20 from si7021 import SI7021 from network import LoRa import binascii import socket import struct import machine import time import pycom import utime from machine import I2C, Pin from machine import WDT import uos wdt = WDT(timeout=60000) # 60 sec - watchdog pycom.heartbeat(False) # turn off heartbeat _VERSION_SENSOR = 1.14 # A basic package header # B: 1 byte for the deviceId # B: 1 byte for the pkg size # B: 1 byte for the messageId # %ds: Formated string for string _LORA_PKG_FORMAT = "!BBB%ds" _LORA_PKG_ACK_FORMAT = "BBBB" _LORA_PKG_LONG_ACK_FORMAT = "BBBBB" # This device ID, use different device id for each device _DEVICE_ID = 0x04 wdt.feed() WIFI_MAC = binascii.hexlify(machine.unique_id()).upper() py = Pysense() if (py.read_fw_version() < 8): while(True): pycom.rgbled(0x001111) time.sleep(3) print('read_fw_version: '+str(py.read_fw_version())) print('uos.uname(): '+str(uos.uname())) si = SI7006A20(py) temp2 = si.temperature() hum = si.humidity() temp3 = 99.99 voltage = py.read_battery_voltage() temp1 = temp2 pressure = 90000 lowest = 0 highest = 0 myMessage = WIFI_MAC+ ';%.2f;%.2f;%.2f;%i;%i;%.0f;%.2f;%.2f' % (temp1, temp2, hum, lowest, highest, pressure, temp3, voltage) msg_id = 1 lora = LoRa( mode=LoRa.LORA, region=LoRa.EU868, frequency=868100000, power_mode=LoRa.TX_ONLY, tx_power=7, bandwidth=LoRa.BW_125KHZ, sf=9, preamble=8, coding_rate=LoRa.CODING_4_8, #CODING_4_8 tx_iq=False, rx_iq=False ) lora_sock = socket.socket(socket.AF_LORA, socket.SOCK_RAW) lora_sock.setblocking(True) pkg = struct.pack(_LORA_PKG_FORMAT % len(myMessage), _DEVICE_ID, len(myMessage), msg_id, myMessage) lora_sock.send(pkg) sleep = 60*15 if (voltage > 1): if (voltage < 3.33): sleep = 60*60*24 elif (voltage < 3.4): sleep = 60*60 elif (voltage < 3.5): sleep = 60*45 elif (voltage < 3.55): sleep = 60*30 py.setup_sleep(sleep) py.go_to_sleep()
Does anybody know, why there could be a difference between V1.0 and V1.1 of the Pysense?
What could I do, to extend the battery lifetime? If i use sf7 or sf8, my packets are not received reliable.
Any help is appreciated :)
Thanks in advance