I’m doing a uni assignment on Iot, and we are doing a soil moisture system with a water pump. One stipulation is that we need to use Node-Red.
List of components
*MCP3008 8-channel ADC
Raspberry Pi 4
*Dfrobot Gravity: Analog Waterproof Capacitive Soil Moisture Sensor
*Piico Dev oLED
*Piico Dev adapter for raspberry pi
*Dfrobot: Amphibious Horizontal Submersible Pump
*Using Mac and controlling raspberry pi through the terminal.
Okay. Im a full rookie here… Apart from connecting a dht22 humidity this is my first project…. Here’s where I’m at:
Installed MCP3XXX library and done this….
sudo pip3 install adafruit-circuitpython-mcp3xxx As per everything on this thread
Set up a mosquito mqtt broker and
node red is connected (check screen shots)`
Heres the code that has been stored
in ` “/home/pi/./code.py”
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import busio import digitalio import board import adafruit_mcp3xxx.mcp3008 as MCP from adafruit_mcp3xxx.analog_in import AnalogIn # create the spi bus spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI) # create the cs (chip select) cs = digitalio.DigitalInOut(board.D5) # create the mcp object mcp = MCP.MCP3008(spi, cs) # create an analog input channel on pin 0 chan = AnalogIn(mcp, MCP.P0) print("Raw ADC Value: ", chan.value) print("ADC Voltage: " + str(chan.voltage) + "V")
Now I run this
code: ` python3 ./code.py and I get data coming in from the sensor. And it does change when I put the sensor in water… so that seems to be working (Look at screenshot).
So what I need is to import this into node-red I’m assuming we need to use an “mqtt in” node, but I just can’t figure it out… I’ve watched probably 40 different YouTube videos, and it looks so easy but nothing seems to work.
When I use a
“mqtt in”node I get nothing coming through
the debugger… It shows it is connect but no error msg or data. (check
Is there a
different way to import the data coming in from the raspberry pi, or is there
something I’m missing?`
I think I will need to calibrate the sensor and somehow set the parameters to interpret the data as come sort of high, medium, low soil moisture level. Not sure if i can do this in Node-Red or do I have to do this in Terminal.
And I haven’t even
attempted to connect the water pump and oLED ,to display if the soil is wet or
not, yet. So many more questions will
probably be on the way haha`
Can some legend out
there same me!!`