Basic / Standard Reef Angel hardware
			
		
		
			
				
																			
								clw143 							 
									
		Posts:  116 		Joined:  Fri Jun 21, 2013 8:20 pm 		
		
											Location:  Louisiana 
							
						
		 
		
						
					
													
							
						
									
						Post 
					 
								by clw143   »  Sun Jan 24, 2021 11:07 pm 
			
			
			
			
			Anyone shine some light on why this does not work?
Code: Select all 
long SetTime;
long RiseTime;   
//Fuge Light on 1 hour before sunset and off 1 hour after sunrise
if (now()>(SetTime - 3600) || now()<(RiseTime + 3600)) ReefAngel.Relay.On(Port6);
else ReefAngel.Relay.Off(Port6);
SetTime = (InternalMemory.StdLightsOnHour_read() * 60 * 60) + (InternalMemory.StdLightsOnMinute_read() * 60);
RiseTime = (InternalMemory.StdLightsOffHour_read() * 60 * 60) + (InternalMemory.StdLightsOffMinute_read() * 60); 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								Piper 							 
									
		Posts:  303 		Joined:  Fri Jul 20, 2012 7:13 am 		
		
											Location:  Oakley, CA 
							
						
		 
		
						
					
													
							
						
									
						Post 
					 
								by Piper   »  Mon Jan 25, 2021 8:23 am 
			
			
			
			
			Try using hour() instead of now().
Code: Select all 
    //Fuge Light on 1 hour before sunset and off 1 hour after sunrise
    if (hour() >= (InternalMemory.StdLightsOnHour_read() - 1) && hour() <= (InternalMemory.StdLightsOffHour_read() + 1)) {
        ReefAngel.Relay.On(Port6);
    } else {
        ReefAngel.Relay.Off(Port6);
    }
This compiles but I have not tested it.
 
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								clw143 							 
									
		Posts:  116 		Joined:  Fri Jun 21, 2013 8:20 pm 		
		
											Location:  Louisiana 
							
						
		 
		
						
					
													
							
						
									
						Post 
					 
								by clw143   »  Mon Jan 25, 2021 9:50 pm 
			
			
			
			
			Yeah that is a possibility, but I'm not understanding why what I am trying to do is not working.
			
			
									
						
										
						 
		 
				
		
		 
	 
				
		
		
			
				
																			
								binder 							 
									
		Posts:  2865 		Joined:  Fri Mar 18, 2011 6:20 pm 		
		
																Location:  Illinois 
							
							
				Contact: 
				
			 
				
		 
		
						
					
													
							
						
									
						Post 
					 
								by binder   »  Tue Jan 26, 2021 6:54 am 
			
			
			
			
			Looking at your code, you are not initializing SetTime and RiseTime before you try to use them. You have:
Then, the next statement you are trying to use those variables in an IF statement. The values stored in them are "undefined" or whatever else the system decided to put in them when initializing. You need to move the initializing code segment before you use the variables.
Code: Select all 
long SetTime = (InternalMemory.StdLightsOnHour_read() * 60 * 60) + (InternalMemory.StdLightsOnMinute_read() * 60);
long RiseTime = (InternalMemory.StdLightsOffHour_read() * 60 * 60) + (InternalMemory.StdLightsOffMinute_read() * 60);
//Fuge Light on 1 hour before sunset and off 1 hour after sunrise
if (now()>(SetTime - 3600) || now()<(RiseTime + 3600)) ReefAngel.Relay.On(Port6);
else ReefAngel.Relay.Off(Port6);
This should work now.