0

I have an MCP3008 analogue to digital chip connected to my Raspberry Pi 3b

16 -> 3.3v
15 ^
14 -> Ground
13 ^ -> CLK (p23)
12 ^ -> Dout (21)
11 ^ -> Din (19)
10 ^ -> CS/SHDN (24)
9  ^

I've connected one Pin to a capacitive moisture sensor at pin 1

capacitive moisture sensor v1.2

Using the Python library adafruit-mcp30008, when the sensor is in water its value is around 600-700, dry always 1023. The strange thing is that all the other pins flip flop between 0 and 1023 with seemingly random values thrown in. Here is a section of the logged values with the sensor connected to pin 0, and sitting in damp soil.

|    0 |    1 |    2 |    3 |    4 |    5 |    6 |    7 |
                           ...
|  761 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  779 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  779 |  715 |    0 |    0 |    0 |    0 |    0 |    0 |
|  779 |  715 | 1023 |    0 |    0 |    0 |    0 |    0 |
|  779 |  715 | 1023 |  892 |    0 |    0 |    0 |    0 |
|  779 |  715 | 1023 |  892 |  805 |    0 |    0 |    0 |
|  779 |  715 | 1023 |  892 |  805 |  953 |    0 |    0 |
|  779 |  715 | 1023 |  892 |  805 |  953 |  832 |    0 |
|  779 |  715 | 1023 |  892 |  805 |  953 |  832 |  676 |
|  780 |  715 | 1023 |  892 |  805 |  953 |  832 |  676 |
|  780 |  278 | 1023 |  892 |  805 |  953 |  832 |  676 |
|  780 |  278 |  219 |  892 |  805 |  953 |  832 |  676 |
|  780 |  278 |  219 |  138 |  805 |  953 |  832 |  676 |
|  780 |  278 |  219 |  138 |   13 |  953 |  832 |  676 |
|  780 |  278 |  219 |  138 |   13 |    0 |  832 |  676 |
|  780 |  278 |  219 |  138 |   13 |    0 |    0 |  676 |
|  780 |  278 |  219 |  138 |   13 |    0 |    0 |    0 |
|  780 |  278 |  219 |  138 |   13 |    0 |    0 |    0 |
|  780 |    0 |  219 |  138 |   13 |    0 |    0 |    0 |
|  780 |    0 |    0 |  138 |   13 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |   13 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |  299 |    0 |    0 |
|  780 |    0 |    0 |    0 |    0 |  299 | 1023 |    0 |
|  780 |    0 |    0 |    0 |    0 |  299 | 1023 | 1023 |
|  782 |    0 |    0 |    0 |    0 |  299 | 1023 | 1023 |
|  782 | 1023 |    0 |    0 |    0 |  299 | 1023 | 1023 |
|  782 | 1023 | 1023 |    0 |    0 |  299 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 |    0 |  299 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 |  299 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  782 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  780 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  780 |  961 | 1023 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  780 |  961 |  854 | 1023 | 1023 | 1023 | 1023 | 1023 |
|  780 |  961 |  854 |  898 | 1023 | 1023 | 1023 | 1023 |
|  780 |  961 |  854 |  898 | 1020 | 1023 | 1023 | 1023 |
|  780 |  961 |  854 |  898 | 1020 | 1023 | 1023 | 1023 |
|  780 |  961 |  854 |  898 | 1020 | 1023 |  935 | 1023 |
|  780 |  961 |  854 |  898 | 1020 | 1023 |  935 |  960 |
|  780 |  961 |  854 |  898 | 1020 | 1023 |  935 |  960 |
|  780 |    0 |  854 |  898 | 1020 | 1023 |  935 |  960 |
|  780 |    0 |    0 |  898 | 1020 | 1023 |  935 |  960 |
|  780 |    0 |    0 |    0 | 1020 | 1023 |  935 |  960 |
|  780 |    0 |    0 |    0 |    0 | 1023 |  935 |  960 |
|  780 |    0 |    0 |    0 |    0 |    0 |  935 |  960 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |  960 |
|  780 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |
|  779 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |

Any idea why there's data on unconnected pins? I tried connecting them to ground based on some article I read but no luck. Also, is that data right? Wet->Dry being 600-1023?!

JYelton
  • 32,302
  • 33
  • 134
  • 249
Ross Drew
  • 101
  • 2
  • 3
    Does this answer your question? [Arduino digitalRead reading wrong](https://electronics.stackexchange.com/questions/83133/arduino-digitalread-reading-wrong) – JYelton Sep 24 '21 at 15:48
  • 2
    Although the referenced question is asking about Arduino and digital reads, while you're working with a Raspberry Pi and analog reads, the culprit is the same: floating pins. I hope that helps! – JYelton Sep 24 '21 at 15:49
  • 2
    _" I tried connecting them to ground based on some article I read but **no luck**."_ - you mean with the pins connected to 'ground' the readings still 'flip flop between 0 and 1023'? – Bruce Abbott Sep 24 '21 at 20:22
  • 1
    Yes. All pins but one connected to ground, I believe to combat the issue mentioned here. They are connected to ground in the example data above. – Ross Drew Sep 24 '21 at 21:40

0 Answers0