Interface and Application Programmming

Happy Thanksgiving! I went home for the holidays so I did not have much time to work on this week's assignment, but luckily it involved only programming and no physical making. This week we had to make a GUI (which means Graphical User Interface; I fully admit that at the beginning of the semester I thought people were saying "gooey" and had no idea what they were talking about). I made a GUI for the input device I made a few weeks ago: a soil moisture sensor. The sensor works by detecting the resistance and capacitance moving between two conductive probes in the soil; the more moisture present, the lower the resistance and capacitance. To jog your memory, you can click here to view that week's assignment, or just look at these photos:

I spent a lot of my time this week just figuring out how to get Python to actually run on my Windows laptop. (The other weeks I've been using Ubuntu in the IDC lab, but I thought it would be best to get Python working on my own computer.) I ran into difficulty getting tkinter and pyserial to work through Cygwin. My problem, ultimately, was that I using Cygwin's built-in python commands rather than running python directly in the folder where I downloaded it. But it took me many hours to figure that out.

Once Python was working, programming was fairly straightforward. I used the hello.txrx.45.py file provided on the class website as a starting point and customized it from there, with some guidance from online Python tutorials and help forums. I came up with two GUIs. Both tell the user whether their soil has enough moisture for their plants or if the soil needs to be watered.

NOTE: I did not calibrate the resistance/capacitance with soil moisture content yet, because I still haven't figured out how to stabilize the reading (see assignment 9). The lines drawn in these GUIs to separate moist from dry solely illustrate the concept and are not actual indicators.

The first GUI uses a bar like in the example Python file. When the right edge of green rectangle is the left of the black line (meaning the resistance/capacitance is low), there is enough moisture in the soil. When the right edge of the green rectangle is to the right of the line, the soil is low on moisture and the plant needs to be watered.

Sufficient moisture:

Time to water:

The second GUI uses a circle of varying radius instead of a bar. As the resistance/capacitance decreases, the radius shrinks; likewise, when the resistance/capacitance increases, the radius grows. When the radius of the yellow-filled circle is smaller than the radius of the black-outlined circle, the soil is sufficiently wet. When the radius of the yellow circle is greater than the radius of the black circle, the soil is dry and it is time to water the plants.

Wet soil and happy plants:

Dry soil and thirsty plants:


Which GUI do you like better?

Files
soil.txrx1.py
soil.txrx2.py