Sample rate grovepi

Dear All,
I am Bruno and I am novice in Python. I need some help on a little project.
I bought a Raspi4 with a grovepi kit.
I tried to read from a sensor with this code:

import grovepi
import os
pot=1
while True:
    text_file = open("sample.txt", "w")
    for z in range(1,50000,1):
        x=grovepi.analogRead(pot)
        print(x,z)
        time.sleep(0.01)
        text_file.write(str(x)+"\n")
    text_file.close()

It seems very very slow… If I try to decrease time sleep to 0.005, the code does not start…
I also tried to directly acquire from an arduino instead of the grovepi board and here the sample rate is higher.
Is there a maximum limit of sample/sec that i can read with the grove board?
Thank you very much for your help

Bruno

1 Like

Which Pi, and what operating system is running?

If you’re using a Pi-4, that might be part of the problem as the Pi-4 is way too fast for the older Grove-Pi software.

Viz.: