0

I am working withe the turbidity sensor SEN0189 and I am using mcp3008 A to D converter but I am not able to get the values for it, as I am not able to download the adafruit mcp3008 libraries in my pi. As I'm not getting any output I have tried some other code so that it's showing the output but it shows 0 all the time and also please help me out about the wiring of the tubidity sensor. The code for which i am getting 0 is

 import mcp3008
 import time
     while true: 
 adc=mcp3008.MCP3008() 
 print(adc.read([mcp3008.CH0])) 
 adc.close() 
 time.sleep(1)

If you know some other code that works for it please let me know.

RalfFriedl
  • 2,188
  • 2
  • 10
  • 11
Habeeba
  • 1
  • 2
  • 3
    Add a photo of your wiring. – CoderMike Feb 24 '19 at 09:42
  • You say " I am not able to download the adafruit mcp3008 libraries" then how are you able to get that code above to run at all? Here are the instructions for the mcp3008 and they include getting the libraries with pip3: https://learn.adafruit.com/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi?view=all Also your code above isn't indented properly, but if you get any results, I'm assuming your version is corrected. – T. M. Feb 25 '19 at 00:40
  • https://gpiozero.readthedocs.io/en/stable/api_spi.html that's a nice simple way to read MCP3008s. – Dougie Feb 26 '19 at 11:33
  • I got the output by using the code in this link:"https://www.raspberrypi-spy.co.uk/2013/10/analogue-sensors-on-the-raspberry-pi-using-an-mcp3008/" but make sure you make the correction spi.max_speed_hz=1350000 if you didnt get the output – Habeeba Feb 26 '19 at 15:02

0 Answers0