From 78907b67bf8d0bc921e826912f59e5ec312fe3ce Mon Sep 17 00:00:00 2001 From: Marcus Date: Mon, 1 Apr 2024 23:47:11 +0200 Subject: [PATCH] tidy up stuff --- Arduino/CanGrow/CanGrow.ino | 26 +-- KiCad/CanGrow/CanGrow.kicad_sch | 272 +++++++++++++++++++------------- 2 files changed, 179 insertions(+), 119 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 024bf86..6be27d3 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -7,11 +7,13 @@ * D0 - MOSFET Fan * D1, D2 - I2C * D3 - DHT11 - * D4 - water level Vcc + * D4 - analog soil moisture (set HIGH to read value) * D5 - MOSFET Grow LED, PWM * D6 - MOSFET Pump - * A0 - water level + * D7 - waterlevel (set HIGH to read value) + * A0 - analog input for soil moisture and waterlevel readings * + * D4 and D7 cannot be HIGH at the same time! */ @@ -21,12 +23,16 @@ #include #include "DHT.h" +// D0 is HIGH at boot, no PWM uint8_t PINfan = D0; +// If D3 is pulled to LOW, boot fails uint8_t PINdht = D3; -uint8_t PINwater = D4; -uint8_t PINled = D5; +// D4 is HIGH at boot, boot fail if pulled to LOW +uint8_t PINsoilmoisture = D4; +uint8_t PINled = D5; // uint8_t PINpump = D6; -uint8_t PINAwater = A0; +uint8_t PINwaterlevel = D7; +uint8_t PINanalog = A0; #define WIRE Wire #define DHTTYPE DHT11 @@ -115,13 +121,13 @@ int getWaterlevel() { int waterlevel = 0; // enable Vcc for water level sensor - digitalWrite(PINwater, HIGH); + digitalWrite(PINwaterlevel, HIGH); // wait a bit to let the circuit stabilize delay(200); // get the value - waterlevelRAW = analogRead(PINAwater); + waterlevelRAW = analogRead(PINanalog); // disable Vcc for the sensor to prevent electrolysis effect - digitalWrite(PINwater, LOW); + digitalWrite(PINwaterlevel, LOW); if( waterlevelRAW >= waterlevelOK) { waterlevel = 0; @@ -176,13 +182,13 @@ void setup() { // setup pins pinMode(PINfan, OUTPUT); pinMode(PINdht, INPUT); - pinMode(PINwater, OUTPUT); + pinMode(PINwaterlevel, OUTPUT); pinMode(PINled, OUTPUT); pinMode(PINpump, OUTPUT); // set all OUTPUT to low digitalWrite(PINfan, LOW); - digitalWrite(PINwater, LOW); + digitalWrite(PINwaterlevel, LOW); digitalWrite(PINled, LOW); digitalWrite(PINpump, LOW); diff --git a/KiCad/CanGrow/CanGrow.kicad_sch b/KiCad/CanGrow/CanGrow.kicad_sch index 4520342..613fc74 100644 --- a/KiCad/CanGrow/CanGrow.kicad_sch +++ b/KiCad/CanGrow/CanGrow.kicad_sch @@ -2219,12 +2219,6 @@ (color 0 0 0 0) (uuid "3ba18a05-a3a5-4dfb-aa21-406b58722355") ) - (junction - (at 96.52 113.03) - (diameter 0) - (color 0 0 0 0) - (uuid "3fcf56fb-9699-4c85-969b-d4d8bbd8d8dd") - ) (junction (at 175.26 34.29) (diameter 0) @@ -2261,6 +2255,12 @@ (color 0 0 0 0) (uuid "86b0fa74-bdbc-4882-9ce7-38fa88e6e628") ) + (junction + (at 96.52 113.03) + (diameter 0) + (color 0 0 0 0) + (uuid "887b2e08-7f9a-45fe-a977-7ccb7629934f") + ) (junction (at 96.52 128.27) (diameter 0) @@ -2297,12 +2297,6 @@ (color 0 0 0 0) (uuid "bcd150de-5c02-47e1-bec1-a53a32897324") ) - (junction - (at 113.03 74.93) - (diameter 0) - (color 0 0 0 0) - (uuid "d68e4a4d-c8fc-4ee1-b8e8-3949c30f459c") - ) (junction (at 194.31 102.87) (diameter 0) @@ -2341,16 +2335,6 @@ ) (uuid "02db16e6-e6ee-4653-8ada-7077b7824c5b") ) - (wire - (pts - (xy 143.51 113.03) (xy 96.52 113.03) - ) - (stroke - (width 0) - (type default) - ) - (uuid "032d577e-6f63-4a84-8f7c-913492db88fb") - ) (wire (pts (xy 96.52 128.27) (xy 76.2 128.27) @@ -2511,16 +2495,6 @@ ) (uuid "28ab5e54-0c4e-482e-84c3-246d70d3c359") ) - (wire - (pts - (xy 135.89 74.93) (xy 135.89 162.56) - ) - (stroke - (width 0) - (type default) - ) - (uuid "28cf53cf-5d6e-465f-a364-2216104e9424") - ) (wire (pts (xy 196.85 59.69) (xy 196.85 72.39) @@ -2573,7 +2547,7 @@ ) (wire (pts - (xy 91.44 162.56) (xy 91.44 139.7) + (xy 88.9 162.56) (xy 88.9 139.7) ) (stroke (width 0) @@ -2723,13 +2697,13 @@ ) (wire (pts - (xy 104.14 128.27) (xy 107.95 128.27) + (xy 113.03 74.93) (xy 121.92 74.93) ) (stroke (width 0) (type default) ) - (uuid "60f78313-3ef1-44c6-bd6e-48a5aafe45bd") + (uuid "60858c9e-3aa5-42ee-8d08-3f07ef30bd2b") ) (wire (pts @@ -2771,6 +2745,16 @@ ) (uuid "6947bf00-6b97-4d86-bd8b-455c4162d0c2") ) + (wire + (pts + (xy 96.52 113.03) (xy 121.92 113.03) + ) + (stroke + (width 0) + (type default) + ) + (uuid "69883160-6c1d-4ecb-85be-869ac9e04202") + ) (wire (pts (xy 229.87 137.16) (xy 229.87 144.78) @@ -2781,16 +2765,6 @@ ) (uuid "6e5434af-f46b-4937-b366-c34056bd7ea2") ) - (wire - (pts - (xy 111.76 74.93) (xy 113.03 74.93) - ) - (stroke - (width 0) - (type default) - ) - (uuid "70079a58-2613-4dee-8900-9eda77ca27eb") - ) (wire (pts (xy 63.5 113.03) (xy 76.2 113.03) @@ -2821,6 +2795,16 @@ ) (uuid "76de1bc4-8827-4569-8281-b9c3674ee33b") ) + (wire + (pts + (xy 100.33 128.27) (xy 96.52 128.27) + ) + (stroke + (width 0) + (type default) + ) + (uuid "773af645-696a-4885-8f8c-436863b4b456") + ) (wire (pts (xy 195.58 62.23) (xy 186.69 62.23) @@ -2851,6 +2835,16 @@ ) (uuid "81ac692e-5ed3-41d8-aba1-339ce39a462e") ) + (wire + (pts + (xy 125.73 67.31) (xy 125.73 162.56) + ) + (stroke + (width 0) + (type default) + ) + (uuid "82bf73e6-1e06-4d48-b8e8-0eb464281ae0") + ) (wire (pts (xy 196.85 59.69) (xy 191.77 59.69) @@ -2991,6 +2985,16 @@ ) (uuid "a86c5d20-d0f9-4a10-8c89-5778e67bae69") ) + (wire + (pts + (xy 121.92 113.03) (xy 121.92 74.93) + ) + (stroke + (width 0) + (type default) + ) + (uuid "aa03e087-2387-4424-9be9-a946d32d8fc5") + ) (wire (pts (xy 194.31 52.07) (xy 207.01 52.07) @@ -3001,6 +3005,16 @@ ) (uuid "aa568138-fdbb-4963-a381-ba38037933cf") ) + (wire + (pts + (xy 107.95 135.89) (xy 107.95 147.32) + ) + (stroke + (width 0) + (type default) + ) + (uuid "aabc615b-f422-426f-9d3a-bf154bcc895d") + ) (wire (pts (xy 195.58 124.46) (xy 195.58 133.35) @@ -3013,7 +3027,7 @@ ) (wire (pts - (xy 91.44 139.7) (xy 105.41 139.7) + (xy 88.9 139.7) (xy 105.41 139.7) ) (stroke (width 0) @@ -3061,16 +3075,6 @@ ) (uuid "b3178a5e-1bda-43d9-966f-0ecf57635e67") ) - (wire - (pts - (xy 113.03 74.93) (xy 135.89 74.93) - ) - (stroke - (width 0) - (type default) - ) - (uuid "b33a6673-3a5a-4954-8f6b-041508be1124") - ) (wire (pts (xy 186.69 34.29) (xy 186.69 62.23) @@ -3211,26 +3215,6 @@ ) (uuid "d7d7e573-b016-4d24-9dc2-0ccb8b7991b0") ) - (wire - (pts - (xy 143.51 113.03) (xy 143.51 67.31) - ) - (stroke - (width 0) - (type default) - ) - (uuid "d87c5476-0abf-445a-8142-f7846b8cb268") - ) - (wire - (pts - (xy 143.51 67.31) (xy 113.03 67.31) - ) - (stroke - (width 0) - (type default) - ) - (uuid "d8a866b3-c81b-4fde-9f8e-5b40f12b5a54") - ) (wire (pts (xy 195.58 62.23) (xy 207.01 62.23) @@ -3251,16 +3235,6 @@ ) (uuid "db61337a-958a-42db-afb6-f9a590107788") ) - (wire - (pts - (xy 107.95 139.7) (xy 107.95 128.27) - ) - (stroke - (width 0) - (type default) - ) - (uuid "ddf7dd90-db97-477a-ba0b-157cbfd8ba17") - ) (wire (pts (xy 207.01 54.61) (xy 207.01 55.88) @@ -3313,7 +3287,7 @@ ) (wire (pts - (xy 135.89 162.56) (xy 91.44 162.56) + (xy 125.73 162.56) (xy 88.9 162.56) ) (stroke (width 0) @@ -3411,6 +3385,16 @@ ) (uuid "ff7d6bc6-4b02-421e-8637-954dcc023e3a") ) + (wire + (pts + (xy 125.73 67.31) (xy 113.03 67.31) + ) + (stroke + (width 0) + (type default) + ) + (uuid "ff95b020-31d3-4ab4-b0cf-084e390728d3") + ) (wire (pts (xy 113.03 62.23) (xy 184.15 62.23) @@ -3421,9 +3405,19 @@ ) (uuid "ffca93ab-b7c3-4700-b47f-27eae3d79c02") ) + (text "Pin D1" + (exclude_from_sim no) + (at 176.53 58.674 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "04443e34-f340-412a-adef-685faa808af9") + ) (text "Pin A0" (exclude_from_sim no) - (at 109.474 127.508 0) + (at 116.84 127.254 0) (effects (font (size 1.27 1.27) @@ -3431,9 +3425,19 @@ ) (uuid "39e00273-5e15-4d2a-a28b-3cc82f788021") ) + (text "Pin D3" + (exclude_from_sim no) + (at 176.53 64.008 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "4572a1de-9a19-412e-8d9e-76db759282ac") + ) (text "1 - GND\n2 - VCC\n3 - SDL\n4 - SDA" (exclude_from_sim no) - (at 226.314 50.292 0) + (at 223.52 52.07 0) (effects (font (size 1.27 1.27) @@ -3441,9 +3445,9 @@ ) (uuid "7689a88c-af3d-4840-bb58-6e6681a3a179") ) - (text "Pin D4" + (text "Pin D7" (exclude_from_sim no) - (at 109.474 112.268 0) + (at 116.84 112.014 0) (effects (font (size 1.27 1.27) @@ -3451,9 +3455,19 @@ ) (uuid "775809ed-2a46-4309-b3e6-c2542e0c428d") ) + (text "Pin D5" + (exclude_from_sim no) + (at 165.862 101.6 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "83b1817d-1f50-4b64-a6c2-60a1a6be5888") + ) (text "1 - GND\n2 - VCC\n3 - AOUT" (exclude_from_sim no) - (at 119.126 147.066 0) + (at 94.742 150.622 0) (effects (font (size 1.27 1.27) @@ -3461,6 +3475,16 @@ ) (uuid "a1650987-1fd0-4684-839d-80d4778c0e67") ) + (text "Pin D4" + (exclude_from_sim no) + (at 121.666 161.29 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "a1c7d76d-f1c1-40f9-a56c-24cbb390238e") + ) (text "1 - OK\n2 - WARN\n3 - CRIT" (exclude_from_sim no) (at 53.594 133.35 0) @@ -3471,6 +3495,36 @@ ) (uuid "cbb7a8c6-8b4b-4eb4-98cc-0849b2ef00c7") ) + (text "Pin D0" + (exclude_from_sim no) + (at 162.56 122.936 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "d76302cb-34ae-4743-ba3c-9cc8fd6ce438") + ) + (text "Pin D2" + (exclude_from_sim no) + (at 176.53 61.468 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "ed0219c8-973d-498e-8890-9f912de965bb") + ) + (text "Pin D6" + (exclude_from_sim no) + (at 160.274 143.51 0) + (effects + (font + (size 1.27 1.27) + ) + ) + (uuid "f6b2e8f4-3011-4331-95b6-2b3c15750b4e") + ) (symbol (lib_id "power:+12V") (at 74.93 39.37 0) @@ -4726,7 +4780,7 @@ ) ) ) - (property "Value" "analog moisture sensor" + (property "Value" "analog soil moisture sensor" (at 105.41 157.48 90) (effects (font @@ -5062,7 +5116,7 @@ ) (symbol (lib_id "Device:D") - (at 100.33 128.27 180) + (at 104.14 128.27 180) (unit 1) (exclude_from_sim no) (in_bom yes) @@ -5071,7 +5125,7 @@ (fields_autoplaced yes) (uuid "989421c9-ff1f-4ea0-ba31-3d0065021ff3") (property "Reference" "D1" - (at 100.33 121.92 0) + (at 104.14 121.92 0) (effects (font (size 1.27 1.27) @@ -5079,7 +5133,7 @@ ) ) (property "Value" "D" - (at 100.33 124.46 0) + (at 104.14 124.46 0) (effects (font (size 1.27 1.27) @@ -5087,7 +5141,7 @@ ) ) (property "Footprint" "Diode_THT:D_DO-15_P12.70mm_Horizontal" - (at 100.33 128.27 0) + (at 104.14 128.27 0) (effects (font (size 1.27 1.27) @@ -5096,7 +5150,7 @@ ) ) (property "Datasheet" "~" - (at 100.33 128.27 0) + (at 104.14 128.27 0) (effects (font (size 1.27 1.27) @@ -5105,7 +5159,7 @@ ) ) (property "Description" "Diode" - (at 100.33 128.27 0) + (at 104.14 128.27 0) (effects (font (size 1.27 1.27) @@ -5114,7 +5168,7 @@ ) ) (property "Sim.Device" "D" - (at 100.33 128.27 0) + (at 104.14 128.27 0) (effects (font (size 1.27 1.27) @@ -5123,7 +5177,7 @@ ) ) (property "Sim.Pins" "1=K 2=A" - (at 100.33 128.27 0) + (at 104.14 128.27 0) (effects (font (size 1.27 1.27) @@ -5565,7 +5619,7 @@ ) (symbol (lib_id "Device:D") - (at 107.95 143.51 270) + (at 107.95 132.08 270) (unit 1) (exclude_from_sim no) (in_bom yes) @@ -5574,7 +5628,7 @@ (fields_autoplaced yes) (uuid "bcc49de9-25fe-4d07-ac16-da2af4bb20ac") (property "Reference" "D2" - (at 110.49 142.2399 90) + (at 110.49 130.8099 90) (effects (font (size 1.27 1.27) @@ -5583,7 +5637,7 @@ ) ) (property "Value" "D" - (at 110.49 144.7799 90) + (at 110.49 133.3499 90) (effects (font (size 1.27 1.27) @@ -5592,7 +5646,7 @@ ) ) (property "Footprint" "Diode_THT:D_DO-15_P12.70mm_Horizontal" - (at 107.95 143.51 0) + (at 107.95 132.08 0) (effects (font (size 1.27 1.27) @@ -5601,7 +5655,7 @@ ) ) (property "Datasheet" "~" - (at 107.95 143.51 0) + (at 107.95 132.08 0) (effects (font (size 1.27 1.27) @@ -5610,7 +5664,7 @@ ) ) (property "Description" "Diode" - (at 107.95 143.51 0) + (at 107.95 132.08 0) (effects (font (size 1.27 1.27) @@ -5619,7 +5673,7 @@ ) ) (property "Sim.Device" "D" - (at 107.95 143.51 0) + (at 107.95 132.08 0) (effects (font (size 1.27 1.27) @@ -5628,7 +5682,7 @@ ) ) (property "Sim.Pins" "1=K 2=A" - (at 107.95 143.51 0) + (at 107.95 132.08 0) (effects (font (size 1.27 1.27)