This guide is all about connecting additional sensors to observe even more about our plant and its environment, in turn, allowing us to conduct meaningful experiments. This guide assumes you've followed the Basic Setup Guide and are familiar with working programming a Raspberry Pi Pico in Thonny. (Check the article for more help!)

Transcript

In the Plant_io basic setup guide, we assembled the Plant_io system to automatically irrigate plants. I don't know if you can see that, but my seeds are just starting to sprout.

As the project runs, a log file is updated with data captured at each interval. This simple log allows us to peer back in time and see how things progressed. It's a wonderful start, but it only captures the soil moisture and pump activity. Unless you wish to observe how ambient light affects your plant, or to track the air temperature and humidity to see how these things impact growth, this guide is all about connecting additional sensors to observe even more about our plant and its environment, in turn allowing us to conduct more meaningful experiments.

We'll show you here how to connect the hardware and log the data. The experiments are up to you. Let's get started. This guide assumes you've followed the Plant_io basic setup guide and are familiar with programming the Raspberry Pi Pico with Thonny. If you have no idea what any of that means, check out that first guide.

Plant_io supports some really useful PiicoDev sensors. The atmospheric sensor measures temperature, air pressure and humidity. The air quality sensor is great for measuring indoor air quality. It's sensitive to volatile organic compounds in the air, providing measurements for air quality index, equivalent CO2 and total volatile organic compounds. The laser distance sensor uses the time of flight of an invisible laser beam to measure distance. The colour sensor can tell you the hue of the measured light or return raw RGB values. The 3-axis accelerometer measures inertial forces and can tell you tilt information too. The magnetometer measures the intensity of invisible magnetic fields. In all three axes. And the ambient light sensor measures the intensity of ambient light. That seems relevant to plants, right?

Follow the links in the guide to learn more about each sensor, how they operate and what experiments you might want to run using each of these.

We can mount these sensors in a few different ways, either on the PiicoDev array to measure general ambient conditions around the experiment, or use this additional hardware to bring the sensor closer to the plant specimen. These acrylic pieces can position a sensor inside the growing container to get it as close as possible to our plants.

PiicoDev sensors are daisy chainable, meaning you can connect them end to end with the whole string receiving power and communications on the same cable. To include another sensor in your experiment, just add it to the end of the daisy chain.

I'll show you how to get started first with the atmospheric sensor, because I'm interested in tracking atmospheric conditions around my specimen. If you choose to work with one of the other sensors, the steps for setting them up will be really similar.

I'll use a PiicoDev cable to connect the sensor to the plant IO shim and mount it to the PiicoDev array next to the breadboard. Make sure you unpower your project before making any connections. A couple of screws holds it in place.

From the source files, I'll upload PiicoDev Unified and the driver files that match my connected hardware. For the atmospheric sensor, that's the BME280 file.

The PlantExperiment.py file is an extension of the basic plant watering script we saw in the previous tutorial. It has all the same functions, but also includes features to sample and log these sensors. It probably has a different soil moisture setpoint.To begin, make sure you update the code from the previous guide to suit your specific needs. Scroll down in the code and uncomment the appropriate line to attach the sensor. For the atmospheric sensor, use "plant.attachBME280" and uncomment that line.

Next, scroll down to step 2 and uncomment the line where the sensor is sampled. Keep in mind that the atmospheric sensor returns three values: temperature, pressure, and humidity. The units for each variable are indicated at the end of their respective names.

Now, let's include the atmospheric data in the log file. Add some headings for each data type by scrolling down to step 4. For example, you can add headings like "temperature" (in degrees Celsius), "pressure" (in pascals), and "percent relative humidity". Define these new heading strings and add them to the end of the data heading list. This will create three new columns in the file for the atmospheric data.

After sampling the data and setting the headings, we need to add the heading-data pairs to the data dictionary. The data dictionary is where we assemble all the data we want to log and associate it with the correct heading. For example, you can add entries like "heading temperature" with the corresponding temperature data (in degrees Celsius), "heading pressure" with the pressure data (in pascals), and "heading humidity" with the humidity data (RH variable). This will ensure that the data is placed in the correct column of the log file.

