Edited by Anthony Gallot

Pir sensor is a device that detect human presence. Use a retriggered PIR.
A value is sent to arduino periodically.
Useful to wake up the robot or launch face detection/recognition. Or what ever you want.

Summary :

  • ELECTRONIC
  • SETUP
  • UTILISATION

ELECTRONIC


PIR_Arduino


SETUP


Open InMoov/config/C_pir.config  and setup like this :

[MAIN]
isPirActivated=1

;whitch arduino control pir :
PirControlerArduino=right

[TWEAK]
;5 minutes after presence detected
HumanPresenceTimeout=300000

To check if the PIR is worky, you can use a multimeter between gnd and signal pins or use input oscope from webgui too.

MRL oscope view:

Oscope


UTILISATION


By default “sleeping” function is sent after 5 minutes of human inactivity.
If the robot is sleeping and if human is detected, “wakeup” function is sent.

File InMoov/services/C_pir.py :

TIMER IS RESET IF HUMAN IS DETECTED
if pins[pin].value>0:
if not RobotIsSleeping:
humanDetected()

IF ROBOT IS SLEEPING WAKUP IS CALLED
if RobotIsSleeping:
sleepModeWakeUp()

File InMoov/life/sleepMode.py

SLEEP ACTION IS CALLED BY A X SECONDS TIMER
def SleepTimerRoutine(timedata):
if pirTimerStarted and not RobotIsSleeping:
sleepModeSleep()

Comments 5

  1. Hello,

    I am trying to get the pir sensor to work but I keep getting this error upon startup “Arduino COM8 OK
    The Arduino choosen does not exist, plese check pir”

    I have verified that the sensor is working properly on a bread board. This is the text in the config file
    [MAIN]
    isPirActivated=True

    ;witch arduino control pir :
    PirControlerArduino=Right
    PirPin=23
    PlayCurstomSoundIfDetection=True

    PirPin=23 was already set so I did not change it. I am using the new blue nervo boards and have the sensor plugged into the PIR pins on the board.

    Any and all help is greatly appreciated!

    • I think you might not have set the Arduino COM port in service_6_Arduino.config.
      In the PIR config you set to connect to the RIGHT arduino:
      PirControlerArduino=Right

      Do you have a Arduino connected for the right side in the service_6_Arduino.config?

      • Thank you for the quick response. I do have the right side set for COM8 in the arduino.config. I was trying to use just the pir sensor so that’s all I had hooked up. I just tried again but with the right hand attached. I was still getting “The Arduino choosen does not exist, plese check pir” but the right hand was functioning properly.

        Is there any info that I could provide that may help?

        • Could you try the same set up but using the Full arduino in the configs?
          I have never tried it with only the right side, and I am about to take off for Bruxelles.
          The Full configuration works for sure, because I use it all the time.

          • Got the same message when config set to full. I get the same message for the NeoPixel as well when I run it through a slave but works just fine when set for standalone nano through USB.

            Does the aref need to be set in the sketch for the pir as well or just the finger sensors?

            I’m in no rush, still waiting on servos to attach the arms to the torso!

Leave a Reply