Friday 7 June 2013

Connecting temperature and motion sensors to Pi-Face

I will assemble the same circuit as in my previous post but this time I will use Pi-Face. The parts are the same except for one minor change: I will use 10k Ohm pull-up resistors for both of the sensors. So grab an additional 10k Ohm resistor and lets wire things up.

Because Pi-Face cannot read DS18B20 temperature sensor's input, I will connect the sensor's data terminal pin directly to Raspberry Pi GPIO, while having everything else connected to Pi-Face. Pi-Face connects to Raspberry Pi through SPI which leaves me with plenty of free GPIO pins. Here is the link to Pi-Face design and its beakout board with the connection pins marked green.

Here is the circuit

 


The big red square are Raspberry Pi (Model B) pins. The pins differ on Model A. Two smaller red squares are sensors - temperature and motion. Four tiny red squares are resistors. Plus two diodes (LEDs). Green lines are wires and green dots are wire junctions. There are also 8 + 8 pins on Pi-Face, marked as Input and Output, the Input set of pins has one ground pin and the Output set of pins has one 5V pin. And finally, green squares on Raspberry Pi pins connect it to Pi-Face.

Connecting Pi-Face to Raspberry Pi


I used a bunch of jumper wires to connect only the required pins marked as green squares on the circuit. So, every male pin on Raspberry Pi marked with a green square should be connected to its female slot on Pi-Face. Triple check that this connection is proper, not upside down, not mirrored. Then you may plug power supply and run this Python program which will enable Pi-Face output pins so you can see its on-board LEDs flash.

Wiring sensors and LEDs


Please read my previous post to understand how to calculate resistor values and wire sensors into the circuit. Note that I am still using 100 Ohm resistors for LEDs because the current does not exceed 20 mAmps (measured 18 mAmps) and I've got plenty of those cheap LEDs! Also note that the voltage provided through Pi-Face Output pins (which act as ground) is not 5V but 4.2V (measured), I guess this is because every output pin has an on-board LED which provides additional resistance.

Summary:
  • Use 5V pin of Pi-Face to power both sensors and both LEDs.
  • Connect the temperature sensor's data terminal to Raspberry Pi GPIO4.
  • Connect the motion sensor data terminal to Pi-Face input pin 0 (the first pin as input pins count starts from 0).
  • Connect ground terminal of the first LED to Pi-Face output pin 2 (4th pin, first pin is 5V and output pins count also starts from 0) and ground terminal of the second LED right next to it - output pin 3.

Python program


It checks room temperature every half a second and lights up one LED when the temperature is above 20 C (just breath on the sensor). Lights up another LED when it detects motion.  You may want to alter the temperature limit ans change the device directory (mine is 28-0000047b16ad) in the source code. Download link.

And finally, a set of pretty pictures



2 comments:

  1. This is great info. I did not know that the PiFace Digital actually only used a few of the GPIO pins. Thanks for posting!

    ReplyDelete
  2. This is great info. I did not know that the PiFace Digital actually only used a few of the GPIO pins. Thanks for posting!

    ReplyDelete