For fast transaction call 0916.457.0748
DIY Arduino Monitoring and Setting up Temperature (Incubator) --Tutorial

DIY Arduino Monitoring and Setting up Temperature (Incubator) --Tutorial

Create you very own Incubator System, made easy using this Tutorial. A stainless steel package Waterproof DS18b20 temperature probe temperature sensor could be of use. This includes the basic step and guide to create your DIY Project..

 

DIY Incubator system with Arduino.

Hardware Required:
  • Arduino Uno R3
  • DS18b20 Temperature Probe Temperature Sensor
  • 1602 LCD with IIC
  • 4x4 Matrix Keypad Membrane
  • 1 Channel Relay Module
  • 4.7k ohm Resistors
  • Connecting Wire

DS18b20 Temperature Probe Temperature Sensor Connections:

- The Sensor VCC connect to 4.7k ohm resistor and then connect to the Arduino Board +5V
- The Sensor GND connect to 4.7k ohm resistor and then connect to the Arduino Board GND
- The Sensor DQ  connect to the Arduino Board Digital I/O 10

 

1602 LCD Display with IIC– Arduino Connections:
- The  VCC connect to the Arduino Board +5V
- The GND connect to the Arduino Board GND
- The  SCL connect to the Arduino Arduino Board Analog I/O 4 (SCL)
- The SDA connect to the Arduino Board Board Analog I/O 5 (SDA)
 
1 Channel Relay Module Connections:
- The  VCC connect to the Arduino Board +5V
- The GND connect to the Arduino Board GND
- The  INPUT connect to the Arduino Arduino Board Digital I/O 11
4x4 Matrix Keypad Membrane Connections:
-The keypad has 8 pins, 4 of them are for the rows and other 4 pin for the columns.
-The Keypad's pins will be connected respectively to the Digital 9-8-7-6-5-4-3-2 pin of the Arduino.

    Schematic Diagram:

The schematic for this project is a fairly easy to replicate one. we have covered connecting the DS18b20 Temperature Probe Temperature Sensor and 4x4 Matrix Keypad Membrane and the One Channel relay and also 1602 LCD Display with IIC to the Arduino Uno R3.

Building the Code

For you to make this project work, you’ll need first to download the Arduino Software and install it in your computer. To do so, visit the Arduino Website and download the application.

Libraries

#include <Wire.h>
#include <LiquidCrystal_I2C.h> // Using version 1.2.1
#include <Keypad.h>
#include <OneWire.h>
#include <EEPROM.h>

String input;
String value = "0";
String tempVal="NAN";
String dot;

char junk;
String inputString="";
boolean first = true;

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'.','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
#define relay 11
#define DS18S20_Pin 12 //DS18S20 Signal pin on digital 2




//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 2

//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value

unsigned long previousMillis = 0;

// constants won't change :
const long interval = 5000;

int addr1 = 0;
int addr2 = 1;
String saveValue;

int switchIn = 12;

int val1;
int val2;
String TempCondition = "HIGH";
void setup(){
Serial.begin(9600);
pinMode(relay, OUTPUT);

saveValue = String( EEPROM.read(addr1)) + "." + String( EEPROM.read(addr2));
value = saveValue;

lcd.backlight();
lcd.begin(16,2);
initialize();
delay(8000);
lcd.clear();
setLCD();
}

void initialize(){
lcd.backlight();
lcd.begin(16,2); // sixteen characters across - 2 lines
lcd.setCursor(0,0);
lcd.print("Connected Cities");
lcd.setCursor(0,1);
lcd.print("Sett. and Monit.");
}

void loop(){
char customKey = customKeypad.getKey();
unsigned long currentMillis = millis();

if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;

// hum = dht.readHumidity();
temp= getTemp();
tempVal = String(temp);
//Print temp to serial monitor
Serial.println("Temp: " + String(temp) + " Celsius \nTemp Limit: " + value + " Celsius\n" + "Temp Condition: "+TempCondition);

lcd.setCursor(0,0); // first character - 1st line
lcd.print("TempRead: " + String(tempVal));


if (temp <= value.toFloat() && temp > 0 )
{
digitalWrite(relay, HIGH);
}else{
digitalWrite(relay, LOW);
}
if (temp >= value.toFloat() && temp > 0 )
{
digitalWrite(relay, HIGH);
}else{
digitalWrite(relay, LOW);
}

}


if(Serial.available()){
delay(500);
while(Serial.available())
{
char inChar = Serial.read(); //read the input
inputString += inChar; //make a string of the characters coming on serial
}

while (Serial.available() > 0)
{ first = false;
junk = Serial.read() ; } // clear the serial buffer

inputString.toUpperCase();

if ((inputString.toInt()>=0)&&(inputString.toInt()<=100)){
value = inputString.toFloat();
val1 = (value.substring(0,3)).toInt();
val2 = (value.substring(3,5)).toInt();
EEPROM.write(addr1, val1);
EEPROM.write(addr2, val2);
setLCD();
}

Serial.println("The Temperature limit is set to " + String(inputString.toFloat()) + " Degrees" );
inputString = "";
}

if (customKey){

//Serial.println(customKey);

if (String(customKey) != "A" and String(customKey) != "B" and String(customKey) != "C" and String(customKey) != "D" and String(customKey) != "#" )
{
if ((String(customKey) == "." or String(customKey) == "0") and input == "" ){
setLCD();
}else{
if (input == ""){
lcd.clear();
input += String(customKey);
editLCD();
}else{

//if(String(customKey) == "." && dot.length() >= 1)
if (input.indexOf(".") > -1)
{ if (String(customKey) != "."){
input += String(customKey);
editLCD();
}
} else{
if(String(customKey) == ".")
{
dot += String(customKey);
}

input += String(customKey);
editLCD();
}
}
}

}else{

if (input == "")
{
setLCD();
}
}


if (String(customKey)== "A" and input != "")
{
if ((input.toInt()>=0)&&(input.toInt()<=100)){
value = String(input.toFloat());

val1 = (value.substring(0,3)).toInt();
val2 = (value.substring(3,5)).toInt();
EEPROM.write(addr1, val1);
EEPROM.write(addr2, val2);
setLCD();
}else{
setLCD();
}
dot = "";
input = "";

}

if (String(customKey)== "C" and input != "")
{
setLCD();

dot = "";
input = "";
}

if (String(customKey)== "D" and input != "")
{
int inputLength = input.length() - 1;
input.remove(inputLength);
lcd.clear();
editLCD();

}


}
}

void setLCD(){
lcd.clear();
lcd.setCursor(0,0); // first character - 1st line
lcd.print("TempRead: " + tempVal);
lcd.setCursor(0,1); // 8th character - 2nd line
lcd.print("Set-Temp: " + value);
}
void editLCD(){
lcd.setCursor(0,0); // first character - 1st line
lcd.print("TempRead: " + tempVal);
lcd.setCursor(0,1); // 8th character - 2nd line
lcd.print("Edit: " + input);
}

float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1000;
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;
}

ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

delay(750); // Wait for temperature conversion to complete

byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad


for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}

ds.reset_search();

byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;

}

Connect your Arduino Board to your computer using the Power Cable.

Open up your Arduino software and write the following code:


Select the Board and Port you are using, in the Menu Bar select “Tools”. Select the corresponding board you are using and the designated port. Check this out on how to select board, Arduino moisture sensor kit.

Upload your code.

Documents:

 

 

Happy Coding!


0 comments

Leave a comment

Please note, comments must be approved before they are published

Payment Methods

Facebook Rewards Program