
DIY Garden or Greenhouse Watering controller
prusaprinters
<p>Many thanks to the Original Developer of this really useful project</p><p>https://www.thingiverse.com/thing:3875075</p><p>I made this remix as the valve I got from China had slightly different dimensions to that of the model. Also the 2 fingers on the original model that hold the valve in place broke when inserted the valve.</p><p>The valve holder is changed to wrap around the valve more (hopefully stronger), and cut back from the servo to allow my valve to be rotated (it hit the original design). I also changed the shape of the inner housing to avoid the need for supports when printing, so I could print the inner housing with the valve holder on the build plate to make the layer orientation best for strength. The shape changes to the inner housing meant the outer housing was slightly increased in size to accommodate the new inner housing dimensions, but it was otherwise unchanged. The hole for the servo shaft was also elongated to make it easier to insert the servo.</p><p>I also increased the size for the valve knob in the servo adaptor, as the one I bought had a bigger width.</p><p>I will only be using my waterer occasionally, so did not use the permanent usb connection mentioned in the original. Instead I supplied mine with 12v from a battery in my greenhouse, and fitted a small voltage stepdown module to supply 5V to the servo and a Wemos D1 mini. The D1 mini was used to control the servo, and connected to my home MQTT server to receive commands telling it to open (water) or close (no water). I did not use a RTC as per the original design as my home automation server is aware of the time, and when to issue commands.</p><p>The code remembers and saves the valve position to the file system (spiffs) on the D1 mini, this is in case of a power interruption, and should prevent the servo being closed when it's already closed, or opened if it's already in the open position - not sure if this is absolutely necessary, but it didn't harm to include it.</p><p>Code used for Wemos D1 mini below.</p><p>#include #include #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" #include "FS.h" #include</p><p>Servo servo;</p><p>/************************* WiFi Access Point (CHANGE THIS)*******************************<strong>/ #define WLAN_SSID "YourSSIDHere" #define WLAN_PASS "YourWirelessPasswordHere" /</strong>*********************** MQTT Setup (CHANGE THIS)*********************************/ #define MQTT_SERVER "MQTTServerIP" #define MQTT_SERVERPORT 1883 #define MQTT_USERNAME "MQTTSERVERUSERNAME" #define MQTT_KEY "MQTTSERVERPASSWORD"</p><p>/************ (Don't Change)******************/ // Create an ESP8266 WiFiClient class to connect to the MQTT server. WiFiClient client;</p><p>// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, MQTT_SERVERPORT, MQTT_USERNAME, MQTT_KEY); /****************************** Feeds (CHANGE THESE)***************************************/ Adafruit_MQTT_Subscribe GreenhouseWateringcommandsub = Adafruit_MQTT_Subscribe(&mqtt, "/GreenhouseWatering/command");</p><p>/*************************** Sketch Code************************************/ int state = 0; int prevstate = 0;</p><p>int ServoPin = D7;</p><p>void MQTT_connect() { int8_t ret; if ( WiFi.status() != WL_CONNECTED) { WiFiConnect(); } if (mqtt.connected()) { return; } Serial.print("Connecting to MQTT... "); int i = 0; while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds..."); mqtt.disconnect(); delay(5000); // wait 5 seconds i++; if (i > 50 ) { ESP.restart(); } } Serial.println("MQTT Connected!"); }</p><p>void WiFiConnect() { delay(500);</p><p>Serial.print("Connecting to "); Serial.println(WLAN_SSID); WiFi.mode(WIFI_STA); WiFi.begin(WLAN_SSID, WLAN_PASS); int i = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); i++; if (i > 50) { ESP.restart(); } } Serial.println(); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP()); }</p><p>void setup() {</p><p>Serial.begin(115200); delay(10); servo.attach(ServoPin);</p><p>//mount spiffs bool result = SPIFFS.begin(); File f = SPIFFS.open("/state.txt", "r");</p><p>if (!f) { Serial.println("File doesn't exist yet. Creating it");</p><p>// open the file in write mode File f = SPIFFS.open("/state.txt", "w"); if (!f) { Serial.println("file creation failed"); } f.println("0"); } else { // we could open the file state = f.readStringUntil('n').toInt(); prevstate = state; Serial.println("Saved SPIFFS state = "); Serial.println(state); } f.close();</p><p>pinMode(ServoPin, OUTPUT);</p><p>Serial.println("Greenhouse Watering Startup Sequence"); Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(WLAN_SSID);</p><p>if ( WiFi.status() != WL_CONNECTED) { WiFiConnect(); }</p><p>mqtt.subscribe(&GreenhouseWateringcommandsub); }</p><p>void loop() { MQTT_connect(); Adafruit_MQTT_Subscribe<i>subscription; while ((subscription = mqtt.readSubscription(1000))) { if (subscription == &GreenhouseWateringcommandsub) { Serial.print(F("Received command: ")); String wateringcommand = (char</i>)GreenhouseWateringcommandsub.lastread; Serial.print(wateringcommand); if (wateringcommand == "open") { servo.write(90); state = 1; //sets current state Serial.println(" OPEN COMMAND RECEIVED"); } if (wateringcommand == "close" ) { servo.write(0); { Serial.println(" CLOSE COMMAND RECEIVED"); state = 0; //sets current state } File f = SPIFFS.open("/state.txt", "w"); if (!f) { Serial.println("file creation failed"); } f.println(state); f.close(); } delay(500); } } }</p><h3>Print Settings</h3><p><strong>Printer Brand:</strong></p><p>Creality</p><p><strong>Printer: </strong></p><p>CR-10</p><p><strong>Rafts:</strong></p><p>No</p><p><strong>Supports: </strong></p><p>Yes</p><p><strong>Resolution:</strong></p><p>0.2 mm layers</p><p><strong>Infill: </strong></p><p>10%</p><p><strong>Filament:</strong> Generic PLA Any</p><p><br> </p><p><strong>Notes:</strong></p><p> </p><p>I used tree supports</p><p> </p><p> </p><p> </p><p>Category: Outdoor & Garden</p>
With this file you will be able to print DIY Garden or Greenhouse Watering controller with your 3D printer. Click on the button and save the file on your computer to work, edit or customize your design. You can also find more 3D designs for printers on DIY Garden or Greenhouse Watering controller.