EcoRenovator  

Go Back   EcoRenovator > Improvements > Geothermal & Heat Pumps
Advanced Search
 


Blog 60+ Home Energy Saving Tips Recent Posts


 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 07-27-14, 11:24 PM   #10
buffalobillpatrick
Master EcoRenovator
 
Join Date: Mar 2014
Location: Florissant, Colorado
Posts: 599
Thanks: 814
Thanked 59 Times in 55 Posts
Default

Setup:

Code:
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>


#define I2C_ADDR    0x3F // <<----- Add your address here.  Find it from I2C Scanner

#define BACKLIGHT_PIN     3  //define LCD digital pins
#define En_pin  2
#define Rw_pin  1             //can't use D0 Tx & D1 Rx
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5              //can use 2 -> 12 below in code
#define D6_pin  6
#define D7_pin  7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

#define SDA                           A4  //RESERVE I2C for LCD           
#define SCL                           A5  

#define mux_analog_in                 A0  //multiplexer to Arduino analog in pin       

#define MQ2_GAS_sensor                A1     


                             // D0 = RX, D1 = TX, reserved
                                     // relays Digital output pins
#define  ALIVE_RLY_R1             4  //  D4                        Songle 10A
                                     //Split R1 & R2 into seperate groups
                                     //as songle relay coil = 90ma
                                     //each group can source 150 mA. max
                                     //group 1 ends with D4
                                     //group 2 starts with D5
#define  HP_RLY_R2                6  //  D6               CRYDOM H12D4850 50A

                                 //define Digital output pins for MUX D7 -> D11
                                 // multiplexer address select lines (A/B/C/D)
const byte mux_address_A       = 7;
const byte mux_address_B       = 8; 
const byte mux_address_C       = 9; 
const byte mux_address_D       = 10; 
const byte mux_enable          = 13;  // multiplexer enable


#define ALARM                   11  // D11 PWM OUTPUT to Audible Alarm

                        


              //analog signals into MUX, these are NOT analog pins on Arduino
                                        //These 12 have been tested good
#define SOLAR_tank_sensor            0     
#define COMP_DISCHARGE_sensor        1 

#define DSH_H2O_IN_sensor            2                        
#define DSH_H2O_OUT_sensor           3                        

#define INPUT_DEAD1           4
#define INPUT_DEAD2           5

#define IHX_HI_IN_sensor             6                        
#define IHX_HI_OUT_sensor            7 

#define IHX_LO_IN_sensor             8                        
#define IHX_LO_OUT_sensor            9 

#define SOURCE_IN_sensor            10              

#define INPUT_DEAD3          11
#define INPUT_DEAD4          12

#define SOURCE_OUT_sensor           13  

#define LOAD_IN_sensor              14                
#define LOAD_OUT_sensor             15



unsigned long T1;
unsigned long T2;
unsigned long TT;


int i;
int Sensor_Data;



void setup(void)       //Start Setup
  {
        
  pinMode (mux_analog_in, INPUT);  //MUX DATA INPUT
  pinMode (mux_address_A, OUTPUT); // multiplexer address select lines (A/B/C/D)
  pinMode (mux_address_B, OUTPUT); 
  pinMode (mux_address_C, OUTPUT); 
  pinMode (mux_address_D, OUTPUT); 
  pinMode (mux_enable,    OUTPUT); // multiplexer enable

 
  pinMode( ALARM,                       OUTPUT); //digital output to relays

  pinMode( ALIVE_RLY_R1,                OUTPUT); //digital output to relays
  pinMode( HP_RLY_R2,                   OUTPUT); //digital output to relays

  digitalWrite ( ALIVE_RLY_R1,          HIGH); //OFF
  digitalWrite ( HP_RLY_R2,             HIGH); //OFF
 
 
 // Serial.begin(9600); // start serial communication

 // delay(10000);      //time to enable monitor window
 
  
 // Serial.println(F("........Hello world!......."));
 // delay(100); 
  
  lcd.begin (16,2); //  <<----- My LCD is 16x2
  lcd.clear();
 
  //Switch on the backlight
  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
  lcd.setBacklight(HIGH);
    

  digitalWrite (ALIVE_RLY_R1,   LOW);   //ON 

  lcd.clear();
  lcd.home (); // go home
  lcd.print(F("ALIVE SIGNAL TO"));
  lcd.setCursor(0,1);
  lcd.print(F("MASTER, R1 ON"));
  delay(5000);
  // Warer pumps not started yet, so can't use custom delay 

 
  lcd.clear();
  lcd.home (); // go home
  lcd.print(F("BBP_HP_SLAVE"));
  delay(5000);
  // Warer pumps not started yet, so can't use custom delay 


  beep(50);
  beep(50);
  beep(50);
  delay(1000);

  
  lcd.clear();
  lcd.home (); // go home
  lcd.print(F("HP DELAY 20Sec"));
  lcd.setCursor(0,1);
  lcd.print(F("BEFORE STARTING"));

  for (i=0; i< 4; i++)    //delay 20 sec.
  {   
  custom_delay();     //Delay 5 sec. & Checks SRC OUT Temp & GAS
  }

 
  digitalWrite (HP_RLY_R2,          LOW);  //Power HP 
  
  lcd.clear();
  lcd.home (); // go home
  lcd.print(F("HP R2 ON"));  
  lcd.setCursor(0,1);
  lcd.print(F("END SETUP"));   
  custom_delay();     //Delay 5 sec. & Checks Water SRC OUT 
                      // FOR BEING TOO COLD, RESETS RLYS & HANGS FOREVER IF SO

  }    //end setup

Last edited by buffalobillpatrick; 09-10-14 at 05:36 PM..
buffalobillpatrick is offline   Reply With Quote
The Following User Says Thank You to buffalobillpatrick For This Useful Post:
AC_Hacker (07-28-14)
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger
Inactive Reminders By Icora Web Design