Transcript
This transcript was autogenerated. To make changes, submit a PR.
Hi everyone.
My name is Marie Cruz, and like many of you, I like to explore
how technology makes our lives easier and sometimes greener.
When we talk about observability, we usually talk about it in terms of
servers, APIs, or distributed systems.
But in this talk, I'm going to share with you how I taught my daughter the
concepts of monitoring and observability, and how they kept our house plans alive.
With that said, welcome to STEM In the Garden, how to monitor
your plans with IOT and GR Cloud.
First things first, who am I?
I work as a senior developer advocate at Grafana Labs, the company
behind open source projects such as Grafana, Lokey, MiiR, and Tempo.
As a senior developer advocate, I get paid to learn about cool stuff
and share that with the community.
Before transitioning to developer advocacy, my background has
always been with software testing.
I'm the co-author of the book Contract Testing in Action.
So if you wanna learn more about how contract testing works, please support and
buy our book by scanning the QR code here.
I'm also a mom of two kids and two dogs, so household life can
be pretty chaotic, but rewarding.
Of course.
If you want to know more about what I do, then you can also
check out testing with marie.com.
Okay, so our story begins with this plant at first plant, taking care
of a plant looks and sound simple.
Just give it water and light, right?
But as many of you know, plants don't always make it.
I know I'm not the only one who's done this, so if you're
watching this virtually, I'd like to see a quick show of hands.
Who here has ever killed a house plant?
The reality is that plants die, and it could be from too much water or not enough
water, or it could be lack of light, or maybe the room was too hot or too cold.
So I wanted 2025 to be the year of no planned casualties.
So I team up with my 8-year-old daughter to look after our plants better,
but also I wanted to take this opportunity to teach her more about STEM subject and
also make the learning fun along the way.
So we made the beginner level friendly project that will monitor
the soil moisture of our plant and let us know when to water them.
And I'd like to share all of that with you in case you also wanna
try a fun IOT project at home.
So as a parent, I wanted her to learn more about what I do for work all day.
I watched the talk online from the Grafana YouTube channel on
how this parent explained Grafana to his children through IOT home
projects, and I was inspired by it.
I wanted to explain tech concepts using easier to understand terms that are
outside the typical technical jargon.
So for this part of my talk, I want to focus on how we can explain concepts
such as iot monitoring and observability to our kids, or even to anyone who
doesn't have much knowledge about it.
I.
Using gardening analogies.
I asked my daughter to imagine that each plant has a little helper called
a sensor that is found in the soil, and that sensor could detect moisture levels
and inform us when it needed water.
I explained that Internet of Things or iot is simply just that.
It's a way to connect objects, including sensors to the internet so they can
monitor, they can communicate, and in some cases they can even take action
automatically to make our lives easier.
So I explained to her that monitoring is a way to keep an eye on our plant.
We monitor the soil's, moisture levels, and if it's dry, we need to water it.
We are simply reacting to the situation and to the plant's.
Needs monitoring is useful, but it's limited because it only
gives us a yes or no check.
If our plant still looks unhealthy after watering it, then monitoring
can't provide us this answer.
Observability, on the other hand, takes monitoring to the next level.
Observability allows us to understand why our plants held changes over time.
For example, does the plant soil moisture drop during a specific time of day?
Do we need to include other factors such as the room temperature and
the humidity into our project to support those predictions?
Or could it be something else entirely?
Could it be that one of our dogs are doing something that they're not supposed to do?
So observability is all about looking at all our data, identifying patterns
over time, and then predicting what's going to happen next.
So we're being proactive instead of reactive.
Without observability, we're essentially walking into a room blindfolded.
We know that the plant is struggling, but we don't know why.
Is it because of too much water?
Is it too little?
Or did we choose the wrong light, or is it because of a change in temperature?
We're essentially guessing and we're operating on hunches
instead of actual facts.
With observability, this block box can become a clear box.
If we have signals, we can then operate on facts.
If we have soil moisture signals, we can tell when to water the plant.
If we have light level signals, we can tell if the plant is getting
enough sun and if we have temperature and humidity signals so we can
tell if the environment is right.
So.
So with observability, we can take the signals clearly and take
action before the plant suffers.
So now that I've explained the key concepts to her, the next
part of this talk is to walk you through the project setup.
As I've mentioned, this is a beginner level IO OT project, so I'm only going
to cover the soil moisture sensor.
If you want a more complete project, you also need to look at buying other
IOT sensors, such as the light sensors, temperature, and humidity sensors.
Okay, so on a more technical aspect, I explained to her that our soil
moisture sensor has two metal farts that are similar to a fork.
When the soil is wet, water helps electricity flow easily between the
metal parts, and when the soil is dry, electricity can't flow as well.
The soil moisture sensor process this information as electrical signals to a
development board like an Arduino or ESP 32, which access the brain of the project.
Once the sensor is connected to the development board, it
can have two possible outputs.
It can have an analog output where the output is of a variable number
that depends on the moisture level.
So when it's a high number, that means the soil is dry, and when it's a low
number, that means the soil is wet, or the output can be a digital one
where the output is either high or low.
The output is then visualized to a dashboard using tools such as
Grafana so we can track them over time and make further observations.
There were a few bits of hardware that I had to purchase for this project, so
I had to buy a soil moisture sensor.
Of course, I bought an ESP 32, um, S3 dev kit development board to process the
output that we receive from the sensor.
I also purchased a red board just to plug all the components together, some
wiring cables to connect the sensor to the board, and finally, A-U-S-B-C uh,
cable to connect the board to my laptop.
So for the software part, I also had to install Arduino IDE, which
is an open source software that you can use to write, edit, and
upload code to a development board.
Then I had to sign up to a Grafana Cloud account and use the free Forever
plan to help us get started easily.
So now that we had everything that we needed, it was time to piece
everything together and get to the most exciting part of the project.
So our first step was to connect the soil moisture sensor
pieces using the DuPont cables.
Now, afterwards, we attach the development board to the breadboard,
and while this is an optional step, we found that in our case, inserting the
development board to the breadboard just made everything more stable.
Next we connected the moisture sensor to the development board
by connecting the following pins.
So we connected the VCC pin to 3.3 volts pin, ground pin to ground
pin, and a open to pin number 11.
So to explain this to her, I said that the VCC pin is basically the power supply pin.
So I told my daughter that this was like the plus side of the battery.
This is where the electricity comes from.
The 3.3 volt pin is the power output on the ESP board that basically
provides 3.3 volts, and then ground is like the minus side of the battery.
So this is where the electricity goes back.
And a O stands for analog output, so we can connect this
to any of the PIN numbers.
So in this case, we connected it to PIN number 11.
So we finally inserted the moisture sensor directly into the soil of
our plant, and then we connected the development board to my laptop, and
then we connected the development board to my laptop via A-U-S-B-C cable.
So once the hardware bits were done, it was time to write the program.
In rdu, we know IDE, we added support for our ESP 32 board and added this
very simple program for our first iteration just to keep things simple so
my daughter could easily follow along.
So let's go over this.
First we simply define the variables for our sensor pin and sensor value.
Within the setup function, we initialize the serial
communication at a 9,600 board rate.
To explain what bot rate is, uh, to my daughter.
I told her to imagine that she was talking to her friends and all of
them agreed to speak 9,600 letters Every second, or every minute or every
hour, if one of them speaks less or more than 9,600 letters, then the
communication won't be clear and they won't be able to understand each other.
So they have to agree to speak to that.
Um, within the loop function, we continuously read the analog
value provided by the sensor, and then if the sensor value
is above 500, the soil is dry.
Otherwise, if the value is low, the soil is wet.
Then we simply added a delay of five seconds before taking another reading.
After uploading the code to the development board and then opening up the
serial monitor in Arduino, IDE, we saw the following messages, which is a good sign.
So that means everything is working.
Um, at this point, she thought that we were finished with the project,
but I explained that we can't keep looking at logs in Arduino, IDE 24 7.
So the next part of this project was to send the sensor values to Prometheus.
Now my next challenge was to explain what Prometheus is to my daughter,
and obviously not this Prometheus.
But this Prometheus.
So I asked her to imagine that there is a gardener who collects the sensor
values continuously and stores all of them in a toolbox called a database.
So Prometheus can store other metrics as well, but for our example, Prometheus will
collect the sensor values from Arduino.
Prometheus database to store the sensor values is hold a Time series
database, so this means that Prometheus also keeps track of when the values
are stored and stores the timestamp.
So this allows us to see a timeline of how the sensor values change over time.
For us to get the sensor values back from Prometheus, we massage by speaking
its own language, which is called prom ql or Prometheus Query language.
And a query can look like this.
It consists of the metric name.
So in this case, the name is called Soil Moisture, and it can also
have an optional label filter.
So the label filter will return values based on your
filter value that you provide.
The easiest way for me to show Prometheus to her was to set up the Grafana Cloud
account using the Free Forever Plan, because it comes with a fully managed
Prometheus instance in our Do We Know.
So we also installed additional libraries such as Pro Low Key Transport
and Prometheus, Arduino to help us send the sensor values to Prometheus.
So the next step was to store the details of our Prometheus instance
in a configuration file so that the code that we wrote in Arduino
could connect to Prometheus.
Here's the code snippet with some details submitted for security reasons.
So essentially we needed to provide the Prometheus instance, URL, the username
and the API token, as well as our wifi details so our dino can send the data.
So for Arduino to send the data securely to our Prometheus instance
in your phone cloud, we also needed to provide a certificates file.
So this file was copied from the Prometheus Arduino GitHub project.
The Prometheus Arduino GitHub project also has a code example of how to send
the metrics from Arduino to Prometheus.
So instead of reinventing the wheel and starting from scratch, we simply
copied the code example and updated it slightly to work with our code.
My daughter asked me if this was cheating because we copied the
code, so I had to explain that this is normal when programming.
Um, but anyway, for the full project, you can check out the plant monitoring
GitHub repo for all the details.
Now again, after uploading the updated program to our development board, we
saw the following logs on our serial monitor, which is a very good sign.
So the final piece of the project was to visualize all of our
Prometheus data to Grafana Cloud.
While Prometheus was our gardener, I explained that
Grafana is our core visualizer.
It takes a sensor values from Prometheus, enters them into beautiful graphs,
making those values easier to understand.
So within our Grafana instance, we started by creating a new dashboard in Grafana.
A dashboard is simply a collection of one or more panels, and each panel can
display a specific visualization, such as a bar graph, a table, or a gauge panel
with the data pulled from a data source.
In our case, the data source is our Prometheus instance.
And the query is basically the query that you already saw a while ago.
There are a lot of visualization types in Grafana, so we had plenty of
choices to choose from and build the dashboard the way how we wanted it.
Finally, we ended up with something like this, so our dashboard was a
collection of multiple panels all using Prometheus as our data source.
The first panel uses a text visualization, which uses simple HTML code to
add the image of our house plant.
The next panel uses the stat visualization, which is useful for
showing a single value and it's best for showing information quickly,
such as the health of our plant.
The next panel uses the gauge visualization.
So a gauge visualization is ideal for showing where a value falls within a
range, and it's helpful for monitoring metrics that have very clear thresholds.
In our case, I have a threshold that if it's over 500, the soil is dry, and if
it's under, that means the soil is wet.
And finally, we also use the time series visualization.
The time series visualization in Grafana is the default and primary way to display
data points that change over time.
On the other hand, here's what our dashboard looks like if the soil
moisture values are above 500.
So if you notice the color of our stats and gauge visualizations
also changed from green to red.
So we were able to achieve this in your fauna using value mappings.
So value mappings in Grafana are used to convert raw data values into more
meaningful or user friendly texts, icons, or colors on your dashboard.
So this way my daughter was also able to understand the dashboard clearly.
Now having a dashboard to look at is excellent, but we thought that
getting an alert when our plan was thirsty would be even better.
So the final piece of our project was to configure Grafana alerting.
To set this up, we created a new alert rule with the alert condition that when
the query is above 500, to ensure that we would only be alerted if the soil
moisture value was above this value.
And then the Prometheus query is still the same query that we have been using.
We created a new contact point to define where our alert should be sent.
When an alert rule is triggered, a contact point is basically who
should receive a notification when an alert rule is triggered.
For this example, we chose Telegram, so every time the sensor value goes above
500, I would get notified on Telegram.
And then finally, everyone's been talking a lot about AI these days, so
I might as well jump on that wagon.
Um, to enhance the look of our dashboard.
So you can see here that the dashboard is much more professional.
It looks much more better.
Um, we also played around with Grafana assistant, so Grafana
assistant is an AI powered agent, LLM.
That's, uh, integrated and built into GR Cloud.
So here I simply ask if visual enhancements can be made, and you
can see that the dashboard looks so much better than the first
dashboard that you saw a while ago.
So, um, that's it for my talk.
Um, but to close this session, here are some takeaways from doing
this project with my daughter.
Learning about monitoring and observability is fun.
So by using gardening analogies, I was able to explain these key
concepts to her in a playful way.
So I also encourage you to explain technical stuff to one another more
often, whether that's at work or at home in a fun, non condescending way.
Getting started with iot and GANA is great for STEM learning.
After this project, we're thinking of adding an automated watering system and
also maybe start other IO OT projects.
So this way I can also support her interest to STEM subjects.
And finally, our plants are.
So if you want to know more about the iot project and you want to learn about
Grafana as well as all the details that you saw as part of this talk, then please
scan the, your code here that you can see, um, on my screen to get all the relevant
information if you have any questions.
You can connect with me via LinkedIn, so please scan your code that you see here.
Uh, but if you have specific questions about Grafana, then
ask us@community.grafana.com.
I hope you enjoyed today's session, and thank you so much for watching.
I.