Documentation **[[Documentation|Home]]** ====== BASIC INFORMATION ====== Name: **Sensor for measure soil temperature and humidity**\\ Type: **Sensor Board**\\ Version: **2.0.0**\\ Author: **Dubravko Penezic**\\ Copyright: **Creative Commons BY-NC-SA v 3.0**\\ Implemented function: * **Measure soil temperature in 3 points (20cm and 10cm deep and on soil level) with DS18B20** * **4 capacitive area (2 between 20cm and 10 cm deep, and 2 between 10cm deep and soil level)** * **LED signalling depends of configuration (A setup blue,green,red and B setup green,red** * **2x5 connector** * **2 3mm mounting holes** * **Clear foil surface protection and dielectric grass pin temperature sensor protection** * **Modular deep (PCB can be shorten to 10cm deep)** * **Compatibile with Arduino 1-Wire and CapSense library (10M resistor and 220pF parallel condensator)** ===== PCB Top and Bottom Image ===== {{:soil_sensor:img_4015.png?300|}}\\ ===== Schematic ===== {{:soil_sensor:soil_sensor_schematic_v200.png?300|}}\\ ===== Dimension ===== Dimension represent in {{:soil_sensor:soil_sensor_v200.pdf|PDF}} and {{:soil_sensor:soil_sensor_web_v200.dxf|DXF}} files.\\ ===== Final product ===== **Type A**:\\ Functionality same like sensor version [[sensor_soil_1|V1.0.0]].\\ 4 capacitive sensing area, 3 temperature DS18B20 sensor, 3 LED (blue,green,red)\\ {{:soil_sensor:img_4046.png?300|}}\\ \\ **Type B**:\\ 4 capacitive sensing area, 3 temperature DS18B20 sensor, 2 LED (green,red), R-C set for every capacitive sensing are (direct connectivity to digital pin is possible)\\ {{:soil_sensor:img_4044.png?300|}}\\ ====== Example of use ====== ====== Software Example ====== Used library [[arduino_lib_dp1wbasic|Dp1WBasic library]], [[arduino_lib_dp1wds18xxxtermo|Dp1WDS18xxxTermo library]] and [[http://playground.arduino.cc//Main/CapacitiveSensor?from=Main.CapSense| Capacitive Sensing]] .\\ \\ /* Author: Dubravko Penezic Version: 1.0, 2013 This code is example how to use Sensor for measure soil temperature and humidity. Source code is provided as is, without any warranty. Distributetd under CC BY v 3.0 */ // include 1Wire library #include #include // Data wire is plugged into port 5 on the Arduino #define ONE_WIRE_BUS 5 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) Dp1WBasic oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. Dp1WDS18xxxTermo tSen(&oneWire); // arrays to hold device address SensorInfo tempSensors[16]; //include CapSense library #include CapSense cs_7_9 = CapSense(7,9); // 10M resistor between pins 7 & 9, pin 9 is sensor pin CapSense cs_7_10 = CapSense(7,10); // 10M resistor between pins 7 & 10, pin 10 is sensor pin CapSense cs_7_11 = CapSense(7,11); // 10M resistor between pins 7 & 11, pin 11 is sensor pin CapSense cs_7_12 = CapSense(7,12); // 10M resistor between pins 7 & 12, pin 12 is sensor pin // set LED pin byte led1 = 6; byte led2 = 8; byte led3 = 13; void setup(void) { // cs_7_9.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600); Serial.println("DpSoilCapTempSensor V 1.0"); pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); delay(10000); } void loop(void) { byte broj = tSen.readTemperature(tempSensors, 16, NORMAL_SEARCH); if(broj == 0 ) { Serial.print("\n\nNo 1-Wire Temperature Sensor Found on Digital Pin "); Serial.println(ONE_WIRE_BUS); } else { for(byte i = 0; i < broj; i++) { Serial.print("\n\nTemperature sensor "); Serial.print(i); Serial.println("."); Serial.print("ROM Address: \t\t"); for(byte j=0; j<8;j++) { if (tempSensors[i].dAddr[j] < 16) Serial.print("0"); Serial.print(tempSensors[i].dAddr[j], HEX); } Serial.print("\nSensor type: \t\t"); switch (tempSensors[i].dAddr[0]) { case DS18B20MODEL: Serial.println("DS18B20"); break; case DS1822MODEL: Serial.println("DS1822"); break; case DS18S20MODEL: Serial.println("DS18S20/DS1820"); break; } Serial.print("Actual temperature \t"); Serial.print(tempSensors[i].dTemperature); Serial.print(" C ("); Serial.print(getResolution(tempSensors[i].dAddr,tempSensors[i].dTempReso),DEC); Serial.println(" bit)"); Serial.print("Alarm Low Temperature \t"); Serial.print(tempSensors[i].dMinAlarm,2); Serial.println(" C"); Serial.print("Alarm High Temperature \t"); Serial.print(tempSensors[i].dMaxAlarm,2); Serial.println(" C"); if(i==0) { if(tempSensors[i].dTemperature>28) { digitalWrite(led1, HIGH); } else { digitalWrite(led1, LOW); } } if(i==1) { if(tempSensors[i].dTemperature>28) { digitalWrite(led2, HIGH); } else { digitalWrite(led2, LOW); } } if(i==2) { if(tempSensors[i].dTemperature>28) { digitalWrite(led3, HIGH); } else { digitalWrite(led3, LOW); } } } } for(byte j = 0; j <25; j++) { long start = millis(); long total1 = cs_7_9.capSense(30); long total2 = cs_7_10.capSense(30); long total3 = cs_7_11.capSense(30); long total4 = cs_7_12.capSense(30); Serial.print(millis() - start); // check on performance in milliseconds Serial.print("\t"); // tab character for debug windown spacing Serial.print(total1); // print sensor output 1 Serial.print("\t"); Serial.print(total2); // print sensor output 2 Serial.print("\t"); Serial.print(total3); // print sensor output 3 Serial.print("\t"); Serial.println(total4); // print sensor output 3mit data to serial por delay(20); } } byte getResolution(uint8_t* deviceAddress, uint8_t conf) { if (deviceAddress[0] == DS18S20MODEL) return 9; // this model has a fixed resolution switch (conf) { case TEMP_12_BIT: return 12; case TEMP_11_BIT: return 11; case TEMP_10_BIT: return 10; case TEMP_9_BIT: return 9; } return 0; }