Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

MinorProject EECS 1011 Minor Project Info Document (v1) Nov 2021 Copyright James Andrew Smith; you do not have permission to upload or transmit or share this document outside of York University. Minor...

1 answer below »
MinorProject
EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
Minor Project: Auto Plant Watering with Arduino and Matlab
James Andrew Smith
Assoc. Prof., York University

[this document will be updated]

This document begins with a discussion of an important software concept for your project: state
machines. It then goes on to describe the components in the project. This is a major revision of
an earlier document and so some elements that describe the project, the reporting and the goals
will be added at a later date.

[this document will be updated]

Introduction to State Machines

State machines are a fundamental concept in developing programs and control systems. They’re
not really “machines” like a car engine, elevator or amusement ride. Instead, think of them as
the core of a program that takes actions based on things that are sensed or measured.

Hunger example

It’s almost lunch time and you’re in a state of hunger. What do you do? You go eat. Once you’re
done eating, you’re in a state of satiation (you’re not hungry). So, you no longer eat.

What I’ve just described is you as a “state machine”: a machine with states (e.g. conditions,
feelings, sensed things). What is sensed drives the state of you or an object. In response to the
sensing and the state it results in, an action is taken. In other words, a state machine produces
an action in response to what it senses or perceives.


Figure 1 A state machine to describe what to do when you're hungry or not.


Reference: Finite State Machines on Wikipedia: https:
en.wikipedia.org/wiki/Finite-state_machine
EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
Watering example

Something similar to the hunger example on the previous page happens in an automated plant
watering system like the one you’ll work on for your minor project.

To control the plant watering in your project you’ll need to organize your Matlab program so that
it is reactive:

1. if the soil is dry, then water it;
2. if the soil is wet, but not too wet, then also water it;
3. if the soil is wet enough, then don’t water it.

In the list above the soil being dry is the first state of your system. The second state is described
y the soil being “wet, but not too wet”. The third state is “wet enough”. Each of these states
has an action associated with it:

1. State: dry à Action: Water
2. State: wet, but not too wet à Action: Water
3. State: wet enough à Action: Don’t Water

What does this maybe look like in a program?1

1. if(readVoltage(myBoard,soilSensor) < reallyDryValue) then writeDigitalPin(myBoard,PumpPin,OnSignal)
2. if(readVoltage(myBoard,soilSensor) < moistureThreshold) then writeDigitalPin(myBoard,PumpPin,OnSignal)
3. if(readVoltage(myBoard,soilSensor) <= saturatedValue) then writeDigitalPin(myBoard,PumpPin,OffSignal)

Of course, the code written isn’t strictly co
ect… it’s close. You’ll have to adapt it to Matlab by:
1. Writing the if-else structure co
ectly
2. Defining the myBoard, soilSensor, reallyDryValue, etc. values.






1 This is pseudo-code. It won’t run without modification.
EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
A Traffic Light State Machine Function in Matlab

Here’s a classic state machine: traffic lights. We use time as the measured input and return two
outputs: a displayed value and a function output.

In the table below, you can see how I call the Matlab function from the command line, providing
the starting time as 0 as the first input parameter and the cu
ent time as the second input
parameter.


Example: Green light state Example: Yellow light state Example: Red light state

You can see that the function responds by displaying a message and also by returning a string
(“Green”, “Yellow” or “Red”).

function trafficLightState = ...
whatLightColourIsIt(startTime, cu
entTime)

% define boundary times for light signals XXXXXXXXXX
seconds)
edStart = 0; % Red starts at 0 sec
edEnd = 5; % Red ends at 5 sec
yellowStart = redEnd; % Yellow starts @ Red end
yellowEnd = 7; % Yellow ends at 7 sec
greenStart = yellowEnd; % Green strt @ Yellow end
greenEnd = 12; % Green ends at 12 seconds



% What part of the timed light cycle are we on?
% Use the "modulo" operation to synchronize on 12
% seconds limit (greenEnd)
cyclePart = mod(cu
entTime,greenEnd); % if
cyclePart is 0 we have restarted.

% Begin the "IF", linking cyclePart's time to
the light's state.
if(cyclePart < redEnd) % Red light "state"
XXXXXXXXXXdisp("State: Red Light.");
XXXXXXXXXXtrafficLightState = "Red";
elseif(cyclePart < yellowEnd) %Yellow "state"
XXXXXXXXXXdisp("State: Yellow Light.");
XXXXXXXXXXtrafficLightState = "Yellow";
elseif(cyclePart <= greenEnd) % Green "state"
XXXXXXXXXXdisp("State: Green Light.");
XXXXXXXXXXtrafficLightState = "Green";
else % E
or "state"
XXXXXXXXXXdisp("ERROR: big time e
or!");
XXXXXXXXXXtrafficLightState = "ERROR";
end % end of the if statement


end % end of the function





Source code State machine diagram

EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
The details for creating the function are below, along with a visualization of the flow of the
program. The complete traffic cycle is expected to last 12 seconds in this example. We use the
modulo function to deal with time above 12 seconds as simply a multiple of the same process, so
that 12 to 24 seconds behaves the same as 0 to 12.


EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
The Minor Project

Tbd.

Objective

Tbd.

Submission for Final Report and Video

Tbd.

This document will be updated.



EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
The project setup

Summary
Set up your plant watering and monitoring system for the
first time. Take important measurements with the soil
moisture sensor and the pump to characterize behaviour of
the system.

Background
• View this watering plant video:
https:
youtu.be/cWtiHE9ZS58

• Read these resources:
o SeeedStudio Grove Beginner Kit Wiki page:
§ https:
wiki.seeedstudio.com/Grove-Beginner-Kit-
For-Arduino/
o Reading analogue voltages on Arduino:
§ https:
www.mathworks.com/help/supportpkg/arduinoio
ef
eadvoltage.html
o Writing digital output voltage on Arduinos
§ https:
www.mathworks.com/help/supportpkg/arduinoio
ef/writedigitalpin.html
o MOSFET Grove board:
§ https:
www.seeedstudio.com/Grove-MOSFET.html
o Plant moisture Grove board:
§ https:
www.seeedstudio.com/Grove-Capacitive-Moisture-Sensor-Co
osion-
Resistant.html
Intro

The Agri-Food industry is one of Canada’s biggest industries and employs all manner of engineers
in a variety of tasks. Automated monitoring and watering of plants is an important element of
this industry and is a fantastic example of mechatronics in action: sensors and actuators
connected together to do useful work.

Here, you will try out two key components in an automated monitoring and watering system:
moisture sensing and water pumping. The moisture sensor returns a voltage that is inversely
proportional to the presence of water, allowing you to determine in the soil is in need of
watering. The immersible pump is placed in a water reservoir and you use a MOSFET amplifier
to driver the electric motor within it to deliver water to your plants.
EECS 1011 Minor Project Info Document (v1) Nov 2021
Copyright James Andrew Smith; you do not have permission to upload or transmit or share this
document outside of York University.
Material needed
• 9v battery & cables
• Grove Beginner kit
• Container for water
• Water Pump
• MOSFET Grove board
• Potted plant
• Moisture sensor
• Container for spills



As part of your project you will need to connect a pump and a moisture sensor to your Grove
oard. You’ll use MATLAB to send signals to the pump in response to dry soil conditions
measured by the sensor. The connections will look something like the following
Answered Same Day Nov 23, 2021

Solution

Sathishkumar answered on Nov 24 2021
105 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here