NMD 211

Coding Lab Final Project

Final product


When thinking of ideas to create the final project, we decided to try and stray from a typical system with just a buzzer or something simple. We wanted to create something useful and functioning that could be used in everyday life. As far as motivation goes we were motivated from a college student standpoint. We both have plants in our apartments however we find that we rarely ever have time to water them/tend to them. More recently, two of my plants have been dying. I can never seem to get the correct number of water at the correct timing. Not only would this be fun to make, it would also be super helpful. By using the knowledge we gathered in class we were motivated to create a smart plant. A system that allows the plant to water itself, so as busy college students, we won’t have to. 


Our plan is to first assemble, find parts to put this project together. We plan to gather an Arduino, breadboard, analog soil moisture sensor, relay module, ultrasonic speaker, LED, resistor, BME280/BMP280, foam, water tubing, tape, a motor, OLED, foam, and battery. We plan on having our system measure the soil moisture and water the plant automatically according to the amount of moisture. The moisture will hopefully be measured every 60 seconds. We plan on having the blue LED tell us when the bucket of water is empty. We plan on having the BME280 display the temperature and humidity in the room. We are hoping our system will correctly display the values of the humidity on the OLED. We plan on having the water pump run when the value from the soil moisture sensor falls below “300” which would indicate that the soil is dry. The outlet will supply power to the pump and relay module we hope will regulate the pump. We plan on connecting the ultrasonic speaker to the breadboard to beep when the watering has been completed. We plan on using the ultrasonic sensor to know how much water is left in the bucket and coordinate the LED with that. Next, we plan connecting ports and find the correct libraries to connect to. We then plan on referencing the code from https://create.arduino.cc/projecthub/lc_lab/automatic-watering-system-for-my-plants-b73442. After correctly hooking everything up we plan to adjust anything that isn’t working and adapt from that. Autumn and I are hoping to spend a few hours inside and outside of class in order to get this project to work. 


Diagram for power flow in our project

In this setup, the Arduino is connected directly to the relay, soil moisture sensor,  and breadboard. The breadboard connects directly to the relay which is joined to the relay and the relay is directly connected to the 9-volt battery as well as the water pump. The power flows from the Arduino to the relay which from there powers the water pump and the 9-volt battery. The breadboard also helps to power the relay.
The power also flows from the Arduino into the breadboard which allows the power to go to the resistor and into the LED. The breadboard powers the other sensors connected to it (Ultrasonic speaker and the humidity sensor). Separately the power flows directly from the Arduino (skipping the breadboard) directly to the soil moisture sensor which doesn’t require additional power from the breadboard or relay.


step 1

Step 1 Diagram from Arduino Tutorial

In Step 1, You start with hooking up the Soil Moisture Sensor. There are three inputs in the sensor, two. wires connect from the sensor to thee breadboard and the last wire connects to the Arduino in port A0. For our project we used an Arduino Mega 2560. After the Soil Moisture Sensor is hooked up, set the pointed side directly into the soil in your potted plant. You may have to rearrange your set up so this reaches. Next we connected our Relay. For this project you will need a 5 pin relay. On the 3 pin side, two of the wires connect to the breadboard. The other wire connects directly to the Arduino in pin 13. On the two pin side, the red wire from the water pump connects to the bottom left pin on the relay and the second wire, the top right, connects directly to thee battery. That leads us to our next step: setting up the battery and water pump. To assure our water pump stayed upright and under the water we decided to tape it to the side of the container filled with water. As mentioned above, the red wire on the pump connects to the relay, while the black wire connects directly to the battery. We used a 6 volt water pump with a 9 volt battery in this project. Lastly in this step you have too connect four other wires directly from the Arduino to the bread board. These wires are connected in ports 3.3v, 5v, GND and GND.

A photo of step 1 completed

step 2

Step 2 Diagram from Arduino Tutorial

Step 2 is connecting the Ultrasonic Sensor and the LED that it triggers when the container of water is empty. First insert the Ultrasonic Sensor, it has 4 pins and goes into the top right corner of the breadboard. Next insert the LED to the left of the sensor and the resistor slightly below it. Now for the wires, there are 3 new wires coming from the Arduino into the breadboard from ports 7, 8 and 9. Then there are 3 wires directly from the breadboard back into the bread board. 2 under the sensor and one next to the LED. That concludes this step.

A photo of step 2 completed

Step 3

Step 3 Diagram from Arduino Tutorial

Step 3 is the final step of setup. This includes adding the LCD and the BME280 Sensor. First you want to add the LCD this will be a bit of a tight fit, it will go almost directly in the middle of the breadboard and if fit helps, it can slightly hang off the bottom edge. Next the BME280 sensor goes to the. liftoff the LCD near the edge of the breadboard. In this step there are many, many wires 15 to be exact. there are 5 wires at the top of the breadboard in the same row mostly all next to each other vertically. Next there are 3 horizontal wires underneath the set of vertical ones and above the LCD. Then there are a cluster of 5 wires underneath the BME280 and next to the LCD. All wires mentioned so far come directly from the breadboard and go directly into the breadboard. Lastly there are 2 wires left of the LCD that go into the Arduino into the two ports directly above AREF. This concludes the set up for this project.

A photo of step 3 completed

Upload and Run

The last step of this project is to upload the code and run the project. The code is provided below.



We used the code from the tutorial we followed. We had to change it slightly because the tutorial used an OLED and we used an LCD.


Overall I believe this project went fairly well. We did not get the finished product to work unfortunately but that does not mean we didn’t learn a ton during this project. To complete this we used 3 Lab periods and met twice outside of class at the hacker space an hour each. We knew when we started this project that it would be a challenge but that’s why we decided to work together. We met first outside of class time at the hacker space just to wrap our minds around the project. When we were there we discovered that we needed some parts that we did not have in our kit so we discussed with the person working there at the time and learned a lot about the different parts that we would be using. I believe that first meeting was very informational for the both of us. After that we got to work in lab. We started with Parker reading off the diagrams in the tutorial and Autumn connecting all the wires towards the end we switched positions to give each other a break. This method I believe worked very efficiently and we were able to complete the whole set up in about an hour and a half. Parker found a tube in one of the boxes in the hacker space and Autumn found some foam and utilized it to finish our set up and make it look aesthetically pleasing. Next we started the code which ultimately lead to our demise in this project. First we discovered that we were using a different LCD then the one provided in the tutorial and was unable to download the library included in the tutorial. After some research we found the right library we needed and we altered the code to support the LCD we were using. That took the remainder of time we had that day, so we properly stored our project and met up again in the hacker space a few days later. During this meeting we finished our new code and went to run our project for the first time. We spent a very long time messing with the ports in our computer and Arduino but neither of our laptops would connect to the port. We were aware that this was a common issue with MacBooks because both of us had been struggling with the same issue throughout the entire lab this semester. We tried every possibility but decided that we would just be unable to finish this project. We took many photos and videos throughout the entire process which is included in this lab report. We also spent a very long time on the code and made sure it worked which is also included. So we know we created a working project just unfortunately our computers did not want to cooperate in displaying that outcome. Although the project did not run officially I learned so much in this process and this lab as a whole. I believe pairing up as a team for this project was a great choice and we worked together very well. I believe having a partner helped me learn even more because we were able to troubleshoot together. Overall I am very happy with the amount of effort and time we spent on this project and the amount of knowledge we gained from it.

Leave a Reply

Your email address will not be published. Required fields are marked *