PySense 2 Accelerometer sampling rate



  • Hello,

    Recently purchased a Lopy4 with a Pysense 2 to try to make measurements at 100Hz from the accelerometer included in the Pysense 2.
    After several attempts I am stuck at about 26Hz. :(

    The Lopy4 is up to date with the latest firmware and I am using the latest version of LIS2HH12.py with "ODR_100_HZ" ON.
    On the other hand I can't update the Pysense 2 maybe it comes from there?

    Despite the many posts in the forum on the subject I can't find an "clear" answer to this question.

    Below is the draft code I use (largely inspired by another post):

    import time
    import pycom
    from pycoproc_1 import Pycoproc
    import machine
    import utime
    
    from machine import RTC
    from LIS2HH12 import LIS2HH12
    
    pycom.heartbeat(False)
    
    py = Pycoproc(Pycoproc.PYSENSE)
    li = LIS2HH12(py)
    
    # RTC sync
    rtc = RTC()
    rtc.init((2021, 7, 23, 16, 10, 0, 0, 0))
    utime.sleep_ms(250)
    print(rtc.now())
    
    ftime = rtc.now()
    datee = str(ftime[2]) + "/" + str(ftime[1]) + "/" + str(ftime[0])
    
    print("Start of recording")
    t_end = time.time() + 1
    TotalData=[]
    while time.time() < t_end:
        dataString = li.acceleration()
        ttime = rtc.now()
        timee = str(ttime[3]) + ":" + str(ttime[4]) + ":" + str(ttime[5]) 
        fullData2 = datee + "," + timee + "," + str(dataString)
        TotalData.append(fullData2)
        print(fullData2)
    
    print("Length of Total Data is : ")
    print(len(TotalData))
    pycom.rgbled(0x007f00) # green
    time.sleep(1)
    pycom.rgbled(False)
    print("Record is over")```
    code_text
    

    Thanks for your help.


Log in to reply
 

Pycom on Twitter