Pidog sound direction - behavior change when calling rgb_strip - Possible bug?

Hello,
I was just wondering if someone else could run a simple test to verify if this is a bug or my system behave differently.

Test file: pidog/basic_examples/11_sound_direction_read.py

When I run this script, I always get one direction detected as console log below:

config_file: /home/sia/.config/pidog/pidog.conf
robot_hat init … done
imu_sh3001 init … done
rgb_strip init … done
dual_touch init … done
sound_direction init … done
sound_effect init … done
sound direction: 250
ultrasonic init … done

This by itself is quite strange because no sound should be detected at all. So it has a first time false positive.

Now, if I add:
my_dog.rgb_strip.set_mode(“breath”, “blue”, bps=0.2)
before while loop

from pidog import Pidog

my_dog = Pidog()
my_dog.rgb_strip.set_mode("breath", "blue", bps=0.2)
try:
    while True:
        if my_dog.ears.isdetected():
            direction = my_dog.ears.read()
            print(f"sound direction: {direction}")
finally:
    my_dog.close()

I get false reading in every read.
Here is a sample of console log:

config_file: /home/sia/.config/pidog/pidog.conf
robot_hat init … done
imu_sh3001 init … done
rgb_strip init … done
dual_touch init … done
sound_direction init … done
sound_effect init … done
sound direction: 71
ultrasonic init … done
sound direction: 130
sound direction: 129
sound direction: 129
sound direction: 129
sound direction: 129
sound direction: 129
sound direction: 129
sound direction: 129

It keeps detecting false sound/reading.( terminated the program manually)

Just want to know if this is a known problem or there is something wrong in my setup.

By the way, there are two LED on the back of sound direction sensor. One is green and the other is red. Anyone knows what they indicate? D2 is green, D1 is red

Thank you

When you run the example, the sound-producing device must be activated before the sound direction sensor prints the readings. If you plug and unplug the sound direction sensor directly after running the example, it may cause the printed readings to become blocked, resulting in continuous detection errors in sound/readings.

I did not plug or unplug sound direction sensor. In both example above, I just turn on the robot Hat, and run the example code.

Just now for confirmation, I ran simple test of 11_sound_direction_read.py in a very quite room and it just keep outputting sound direction data until i terminate with Ctrl-C

This is a slightly modified code of original 11_sound_direction_read.py, so I can demonstrate the output:

from pidog import Pidog

my_dog = Pidog()
my_dog.rgb_strip.set_mode("breath", "blue", bps=0.2)
try:
    while True:
        if my_dog.ears.isdetected():
            direction = my_dog.ears.read()
            print(f"sound direction: {direction}")
finally:
    my_dog.close()

We will send you a new sound direction sensor and ribbon cable as a replacement.Please contact us at service@sunfounder.com

1 Like