MCP3008 / Transducer on RPiZero2W - Erratic values

anyone know the little 8 channel ADC…

please have a look at the following, stumped…

https://forums.raspberrypi.com/viewtopic.php?p=2283705#p2283705

G

… could have stabilised the readings,

I zero’d/ground’d all the unused pins.

G

or seems not totally…

channel 5 is a pot, channel 6 is a drop in sensor.
channel 0 and 1 is the same sensors, one bottom of tube with 109cm water and two lying on table.

root@waterlevelk:~# cd /app/waterlevels/
root@waterlevelk:/app/waterlevels# python3 simpletest.py
Reading MCP3008 values, press Ctrl-C to quit…
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |

| 969 | 528 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 527 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 528 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 989 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 966 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 965 | 0 | 0 | 0 | 0 | 459 | 251 | 0 |
| 969 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1001 | 535 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 535 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 532 | 0 | 0 | 0 | 459 | 251 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 463 | 252 | 0 |
| 1023 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 972 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 964 | 0 | 0 | 0 | 0 | 459 | 251 | 0 |
| 968 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1010 | 541 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 535 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 447 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1009 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 967 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 966 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 970 | 0 | 0 | 0 | 0 | 459 | 251 | 0 |
| 1023 | 541 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 535 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 250 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1003 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 967 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 966 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 968 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1014 | 540 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 538 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 0 | 0 | 0 | 0 | 459 | 251 | 0 |
| 977 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 964 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 967 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 972 | 67 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 541 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 534 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 985 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 965 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 967 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 970 | 0 | 0 | 0 | 0 | 459 | 251 | 0 |
| 1023 | 541 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 536 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 530 | 0 | 0 | 0 | 458 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 157 | 0 | 0 | 0 | 459 | 251 | 0 |
| 1005 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 968 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 966 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 968 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |
| 986 | 322 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 540 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 534 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 529 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 510 | 0 | 0 | 0 | 459 | 252 | 0 |
| 1023 | 0 | 0 | 0 | 0 | 459 | 252 | 0 |

What sensor, and how is it connected?

Those numbers on channels 0 and 1 look like mains hum superimposed on the signal - possibly a bad ground on the sensors or something similar.

What do you get when you measure the sensor output with a multimeter? Perhaps you ordered a 0-3.3V and got a 4-20mA or a RS485 variant?

checked… it dev 0-3.3v output, 5v input, it’s printed on sensors.

G

connected as per dc.

ground to common ground.
at the moment both sensors are one 3.3v input, common to mcp 3.3v
and then pin 3 as per the spec/diagrams onto analog input of mcp3008.

bad ground on all…
notice how the sensor on channel 6 stabilised when i connected the other inputs to ground.

Sensor 1 - humming as per next post…

Sensor 2 - stable


… and it was a bad earth on the power supply or Rpi then I’d expect the drop in sensor thats on 6 to also go wavy…

interesting that the pots thats connected are stable.
will take the 2 problem sensors and remove long wire and local connect and see if it’s the wiring…

G

Are you sure of the power supply requirements? The Aliexpress links seem to say pressure transducer requires min 12V. The specs on the water level sensor are more confusing - in one place it says 5V, in another, 12V…

re multimeter…
tried using it… got strange values, checked against a single cell battery, got impossible voltage…
will first just get a new battery, see if thats the problem… otherwise it seems to be dead…

G

Can i ask…

is it possible to wire a sensor up to 5v from the rpi 5v pin, if sensor input is 5v, output is 0-3.3 volt which is wired onto the mcp3008, which itself on vcc and vref is wired to the 3.3v pin on the rpi.

G

checked both devices, it’s printed on the side.

5v input, 0-3.3v output.

As per order, i’m aware it does not show that on the web site.

G


G

this is one of 3 sensors, exact same… i got one connected to a pipe, filled with 109cm water.
others are out on table…

they measure full value 65535 at 0 load, and then reduce as pressure increases… so bit difficult to simple swop out…

connected the one to pipe, to use as test/lab… before connecting the others onto my tanks.

G

some more testing…

the first set of output is sensor connected to 3.3v input… we can see up/down…

second set of values is sensor connected to 5v input…

Blockquote
Password:
root@waterlevelk:~# cd /app/waterlevels/
root@waterlevelk:/app/waterlevels# [ython3 simpletest.py
-bash: [ython3: command not found
root@waterlevelk:/app/waterlevels# python3 simpletest.py
Reading MCP3008 values, press Ctrl-C to quit…
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |


| 412 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 116 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 512 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 597 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 581 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 579 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 582 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 459 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 |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 0 | 0 |
| 481 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 598 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 584 | 0 | 0 | 0 | 0 | 989 | 0 | 0 |
| 572 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 990 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 808 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 576 | 0 | 0 |
| 220 | 0 | 0 | 0 | 0 | 571 | 0 | 0 |
| 591 | 0 | 0 | 0 | 0 | 572 | 0 | 0 |
| 608 | 0 | 0 | 0 | 0 | 571 | 0 | 0 |
| 596 | 0 | 0 | 0 | 0 | 571 | 0 | 0 |
^CTraceback (most recent call last):
File “/app/waterlevels/simpletest.py”, line 57, in
time.sleep(0.5)
KeyboardInterrupt

root@waterlevelk:/app/waterlevels# Read from remote host 172.16.20.206: Operation timed out
Connection to 172.16.20.206 closed.
client_loop: send disconnect: Broken pipe

ssh pi@172.16.20.206

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
su -
Password:
root@waterlevelk:~# cd /app/waterlevels/
root@waterlevelk:/app/waterlevels# python3 simpletest.py
Reading MCP3008 values, press Ctrl-C to quit…
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |

| 1023 | 3 | 2 | 2 | 2 | 740 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 739 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 740 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 738 | 3 | 3 |
| 1023 | 2 | 2 | 2 | 2 | 731 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 740 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 743 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 740 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 743 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 741 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 743 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 733 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 743 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 744 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 747 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 746 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 747 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 746 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 746 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 746 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 745 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 700 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 522 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 430 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 426 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 427 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 347 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 94 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 50 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 93 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 290 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 514 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 608 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 617 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 617 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 617 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 620 | 3 | 3 |
| 1023 | 3 | 2 | 2 | 2 | 620 | 3 | 3 |
^CTraceback (most recent call last):
File “/app/waterlevels/simpletest.py”, line 57, in
time.sleep(0.5)
KeyboardInterrupt

I removed bad wiring from picture, connected directly using crocodile clamps.

now to try and fit this back, add water, with crocodile clamps and see…

Looking at the pictures, are you sure the output is analog voltage.
I have a similar sensor for my air compressor and it works on current and not voltage.
I had to connect the gauge in series on the negative side to make it work.
But I am not logging the values it just a visual gauge to show the pressure.
Just asking for incase.

Will be back at home in two days and can have a closer look.

See picture a couple of posts up, showing input and output.

You can order them in a couple of different specs.

G

still curious if it would work if i connect the transducer to 5v input from 5v pin on Rpi and the MCP vCC ad vRef onto 3.3V … as the output from y sensors are 3V as per picture above.

G

EEK - Editing that post.

I somehow thought Raspberry Pi GPIO was 5V, but it is 3.3V only, so you MUST connect Vcc and Vref to 3.3V. 5V Vcc will eventually damage the RPi.

it’s both, pin 2 is 5V and pin 1 is 3.3V

The pi will not see 5V coming back.

The transducers is powered by 5V, pin 2, the MCP3008 is powered by 3.3v pin 1
the data coming into the analog pin on mcp3008 is 3,3v

G