Water Tower Animation

The gubbins for the inside of the water tower have come together at last. Once the noise maker was working, it was a straightforward matter of programming to make it all work – at least in the unit and integration tests! When I went to upload it to the board, however, there were still some surprises in store.

First, the limit and valve switches did not work as expected. In fact, they exhibited magical properties that left me scratching my head for days. When I first connected the switches to pins 22 and 23 of the ESP32, nothing happened at all. Eventually, I relented and made them drive the onboard LED, rather than the water tower. The LED lit up mysteriously whenever I put my hand near the switches. Those must be special pins, and so, I moved to pins 36 and 39 on the other side of the board. These worked, except when I pressed one button, the other button behaved as if it had been pressed too! Finally, I changed to 36 and 34, placing a space between the two inputs, and it all worked properly. Someday I will have to figure out what was going on, but this is not that day.

Then everything worked perfectly, except the linear actuator didn’t initialize properly. When the board turns on, the linear actuator is supposed to go to the end of its travel and stop so it knows where it is even if it was turned off when the float was midway down. All it did was to make a barely audible “put” noise and stay still. It turns out that a stepper motor needs a little time to actually get to its next step. So you need to leave a slight delay from one step to the next; 10 ms seems to do the trick.

With all the magic resolved, and several more lessons learned, I put everything back together again in the code, and pressed the valve button. The sound of water gushing emerged from the little speaker, and the linear actuator moved just as it was supposed to. When I let go of the valve button, the linear actuator slowly returned to its limit.

The code is available on Github. I also shot a 64 second video of the action for those who don’t believe it without seeing it.

4 thoughts on “Water Tower Animation

    1. I don’t think that’s it. According to the docs, they know how to speak a couple of digital protocols. It makes no sense to me that they would be sensitive to field changes, especially after being initiated general purpose input pins. Clearly I have more to learn!

  1. Now all you need to do is make the indicator bob up and down once or twice as the water sloshes about and the float finds its new level. (not sure that’s a thing; just having fun with your success here).

    1. It’s just software from here out, and so bobbing would be easy. There is a fun Easter egg in the program, but you might have to fill quite a few tenders before you encounter it!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.