Plant_io - Plant Cultivation Kit (CE09696)

Hi Justin,

I tried the code and it worked sometimes and then other times it just turned off.

Very strange, just to confirm - the LED doesnt light sometimes but the HAT’s LED comes on?

The Latter is correct, once the 20 minutes has elapsed the Pico turns on and runs all of the code then turns the DONE pin on and puts it back to sleep by cutting the power.

Questions and debugging are great!
Keen to get your watering setup running smoothly!
Liam

Hi Liam,

I have a great update.

After i ran the simple code to test the power HAT that you gave me, (which i think i somehow still managed to not properly work out), i then re-installed the proper plant main.py file which had all my data in it, and there you go…it now seems to be working totally fine. No idea what actually caused the issues, but the battery pack set up is now working to my liking. I haven’t done a long test yet, but i will start now.

Thanks for your help.

I can imagine this must be a tad frustrating for you given the plant io has probably attracted some non programmers to the field (like myself). Well, we persevered and it seems to have paid off, at least for now.

Justin

2 Likes

:partying_face:

Nice one @Justin264431 !

1 Like

:sunglasses:


3 Likes

Hi Justin,

WHOOOOO!!! Sweet work getting it workin, and nice setup!

No frustrations from anyone, it was great exploring and troubleshooting the system.

That’s the whole point! We’re all keen to see your learning journey continue!

2 Likes

Hi Liam,

I’ve made a couple of notes:

  • Time of day and year are critical pieces of information to map long term horticultural data. I notice in the Plant_io code data, there isn’t a line for an RTC picodev module. Is that something that can be say daisy chained to an existing atmospheric sensor seen in pic above?

  • Is it possible to daisy chain a PicoDev OLED module to this setup and have it read out current metrics?

  • The longer term goal for me personally would be to have this plant_io set up become completely wireless (wifi enabled) to monitor data from a wireless position. The problem is I have no idea where to start to code this.

Justin

2 Likes

Learning sockets and intercom over network is NOT beyond you :slight_smile:
It is not an easy skill however, and I think it will take you a long time to learn.
That’s not a bad thing if you have the time. If you want to give it a shot, we can try to help.

If you would like to receive updates and monitor the progress of the plant setup, what about something simple like a daily email.
Sending emails from a raspberry PI is much easier than something like SSH.
You could get a small microcontroller to read the data, format it in a pretty way, and then send you a full colour report every morning.
Some bar graphs, fun stats.
Maybe even a line graph showing it’s progress over the last month.
Could be fun!

3 Likes

This sounds pretty awesome.

1 Like

Gmail has a API you could use.

You will also need a single board computer that can

  1. listen to your PICO using the GPIO
  2. Connect to the internet.

Since you’ve started with python and raspberry pi already, I’d suggest this.

Before making any purchases or modifications to your working plant setup, consider opening your day to day Personal Computer and following googles API tutorial. Write some code on your computer that sends an email to yourself. Just an email that says “Hello Justin!”. Get familiar; then commit.

1 Like

Hey Justin,

Pixmusix definitely has some awesome ideas here for how this could be set up. making the Plant_io kit into an IOT connected device was inevitable, but with the use of a Pico W it may be a lot simpler than you think. Even using the Wifi capability of the Pico W to have communication with your local wireless network opens a range of possibilities.

Cheers,
Blayden

2 Likes

Hey Guys,

So i’ve been busy adding some sensor’s (BME280, ENS160, VEML6030), which i think i’ve managed to get working fine…whilst connected to USB. When i ran the setup on battery i noticed that all the Air Quality Sensor Data were: “eCO2(value=0, rating=‘invalid’),operating ok,0,AQI(value=0, rating=‘invalid’)”. Basically, i’m just wondering if there needs to be a little more of a delay when grabbing the eCO2 Data because it seems like the sensors didn’t have enough time to initialise. Or i’m doing something wrong.

This project requires the Plant_io module which handles

- Interfacing with electronics (pump, moisture sensor, PiicoDev modules)

- Datalogging to a file

Plant_io removes a lot of setup complexity from PiicoDev but is only compatible with select modules.

from time import sleep_ms
from Plant_io import Plant_io, DataLogger

while True:
### Step 1: Initialise the Plant
plant = Plant_io()
plant.moisture_setpoint = 80 # change this to tune how moist the growing media should be. Use the results from test_moisture_sensor.py

# Attach sensors. Comment-out any sensors you are not using.
print("Initialising PiicoDev modules")
plant.attach('BME280')            # Atmospheric Sensor
plant.attach('ENS160')            # Air-Quality Sensor

plant.attach(‘VEML6040’) # Colour Sensor

plant.attach('VEML6030')          # Ambient Light Sensor

plant.attach(‘VL53L1X’) # Laser Distance Sensor

plant.attach(‘LIS3DH’) # 3-Axis Accelerometer

plant.attach(‘QMC6310’) # 3-Axis Magnetometer

print("")

### Step 2: Collect some data to log
soil_moisture = plant.measure_soil()
voltage = plant.measure_system_voltage()

Ambient Light Sensor VEML6030

lux = plant.VEML6030_light()

Atmospheric Sensor BME280

temperature_C, pressure_Pa, humidity_RH = plant.BME280_weather()

Air-Quality Sensor ENS160

ENS160_status, AQI, TVOC, eCO2 = plant.ENS160_air_quality()

Colour Sensor VEML6040

hsv = plant.VEML6040_HSV()

rgb = plant.VEML6040_RGB()

Laser Distance Sensor VL53L1X

distance_mm = plant.VL53L1X_distance()

3-Axis Accelerometer LIS3DH

