{"id":337,"date":"2013-04-22T14:16:31","date_gmt":"2013-04-22T12:16:31","guid":{"rendered":"http:\/\/saulevire.lt\/?page_id=337"},"modified":"2025-06-01T19:08:16","modified_gmt":"2025-06-01T17:08:16","slug":"valdiklio_programa","status":"publish","type":"page","link":"https:\/\/saulevire.lt\/en\/kolektoriaus-valdiklis\/valdiklio_programa\/","title":{"rendered":"(Lietuvi\u0173) Valdiklio programa"},"content":{"rendered":"<p><\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\/\/\r\n\/\/ W w w. S a l u e V i r e. l t\r\n\/\/\r\n\/\/ The project is titled &quot;DIY hot water solar controller.\r\n\/\/ All files are here - http:\/\/fritzing.org\/projects\/hot-water-solar-controller\/\r\n\/\/\r\n\/\/ CHANGES\r\n\/\/\r\n\/\/ 2013 05 12\r\n\/\/ Added the ability to select the PCB version. Lithuania and China produce plaques\r\n\/\/ Use different CPU conclusion.\r\n\/\/ Therefore, before recording, select a plate with which the processor will work. Look for the line &quot;# define VERSIJA_1.0&quot;\r\n\/\/ 2013 05 05\r\n\/\/ Displayed if the anti-freeze\r\n\/\/ 2013 04 27\r\n\/\/ Attached the pump start and stop values printing\r\n\/\/ 2013 04 23\r\n\/\/ Added the variable &quot;freezing&quot; frost protection enabled (freezing = 1) or off (freezing = 0)\r\n\/\/\r\n\/\/ Required libraries:\r\n\/\/ &quot;Dallas Temperature Control Library here:\r\n\/\/ Http:\/\/milesburton.com\/index.php?title=Dallas_Temperature_Control_Library\r\n\/\/ OneWire (Version 2.1) library here:\r\n\/\/ Http:\/\/www.pjrc.com\/teensy\/arduino_libraries\/OneWire.zip\r\n\/\/ Library should be unpacked to C: \\ arduino-xxx \\ library directory. c: \\ arduino-xxx \\ library \\ dallas-temperature-control\r\n\/\/ Need to rename the folder to C: \\ arduino-xxx \\ library \\ DallasTemperatureControl (without dashes)\r\n\/\/\r\n\/\/ First When the temperature difference between the solar collector and the tank more than 5 degrees, the switch is turned on.\r\n\/\/ Temperture is measured and displayed on the screen constantly, but the difference is checked every 15 seconds.\r\n\/\/ Second When the temperature difference between the solar collector and the tank is less than 2 degrees, the pump drives the relay is switched off.\r\n\/\/ Difference checked every 15 seund\u017ei\u0173.\r\n\/\/ Third Potentiometer can ask any number from 0 to 100, it is displayed on the screen. When the 3-ber temperature sensor\r\n\/\/ Reaches the limit switches 2nd relay. Temperature falls below the limit switch turns off.\r\n\/\/ 4th Instead of the two sensors (2 i\u0161litavus cages or track perpovus board) can connect another 2 channel\r\n\/\/ Relay module and the necessary sensors connected sequentially on a single cable. For the controller to work after such changes\r\n\/\/ Must be a minimum program of improvements.\r\n\/\/ 5th DS18B20 sensors can be connected 2 or 3 wires.\r\n\/\/ 6th The display shows the boiler temperature, collector temperature, the temperature difference\r\n\/\/ 3-ber temperature sensor, potentiometer preset temperature, relay status.\r\n\/\/ 7. If the collector temperature is less than or equal to 0, the pump and the collector from freezing.\r\n\/\/\r\n\/\/\r\n\r\n#include &lt;LiquidCrystal.h&gt;\r\n#include &lt;OneWire.h&gt;\r\n#include &lt;DallasTemperature.h&gt;\r\n\r\n\/\/ Comment out the existing line &quot;# define VERSIJA_1.0&quot; if you are on your polok\u0161tel\u0117s\r\n\/\/ Www.SauleVire.lt advertising and the &quot;Order # 100010284&quot;\r\n\/\/#define VERSIJA_1.0\r\n#ifdef VERSIJA_1.0\r\n\/\/ Here the first version of the plate used in the conclusion (produced in Lithuania, yellow)\r\n#define Pump 11 \/\/Siurblio valdymo rel\u0117s i\u0161vadas\r\n#define Relay2 12 \/\/Termostato valdymo rel\u0117s i\u0161vadas\r\nint analogPin = A0; \/\/daugias\u016bkio rezistoriaus pajungimo i\u0161vadas\r\n#else\r\n\/\/ Here the second version of the plate used in the conclusion (produced in China, green)\r\n#define Pump A0 \/\/Siurblio valdymo rel\u0117s i\u0161vadas\r\n#define Relay2 A1 \/\/Termostato valdymo rel\u0117s i\u0161vadas\r\nint analogPin = A2; \/\/\/\/daugias\u016bkio rezistoriaus pajungimo i\u0161vadas\r\n#endif\r\n\r\n#define SERIAL_BAUD_RATE 9600\r\n\/\/ Temperature sensors data pins connected to the Arduino 8,9,10 outputs\r\n#define Collector 8 \/\/ collector sensor conclusions\r\n#define Boiler 9 \/\/\u00a0 Boiler sensor conclusions\r\n#define Temp_3 10 \/\/ thermostat sensor conclusions\r\n\r\nint relayPin = Pump;\r\nint relay2Pin = Relay2;\r\nstatic long timer_pump=0;\r\nstatic long timer_Relay2=0;\r\n\r\nstatic long timer_Collector_Error=0;\r\nstatic long timer_Boiler_Error=0;\r\n\/\/ Time Intervals\r\n\/\/ REQUEST_Pump_Control minimum pump relay operating time interval, the change in the temperature values\r\n\/\/ REQUEST_Relay2_Control minimum thermostat relay operating time interval, the change in the temperature values\r\n\/\/ Time interval REQUEST_Collector_Error action if the collector temperature sensor shows error\r\n\/\/ REQUEST_Boiler_Error interval operation if the boiler temperature sensor shows error\r\n#define REQUEST_Pump_Control 10000\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ 10000 millis= 10 sekundziu\r\n#define REQUEST_Relay2_Control 10000\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ 15000 millis= 15 sekundziu\r\n#define REQUEST_Collector_Error 180000\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ 120000 millis= 3 minut\u0117s\r\n#define REQUEST_Boiler_Error 10000\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ 30000 millis= 30 sekundziu\r\n\r\nint freezing = 1; \/\/ variable frost protection enabled (freezing = 1) or off (freezing = 0)\r\nint Differential_ON=3; \/\/ You asked what the temperature difference between the collector pump relay is activated\r\nint Differential_OFF=2; \/\/ to such differences pump relay off\r\nint Collector_Error, Boiler_Error; \/\/ sensor status &quot;error&quot; tag\r\nint Collector_Good, Boiler_Good; \/\/ sensor status 'all good' tag\r\nfloat Collector_tempC, Boiler_tempC, Sensor3_tempC; \/\/ ariables to store values \u200b\u200bof the temperature measurements\r\nfloat Saved_Collector_tempC, Saved_Boiler_tempC;\r\n\r\nbyte arrow_up&#x5B;8]={ \/\/ pump on indicator (arrow up)\r\nB00100,\r\nB01110,\r\nB11111,\r\nB00100,\r\nB00100,\r\nB00100,\r\nB00100,\r\nB00100\r\n};\r\nbyte arrow_down&#x5B;8]={ \/\/ Pump disarm symbol (arrow down)\r\nB00100,\r\nB00100,\r\nB00100,\r\nB00100,\r\nB00100,\r\nB11111,\r\nB01110,\r\nB00100\r\n};\r\n\r\n\/\/ Sets the values of the controller &quot;build bridges&quot; with sensors DS18B20\r\nOneWire Collector_T(Collector);\r\nOneWire Boiler_T(Boiler);\r\nOneWire Temp_T(Temp_3);\r\nDallasTemperature CollectorSensor(&amp;Collector_T);\r\nDallasTemperature BoilerSensor(&amp;Boiler_T);\r\nDallasTemperature TempSensor(&amp;Temp_T);\r\n\/\/ Sensor arrays to store addresses\r\nDeviceAddress Collector_Sensor_Address;\r\nDeviceAddress Boiler_Sensor_Address;\r\nDeviceAddress Temp_3_Sensor_Address;\r\n\r\n\/\/ LCD display settings\r\n\/\/ Connection:\r\n\/\/ Rs (LCD conclusions 4) to Arduino conclusions 2\r\n\/\/ Enable (LCD findings 6) to Arduino conclusions3\r\n\/\/ LCD findings 15 - 13 Arduino conclusions\r\n\/\/ LCD conclusion d4, d5, d6, d7 - Arduino outputs 4, 5, 6, 7\r\n\r\nint backLight = 13; \/\/ output 13 controls the display backlight\r\nLiquidCrystal lcd(2, 3, 4, 5, 6, 7);\r\n\/\/ Variable to keep the thermostat set point\r\nint val = 0;\r\n\/\/ General settings begin\r\nvoid setup() {\r\nSerial.begin(SERIAL_BAUD_RATE);\r\npinMode(Pump, OUTPUT);\r\npinMode(Relay2, OUTPUT),\r\n\/\/ Arduino preparing pinns for the LCD panel\r\npinMode(backLight, OUTPUT);\r\ndigitalWrite(backLight, HIGH); \/\/ activated lighting.\r\nlcd.createChar(1, arrow_down);\r\nlcd.createChar(2, arrow_up);\r\n\r\nlcd.begin(16, 2);\r\n\/\/ Promotional message output to the screen (this is very important :-).\r\nlcd.print(&quot;www.SauleVire.lt&quot;);\r\nSerial.println();\r\nSerial.println(&quot;www.SauleVire.lt&quot;);\r\nSerial.print(&quot;The pump turns on when the temperature difference will be - &quot;);\u00a0 Serial.println(Differential_ON);\r\nSerial.print(&quot;The pump turns off when the temperature difference will be - &quot;);\u00a0 Serial.println(Differential_OFF);\r\nif (freezing = 1) {Serial.println(&quot;The collector frost protection - ON&quot;);}\r\nelse {Serial.println(&quot;The collector frost protection - OFF&quot;);}\r\ndelay(5000); \/\/ Advertising takes only 5 seconds.\r\nlcd.clear();\r\nCollectorSensor.begin();\r\nif (!CollectorSensor.getAddress(Collector_Sensor_Address, 0))\r\nSerial.println(&quot;defective Collector temperature Sensor&quot;);\r\n\/\/ Set the maximum sensor-12-bit accuracy.\r\nCollectorSensor.setResolution(Collector_Sensor_Address, 12);\r\nBoilerSensor.begin();\r\nif (!BoilerSensor.getAddress(Boiler_Sensor_Address, 0))\r\nSerial.println(&quot;defective Boiler temperature Sensor&quot;);\r\n\/\/ Set the maximum sensor-12-bit accuracy.\r\nBoilerSensor.setResolution(Boiler_Sensor_Address, 12);\r\nTempSensor.begin();\r\nif (!TempSensor.getAddress(Temp_3_Sensor_Address, 0))\r\nSerial.println(&quot;defective Temp_3 temperature Sensor&quot;);\r\n\/\/ Set the maximum sensor-12-bit accuracy.\r\nTempSensor.setResolution(Temp_3_Sensor_Address, 12);\r\n}\r\n\/\/____________________________\r\n\/\/ End of program settings\r\n\/\/____________________________\r\nvoid loop() { \/\/ Satart main programm\r\nSerial.println();\r\nSerial.print(&quot;The pump turns ON when the temperature difference will be - &quot;);\u00a0 Serial.println(Differential_ON);\r\nSerial.print(&quot;The pump turns OFF when the temperature difference will be - &quot;);\u00a0 Serial.println(Differential_OFF);\r\n\r\nif (freezing == 1) {lcd.setCursor(14,0);\r\nlcd.print(&quot;*&quot;);}\r\n\r\nelse {Serial.println(&quot;Collector frost protection - OFF&quot;);\r\nlcd.setCursor(14,0);\r\nlcd.print(&quot; &quot;);\r\n}\r\n\r\nval = (analogRead(analogPin) * 100.0) \/ 1024; \/\/ read a resistor value variable for the thermostat\r\nlcd.setCursor(7,1);\r\nlcd.print(&quot;N&quot;);\r\nlcd.setCursor(8,1);\r\nlcd.print(val); \/\/ display resistor value on the screen\r\n\r\nTempSensor.requestTemperatures();\r\nSensor3_tempC=TempSensor.getTempC(Temp_3_Sensor_Address);\r\nSerial.print(&quot;The thermostat value &quot;); Serial.println(val); \/\/ printed to the terminal, if the computer is connected\r\nSensor3_tempC=TempSensor.getTempC(Temp_3_Sensor_Address);\r\nlcd.setCursor(11,1);\r\nlcd.print(Sensor3_tempC);\r\nSerial.println(Sensor3_tempC);\r\nif (millis() &gt; timer_Relay2 + REQUEST_Relay2_Control) {\r\ntimer_Relay2 = millis();\r\n\r\nif (Sensor3_tempC &gt;= val) { Rele_2_ijungta();}\r\nif (Sensor3_tempC &lt;= val) { Rele_2_isjungta();}\r\n\r\n}\r\n\r\nSerial.print((!CollectorSensor.getAddress(Collector_Sensor_Address, 0)));\r\nif (!CollectorSensor.getAddress(Collector_Sensor_Address, 0)) {\r\nlcd.setCursor(0,0);\r\nlcd.print(&quot;Collect. ERROR!&quot;);\r\nCollector_Error=1;\r\n}\r\nelse\r\n{\r\nCollectorSensor.requestTemperatures(); \/\/ command sensor to show the measured temperature\r\nSerial.print(&quot;Collector temperature: &quot;);\r\nCollector_tempC=CollectorSensor.getTempC(Collector_Sensor_Address);\r\nif (Collector_tempC==-127.00){\r\nlcd.setCursor(0,0);\r\nlcd.print(&quot;Collect. ERROR!&quot;);\r\nSerial.println(&quot; E R R O R !&quot;);\r\nCollector_Error=1;\r\n}\r\nelse\r\n{\r\nSerial.println(Collector_tempC);\r\nlcd.setCursor(0,0);\r\nlcd.print(&quot;K\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &quot;);\r\nlcd.setCursor(1,0);\r\nlcd.print(Collector_tempC);\r\nlcd.setCursor(9,0);\r\nlcd.print(&quot;\u00a0\u00a0\u00a0\u00a0\u00a0 &quot;);\r\nlcd.setCursor(9,0);\r\nlcd.print(Collector_tempC-Boiler_tempC);\r\nCollector_Good=1;\r\n}}\r\n\r\nif (!BoilerSensor.getAddress(Boiler_Sensor_Address, 0)) {\r\nlcd.setCursor(0,1);\r\nlcd.print(&quot; Boiler ERROR! &quot;);\r\nBoiler_Error=1;\r\n}\r\nelse{\r\nBoilerSensor.requestTemperatures();\r\nSerial.print(&quot;Boiler temperature: &quot;);\r\nBoiler_tempC=BoilerSensor.getTempC(Boiler_Sensor_Address);\r\nif (Boiler_tempC==-127.00){\r\nlcd.setCursor(0,1);\r\nlcd.print(&quot; Boiler ERROR! &quot;);\r\nSerial.println(&quot; E R R O R !&quot;);\r\nBoiler_Error=1;\r\n}\r\nelse{\r\nSerial.println(Boiler_tempC);\r\nlcd.setCursor(0,1);\r\nlcd.print(&quot;B\u00a0\u00a0\u00a0\u00a0\u00a0 &quot;);\r\nlcd.setCursor(1,1);\r\nlcd.print(Boiler_tempC);\r\nBoiler_Good=1;\r\n}}\r\n\/\/__________________________________________________\r\n\/\/ Check what must be the pump status. Start\r\n\/\/--------------------------------------------------\r\n\/\/ Variable REQUEST_Pump_Control indicates how often do\r\nif (millis() &gt; timer_pump + REQUEST_Pump_Control) {\r\ntimer_pump = millis();\r\nif (Boiler_Good==1){\r\nif (Collector_Good==1){\r\n\/\/ Check at the collector is not warmer than the boiler\r\nif (Collector_tempC - Boiler_tempC &gt;= Differential_ON) {\r\nSiurblys_ijungtas();\r\nSerial.println(&quot;PUMP\u00a0 _ON_&quot;);\r\n}\r\n\/\/ Check whether the collector and tank temperature difference is not less than the prescribed\r\nif (Collector_tempC - Boiler_tempC &lt;= Differential_OFF) {\r\nSiurblys_isjungtas();\r\nSerial.println(&quot;PUMP _OFF_&quot;);\r\n}\r\n\/\/ Freeze Protection\r\nif (freezing = 1) { \/\/if security is enabled,\r\n\/\/ Check if the collector temperature is positive\r\nif (Collector_tempC\u00a0 &lt;= 0 ) { \/\/ if temperature is negative,\r\nSiurblys_ijungtas();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Pump turn on\r\nSerial.println(&quot;switched frost protection ON&quot;);\r\n}}\r\n\/\/______________________________________________\r\n\/\/ Collector sensor error checking. START\r\n\/\/----------------------------------------------\r\n}else{\/\/\u00a0 If the collector temperature sensor is not working, the pump for 3 minutes (the time variable indicates REQUEST_Collector_Error)\r\n\r\nif (millis() &gt; timer_Collector_Error + REQUEST_Collector_Error) {\r\ntimer_Collector_Error = millis();\r\nSaved_Boiler_tempC=Boiler_tempC; \/\/ remembering the boiler temperature\r\nSiurblys_ijungtas();\r\nSerial.println(&quot;collector temperature measuring error, the pump is turned on&quot;);\r\n\r\n}else{ if (Saved_Boiler_tempC-Boiler_tempC &lt;=2){\r\nSiurblys_isjungtas(); \/\/ If the collector temperature sensor is not working and the boiler temperature drops, the pump is turned off\r\n}}\/\/______________________________________________\r\n\/\/ Collector sensor error checking START\r\n\/\/----------------------------------------------\r\n}}\r\nelse{ if (Collector_tempC &gt;=81){Siurblys_ijungtas();}\r\n\r\n}} \/\/__________________________________________________\r\n\/\/ End of the survey what must be the pump status.\r\n\/\/--------------------------------------------------\r\n\r\n}\/\/ End main programm\r\n\/\/_______________________________________\r\n\/\/\u00a0\u00a0\u00a0\u00a0\u00a0 subroutine\r\n\/\/ Pump and thermostat relay Switching\r\n\/\/---------------------------------------\r\n\/\/ Turn on the pump and the corresponding mark on the screen display\r\nvoid Siurblys_ijungtas()\u00a0 {\r\ndigitalWrite(Pump, LOW);\r\nlcd.setCursor(15,0);\r\nlcd.write((uint8_t)2);\/\/char up to LCD\r\n\/\/\u00a0\u00a0 lcd.setCursor(15,1);\r\n\/\/\u00a0\u00a0 lcd.write((uint8_t)2);\/\/char up to LCD\r\n}\r\n\/\/ Pump switch-off and the corresponding mark on the screen display\r\nvoid Siurblys_isjungtas(){\r\ndigitalWrite(Pump, HIGH);\r\nlcd.setCursor(15,0);\r\nlcd.write((uint8_t)1);\/\/char down to LCD\r\n\/\/\u00a0\u00a0 lcd.setCursor(15,1);\r\n\/\/\u00a0\u00a0 lcd.write((uint8_t)1); \/\/char down to LCD\r\n}\r\n\/\/ Thermostat relay on and the corresponding mark on the screen display\r\nvoid Rele_2_ijungta()\u00a0 {\r\ndigitalWrite(Relay2, LOW);\r\nlcd.setCursor(10,1);\r\nlcd.write((uint8_t)2);\/\/char up to LCD\r\n}\r\n\/\/ Thermostat relay switch-off and the corresponding mark on the screen display\r\nvoid Rele_2_isjungta(){\r\ndigitalWrite(Relay2, HIGH);\r\nlcd.setCursor(10,1);\r\nlcd.write((uint8_t)1); \/\/char down to LCD\r\n}<\/pre>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>\/\/ \/\/ W w w. S a l u e V i r e. l t \/\/ \/\/ The project is titled &quot;DIY hot water solar controller. \/\/ All files are here &#8211; http:\/\/fritzing.org\/projects\/hot-water-solar-controller\/ \/\/ \/\/ CHANGES \/\/ \/\/ 2013 &hellip; <a href=\"https:\/\/saulevire.lt\/en\/kolektoriaus-valdiklis\/valdiklio_programa\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-337","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/pages\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/comments?post=337"}],"version-history":[{"count":12,"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/pages\/337\/revisions"}],"predecessor-version":[{"id":1591,"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/pages\/337\/revisions\/1591"}],"up":[{"embeddable":true,"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/pages\/2"}],"wp:attachment":[{"href":"https:\/\/saulevire.lt\/en\/wp-json\/wp\/v2\/media?parent=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}