title: Co2 k30 sensor not working with Raspberry pi 3
body: <p>I have following code that is running for detecting CO2 level. 
  Below are some of the information about the models. </p>
  
  <p>CO2 sensor - K30 
  Raspberry Pi 3 </p>
  
  <p>I have done connections between pi and k-30 as per below document 
  <a href="http://www.co2meters.com/Documentation/AppNotes/AN137-K30-sensor-raspberry-pi-uart.pdf" rel="nofollow noreferrer">http://www.co2meters.com/Documentation/AppNotes/AN137-K30-sensor-raspberry-pi-uart.pdf</a></p>
  
  <p>Below is my python code </p>
  
  <pre><code>import serial
  import time
  ser = serial.Serial("/dev/ttyS0",baudrate =9600,timeout = .5)
  print " AN-137: Raspberry Pi3 to K-30 Via UART\n"
  ser.flushInput()
  time.sleep(1)
  for i in range(1,21):
  
      ser.flushInput()
      time.sleep(1)
      ser.write("\xFE\x44\x00\x08\x02\x9F\x25")
      time.sleep(1)
      resp = ser.read(7)
  
      high = ord(resp[3])
      low = ord(resp[4])
      co2 = (high*256) + low
      print "i = ",i, " CO2 = " +str(co2)
      time.sleep(.5)
  </code></pre>
  
  <p>I am not getting consistent output. </p>
  
  <p>I am getting something below </p>
  
  <pre><code>pi@raspberrypi:~/i2c $ sudo python test-co2.py 
  AN-137: Raspberry Pi3 to K-30 Via UART
  
  i =  1  CO2 = 2458
  i =  2  CO2 = 2457
  i =  3  CO2 = 2448
  Traceback (most recent call last):
  File "test-co2.py", line 16, in &lt;module&gt;
      high = ord(resp[3])
  IndexError: string index out of range
  pi@raspberrypi:~/i2c $ sudo python test-co2.py 
  AN-137: Raspberry Pi3 to K-30 Via UART
  
  i =  1  CO2 = 2207
  Traceback (most recent call last):
  File "test-co2.py", line 16, in &lt;module&gt;
     high = ord(resp[3])
  IndexError: string index out of range
  pi@raspberrypi:~/i2c $
  </code></pre>
  
  <p>Appreciate any help ?</p>