This will be my final blog in the IoT: In the Cloud project.  I have finished programming the controller logic and have modified the enclosure to mount the relay module and drilled out the wiring access hole.


Controller Logic

For this first pass I basically replicated the control logic of the mechanical timer that I am replacing and with the Cayenne dashboard I can update it remotely.  The sprinkler schedule can be set for a two week period.  The day buttons are selected for each day that the sprinklers should run.  The current day indicator shows which day is active.  The start time indicates when the sprinklers should start and each zone has an independent duration setting.


When the current day is a day with the day button set, the sprinklers will start when the current time matches the scheduled time.  The zones run in sequence starting with zone 1.


Here is a short video showing the operation.  I started the video about 15 seconds before the scheduled time.  The durations in the video are programmed in seconds rather than minutes just for the demo.  Inset on the lower right of the GUI is the relay module so you can see the relays operating.




A couple of things to note in the video:

  1. The current time freezes when the zone sequence starts and only continues when all zones have finished
  2. There is no indication of which zone is active (other than the LEDs on the relay module)


Both of these shortcomings are caused by not using independent threads for the time and run functions.  The tkinter GUI is somewhat tricky to implement with threads and I haven't quite figured that out yet.  Since the sprinkler operation works fine, I'm going to start with what I have .  Fixing the status indicators will have to wait until later this summer.


Enclosure modification

It turns out that I had some bad luck and wasn't quite able to finish.  I've been having some issues on and off with the hotend on my 3D printer and as Murphy would have it, the unit wasn't functioning when I tried to print the base for my relay module.  After a couple hours of troubleshooting I figured out that my nozzle is blocked.  I don't think there is an easy fix other than getting another nozzle.  So, I had to resort to a mock up using foam core board.


Here is a picture of the assembled enclosure:

Sprinkler controller assembly


I am not going to mount the enclosure until I fix my printer and print the relay baseplate.



I finished most of what I had planned for the initial phase of this project although I'm not really happy with the appearance of the Cayenne dashboard and I did not have time to figure out why the mobile app didn't work (I've used it before with The Raspberry Pi agent, so it must be a problem with the MQTT implementation).


Since I can't finish until I fix my printer, I may take the opportunity to add an RTC.  And try to fix the issue with the mobile app.  Maybe I'll look at some other cloud dashboards to see if I can get a better fit to my GUI.


Software enhancements that are planned:

  1. Implement threading in the tkinter GUI to prevent delays in updating GUI elements when the sprinklers are running
  2. Unique zone durations per day - currently durations are the same for every day


Software features that I would like to add:

  1. Calendar based scheduling - to allow for vacations, etc
  2. Weather aware operation - e.g. don't run if it's raining


The good news is that I can do the program development and updates remotely using SSH and VNC.