Skip to content

Motion_sensor

Antonio Lignan edited this page Jan 29, 2016 · 2 revisions

Motion sensor

The Motion sensor driver is compatible with most existing Motion and Presence sensor boards, that drive a pin low/high (or open collector) when presence is detected. It has been tested on the following sensors:

Technical details and documentation

Check the sensor specific documentation, as mentioned before all sensors from the above list should work, mind only changing the logic (pin low or high when presence is detected). The requirements to use any of the sensors are:

  • Use 3.3V or 5V (in this case you need to power the sensor from the RE-Mote when connected over USB, or externally).
  • Detection range mmay vary depending on the sensor, and its orientation.

Libraries and examples

The Contiki sensor library can be found at platform/zoul/dev/motion-sensor.c, check out the most updated version in Contiki repository.

Depending on the pin logic (pin set high or low when presence), change the interrupt setting to GPIO_DETECT_RISING if high when presence is detected, or GPIO_DETECT_FALLING otherwise.

/* Configure interruption */
  GPIO_SOFTWARE_CONTROL(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
  GPIO_SET_INPUT(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
  GPIO_DETECT_RISING(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
  GPIO_TRIGGER_SINGLE_EDGE(MOTION_SENSOR_PORT_BASE, MOTION_SENSOR_PIN_MASK);
  ioc_set_over(MOTION_SENSOR_PORT, MOTION_SENSOR_PIN, IOC_OVERRIDE_DIS);
  gpio_register_callback(motion_interrupt_handler, MOTION_SENSOR_PORT,
                         MOTION_SENSOR_PIN);

To test the Motion Sensor sensor follow the next steps

  1. Grab Contiki and prepare the development setup (skip if you already have it)

  2. Connect the sensor to the RE-Mote using the 3-pin cable as shown in the photo above. This is a 3-pin connector with 2.54 mm pitch spacing, if you are to connect using a different cable than the one provided, check out the RE-Mote pin-out and the connector information.

  3. Compile the test example and program the RE-Mote:

cd examples/zolertia/zoul
make test-motion.upload && make login
Clone this wiki locally