Before logging the new data, it is important to delete the old log file so that the new one with the correct headings can take its place. If you want to keep the old data, make sure to download and save it somewhere safe. Right-click on the old log file and select "delete". Finally, click "run" to make sure everything is functioning correctly.Works. Cool, our shell is showing something a little different to what we're used to.

Now in this light blue text, we can see that we successfully attached the PiicoDev atmospheric sensor BME280 at some address, and then the normal control messages are showing.

I'll halt my script and refresh the files. We have a new log file, and taking a look inside that log file, we have the headings that we know and love, time in minutes, moisture percent, and pump run seconds, but now we have these additional headings, temperature, pressure, and humidity, just as we described them in the code.

And if we look at the data underneath, we can see three new entries. So I guess that means in this studio, it's about 22-degrees, it's 1013 HPA, hectopascals. So the unit that we're logging here is pascals, and it's about 52% relative humidity, according to this sensor.

And of course, to run this file automatically, we need to save it to the Raspberry Pi Pico as main.py.

Let's look at how to mount a sensor closer to the specimen. I'll mount an ambient light sensor on this acrylic assembly that extends into the container. The small foot snaps onto the vertical extender, which can be pinned to dangle from the crossbar. Each of these three pieces has a location to mount a sensor, depending on where you want to place that sensor and with what orientation.

Then commission the sensor in exactly the same way as before. Wire it into the daisy chain, upload the relevant driver file and uncomment the attach and measurement lines. Next define the heading text and add the heading to the heading list. And finally, you can add the heading and data pair to the data dictionary.

And here we are a couple of days later, this setup was running on the windowsill.In our kitchen over the weekend, I've managed to download the log file and plot that file in Excel, so we can take a look at some of the results. Now I've already seen soil moisture and pump duration in the previous video, so we'll focus on just the sensors this time, the atmospheric sensor and the light sensor.

Here we have a three day plot of atmospheric data and we can probably find out what was day and night by this red temperature plot. Here we can see that it's quite periodic. We get a slow ramp down, that's overnight, and then a rise during the day, slow ramp down, rise during the day and so on. So that's quite a reliable indicator, I think.

In yellow, we have the relative humidity cycling as well over the days, and that seems to be bounded by about 48% up to about 65% relative humidity. And this third line is the atmospheric pressure. And what I find quite interesting is that there's a bit of a weather trend that we observed over the three days. The atmospheric pressure starts high at around 1016 HPA. And by the end of those few days, it's dropped a couple of HPA down around 1012. So there's a bit of a slower trend happening there.

So that's all the atmospheric data, but we also have the ambient light sensor. And I find this pretty interesting as well. We can see a pretty strong correlation with the day-night cycle. I started on Friday afternoon, and then here we have the next day, the following day and the third day. And we ought to be able to correlate that time with the temperature. So we can see the peak brightness was around hour 20. And that's about when we had our peak temperature as well.

Now, this is an interesting experiment. We have a privacy film covering that window, which means that the lightIntensity will actually be reduced. The light is attenuated by that film. After doing some light research, direct sunlight on a bright day is around 30,000 lux. And we're seeing a peak of 6,000 to 7,000 lux behind this privacy film. So even though the sun is shining directly through the film and onto the experiment, we're attenuating about two thirds of the light that comes through.

And so this is an interesting experiment to see if the plant will be successful growing behind one of these films, just on our windowsill indoors. And just some general observations, it looks like the first day had really good sunlight and the next day was a little overcast. Maybe there was some spotty clouds, which is why we see these sharper lines. Again, the sample interval is only once every 20 minutes. So if there's clouds moving in and out, it's only at that sample time that the light is captured. But 20 minutes is probably sufficient for general trends.

And then it looks like this third day was a lot sunnier with a bit of spotty cloud in the afternoon. And so there you have it. We've completed setting up Plant_io for irrigating a plant and collecting data automatically. In my situation, I'm running a particular experiment with this plant, this growing medium and the growing conditions that I have on my windowsill. 

And I really look forward to you sharing the experiments you come up with and your findings. Be sure to share your setups in our forums and until next time, happy making.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.