Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    PySense hardware versions 1.0 vs 1.1 with Lopy - battery lifetime issue

    Scheduled Pinned Locked Moved Discussion
    pysenselopybattery powereddeep sleep
    1 Posts 1 Posters 514 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      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

      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • 1 / 1
      • First post
        Last post

      Pycom on Twitter

      Pycom