acceleration = plant.LIS3DH_acceleration()

Magnetometer QMC6310

plant.QMC6310_calibrate() # should only need to run once. Comment out once calibration is complete.

flux = plant.QMC6310_flux()

polar = plant.QMC6310_polar()

### Step 3: Run the pump if plant requires water. This function uses soil moisture to decide whether to run the pump or not.
pump_running_seconds = plant.run_pump_control()

# Print some debugging information
print(f'Moisture {soil_moisture:5.2f}%    Pump Time {pump_running_seconds:5.2f}s')


### Step 4: Log the data to a file
period_minutes = 20 # The chosen interval time on the Makerverse Nano Power Timer
file_name = 'log.txt'

# These are the labels that appear at the top of each data column in the log.txt file
# TODO: Add your heading titles here
heading_time = 'Time [minutes]'
heading_moisture = 'Moisture [%]'
heading_pump = 'Pump Run [seconds]'
heading_voltage = 'Supply Voltage [V]'
heading_lux = 'lux'
heading_temperature = 'Temperature [C]'
heading_pressure = 'Pressure [Pa]'
heading_humidity = 'Humidity [RH%]'
heading_ENS160_status = 'ENS160_status'
heading_eCO2 = 'eCO2 [ppm]'
heading_AQI = 'AQI'
heading_TVOC = 'TVOC [ppb]'
data_heading = [heading_time, heading_moisture, heading_pump, heading_voltage, heading_lux, heading_temperature, heading_pressure, heading_humidity , heading_eCO2 , heading_ENS160_status, heading_TVOC, heading_AQI ,] # The heading that will appear at the top of the log file


logfile = DataLogger(file_name, data_heading, period_minutes) # Open the log file, and write the data_heading if the file was just created.
timestamp = logfile.last_timestamp + period_minutes # get the most recent timestamp

# Construct a data dictionary - dictionary keys match the data headings eg. {heading string : data to log}
# TODO: Add your sampled data here
data = {heading_time        : timestamp,
        heading_moisture    : soil_moisture,
        heading_pump        : pump_running_seconds,
        heading_voltage     : voltage,
        heading_temperature : temperature_C,
        heading_pressure    : pressure_Pa,
        heading_humidity    : humidity_RH,
        heading_lux         : lux,
        heading_eCO2        : eCO2,
        heading_ENS160_status: ENS160_status,
        heading_TVOC        : TVOC,
        heading_AQI         : AQI,
        
        
        
        }

logfile.log_data(data)


### Step 5: Signal to the Makerverse Nano Power Timer that we are DONE!
# This removes power from the project until the next timer interval
plant.sleep()

### Step 6: If we are running from USB power then power will never be removed by the Nano Power Timer.
# Instead we can just insert a delay. When powered only by batteries, this code will never run.
sleep_ms(round(1000*60*period_minutes))

You’re totally right - the Air Quality sensor will need more on-time to warm up the sensor.

check out the ENS160 guides for a rundown on how the warm up time works. It may be that you need to pre-treat the sensor for 24 hours to get past it’s initial startup time, and then the subsequent startup times will be much faster.

Hi,

Finally got back around to figuring out my problem of the soil moisture probe not giving correct readings and thought id put up a solution i found. I ended up using a different script to get the raw output, run it 100 times and then output the average and then use those values in the Plant_io.py script. Worked a treat, i now get nice 0% and 100% values :slight_smile: time to get this thing all setup then.

from time import sleep_ms
from Plant_io import Plant_io

# Initialise the Plant_io controller
plant = Plant_io()

def test_adc_reading(soil):
    soil_adc_reading = soil.read_u16()
    print(f"ADC Reading: {soil_adc_reading}")
    return soil_adc_reading

# Initialize a list to store the ADC readings
adc_readings = []

# Run the function 100 times
for _ in range(100):
    adc_reading = test_adc_reading(plant.soil)
    adc_readings.append(adc_reading)
    sleep_ms(100)  

# Calculate the average ADC reading
average_adc_reading = sum(adc_readings) / len(adc_readings)

print(f"Average ADC Reading: {average_adc_reading}")
3 Likes

Hi @Josh265172,

Glad to hear you go it all working well now :slight_smile:!!!

This is a great project & I’d order a heap for my classes if it was Arduino based. Is that possible? I can’t justify teaching another programming language for one project.

2 Likes

Hi Tom,

Definitely possible, are you using Arduino Uno’s, or would it be possible to use the Pico (with Arduino) the code would have to be ported but that’s entirely do-able

2 Likes

Hey @Tom224738
Do you want Arduino because of the simplicity of the IDE, language, and ecosystem? Or do you want Arduino because you like (or already own) the hardware?

1 Like

Hi,
I want Arduino because that’s the system we already teach with at our school and i wouldn’t change it for just one project.

2 Likes

Can’t argue with that.
Looking through the plantIO code base I can see that it’s built upon the strong foundation CE has developed for their in-house piicodev and maker-verse lines. These libraries are micropython native. Porting it the C++ is possible, but, in my personal opinion, not a trivial weekend project.

I could imagine remixes of this project, inspired by @Michael & CEs design, but built from the ground up in a way appropriate for the Arduino ecosystem. If there was some support from the forums, is that something you would be interested in perusing?

1 Like

Hi Tom
At the end of the day would it be a case of simply reading the relevant info from sensors via I2C and processing that with Arduino instead of Pico or whatever.

I have not gone into this sort of thing but quite some time ago I purchased some rotary encoder boards with a system called “Seesaw” (I think Adafruit) on board to decode the encoders. An Arduino UNO had no bother reading the I2C rotary encoder info from that.
Cheers Bob