title: How to get the frequency of a square wave in a python script
body: <p>I'm using the TSL235 (<a href="http://www.ti.com/lit/ds/symlink/tsl235.pdf" rel="nofollow">http://www.ti.com/lit/ds/symlink/tsl235.pdf</a>) light-to-frequency converter and the Raspberry Pi. The output of the sensor is a square wave (50% duty cycle) with frequency directly proportional to light intensity. </p>
  
  <p>So I need to know (in a python script) which frequency gets to the Input GPIO-Pin of the Raspberry Pi.</p>
  
  <p>I only found a tutorial (<a href="http://playground.arduino.cc/Main/TSL235R" rel="nofollow">http://playground.arduino.cc/Main/TSL235R</a>) which shows a C-code, but I do not understand C... I'm only working with python</p>
  
  <p>Reading a GPIO Input isn't that hard so far:</p>
  
  <pre><code>#!/usr/bin/python
  import RPi.GPIO as GPIO
  
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(25, GPIO.IN)
  
  impuls_count = 0
  # Do next lines for i.e. 1000ms:
  GPIO.wait_for_edge(25, GPIO.FALLING)
  impuls_count = impuls_count + 1
  </code></pre>
  
  <p>I think I have to count the signals in a time intervall. But how?</p>