Pycoproc function TypeError: function takes 2 positional arguments but 1 were given in PySense board i am trying to use accelerometer wake up interrupt example from pycom webpage
-
I am trying to use accelerometer movement as interrupt to wake the pysense board, but when creating an object for pycoproc() function and uploading it to board, there is a typeError show as it require 2 positional argument but only 1 were given.
i am run the same code given in the pycom examples.
Here is the code:# This script demonstrates two examples: # * go to ultra low power mode (~10uA @3.75V) with all sensors, incl accelerometer and also pycom module (Fipy, Gpy, etc) off - tap the MCLR button for this # * go to low power mode (~165uA @3.75V) with accelerometer on, pycom module in deepsleep and wake from accelerometer interrupt - hold the MCLR button down for this # See https://docs.pycom.io for more information regarding library specifics import time import pycom import struct from machine import Pin from pycoproc import Pycoproc import machine from LIS2HH12 import LIS2HH12 from SI7006A20 import SI7006A20 from LTR329ALS01 import LTR329ALS01 from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE def accelerometer(): print("ACCELEROMETER:", "accel:", accelerometer_sensor.acceleration(), "roll:", accelerometer_sensor.roll(), "pitch:", accelerometer_sensor.pitch(), "x/y/z:", accelerometer_sensor.x, accelerometer_sensor.y, accelerometer_sensor.z ) def activity_int_handler(pin_o): if pin_o(): print('[Activity]') pycom.rgbled(0x00000A) # blue else: print('[Inactivity]') pycom.rgbled(0x0A0A00) # yellow def activity_int_handler_none(pin_o): pass ############################################################### sleep_time_s = 300 # 5 min pycom.heartbeat(False) pycom.rgbled(0x0a0a0a) # white print("pycoproc init") py = Pycoproc() print("battery {:.2f} V".format(py.read_battery_voltage())) py.setup_sleep(sleep_time_s) # init accelerometer accelerometer_sensor = LIS2HH12() # read accelerometer sensor values accelerometer() print("enable accelerometer interrupt") # enable_activity_interrupt( [mG], [ms], callback) # accelerometer_sensor.enable_activity_interrupt(8000, 200, activity_int_handler) # low sensitivty # accelerometer_sensor.enable_activity_interrupt(2000, 200, activity_int_handler) # medium sensitivity accelerometer_sensor.enable_activity_interrupt( 100, 200, activity_int_handler) # high sensitivity # accelerometer_sensor.enable_activity_interrupt(63, 160, activity_int_handler) # ultra sensitivty print("enable pycom module to wake up from accelerometer interrupt") wake_pins = [Pin('P13', mode=Pin.IN, pull=Pin.PULL_DOWN)] machine.pin_sleep_wakeup(wake_pins, machine.WAKEUP_ANY_HIGH, True) print("put pycoproc to sleep and pycom module to deepsleep") py.go_to_sleep(pycom_module_off=False, accelerometer_off=False, wake_interrupt=True) machine.deepsleep(sleep_time_s * 1000) print("we never reach here!")
and here is the output error:
Smart Provisioning started in the background See https://docs.pycom.io/smart for details pycoproc init Traceback (most recent call last): File "Chandan_deepsleep_code.py", line 39, in <module> TypeError: function takes 2 positional arguments but 1 were given Pycom MicroPython 1.20.2.r1 [v1.11-09d3ee1] on 2020-02-09; FiPy with ESP32 Pybytes Version: 1.3.1
Plese help me in resolving these error as i am new to these topics.
-
Depending on which hardware version of the Pysense you're using, you should load the correct pycoproc file. You can find the latest versions of the file here: https://github.com/pycom/pycom-libraries/tree/master/shields/lib
pycoproc_2.py
is for Pysense v2.0 X, wherepycoproc_1.py
is for Pysense 1. This also changes the initialisation argument. For Pysense 1, you should putpy = Pycoproc(Pycoproc.PYSENSE)
, whereas Pycoproc 2 does not require an argumentTo get a working example, you can load one of the zip files from here: https://github.com/pycom/pycom-libraries/releases/tag/v2.0.0 for the correct board version