My Neptune Apex web interface compatible DIY reef controller

I already had the mega with the touchscreen controlling my lights and just use I2C to communicate the ph and temp data to it, using the wire library. But when I'm just testing the code I don't have the I2C in the code just how you got it. I change the #define EEPROMSIG 0xA0 every time I change anything. My problem is that I have 9 channel of lights over the tank and I like your interface. So basically I have two controllers on the tank. Everything work just fine as is, just wanted to use more of the outlets. I could just use one of the outlets that I don't think I will need and replace it with the heater.
But if you get a chance to see if it's just me doing something wrong with changing from 8 to 16 max outlet let me know and also when change back to 8 the page loads back up.
Thanks
 
I already had the mega with the touchscreen controlling my lights and just use I2C to communicate the ph and temp data to it, using the wire library. But when I'm just testing the code I don't have the I2C in the code just how you got it. I change the #define EEPROMSIG 0xA0 every time I change anything. My problem is that I have 9 channel of lights over the tank and I like your interface. So basically I have two controllers on the tank. Everything work just fine as is, just wanted to use more of the outlets. I could just use one of the outlets that I don't think I will need and replace it with the heater.
But if you get a chance to see if it's just me doing something wrong with changing from 8 to 16 max outlet let me know and also when change back to 8 the page loads back up.
Thanks

please email your config.h to me so I can take a look at your setup. I probably still have some other hardcoded values in the code I need to fix. I know I tested the htm file on an Apex with 24 outlets and it displayed correctly. So the problem may be in the arduino code, probably in Apex.ino.

as to using I2C, remember I changed my I2C to run 400khz. The default is 100khz. You will need to setup an I2C slave to wait for requests from your light controller if you want to set that up as I2C master. There should be plenty of example code making two arduinos communicate via I2C.

How do you like the WP25
I've only used it for a day. I like the fact that they make it easy to control.
I removed my 4 koralias and replaced it with one wp-25. Strictly speaking, I can actually get by now with just 3 outlets (return, kalk/ato, heater). I only use outlets that need to be controlled on a schedule. Things like media reactor pump that are always ON I do not use on the controller outlet.

I've already got a basic code for controlling the pwm and the frequency. next I need to come up with a method to define the patterns and the program schedule.
 
does your sketch have pwm pins for lighting? ramp up in the am and ramp down at night?
for 2 pins or maybe more. if not using wp pumps
 
Hello thanks again by putting a 9 in max outlets made the webpage come up. Also I can see that I have 9 outlets. So I guess if I add more outlets just change it to the number I'm using up to 16
 
thank you and you help!!!

other question:
1. I have 2 DIY Leds, The Leds need 5 channel PWM. and I have 2 wp40 need use 2 channel PWM. But you program use 4 timer, then I only have 9,11,12 pin. PLS tell me, what pin can I use?

2. if I need 9:00am poweron and 20:30PM poweroff, what can i set on webpage.
 
does your sketch have pwm pins for lighting? ramp up in the am and ramp down at night?
for 2 pins or maybe more. if not using wp pumps

the current wiring diagram supports 2 10v PWM. You can add your own code and do analogWrite to pins 2 and 3.
 
thank you and you help!!!

other question:
1. I have 2 DIY Leds, The Leds need 5 channel PWM. and I have 2 wp40 need use 2 channel PWM. But you program use 4 timer, then I only have 9,11,12 pin. PLS tell me, what pin can I use?

2. if I need 9:00am poweron and 20:30PM poweroff, what can i set on webpage.

With the latest code, you can use PWM on pins
2,3,5,9,11,12,44,45
if you move the temp sensor from pin 46 to any other free digital pin, you can use pin 46 for pwm as well for a total of 9 PWM pins.
in Sensors.ino, change

#define TEMPPIN 46
to the new pin number that is not a PWM pin.

That is all the usable PWM lines on the Mega. Since you cannot use pins 4, and 10 since they are used by ethernet shield, and pin 13 is used by LED.

The outlet scheduler is for turning the outlets on/off on a schedule. You must write your own routine to control the PWM lines for the LED. I am currently working on the code for WP pumps.
 
I was change code for PWM, not use loop. and add code update_leds() to ISR(TIMER4_COMPB_vect).

The PWM code like this:
Code:
static int bl = 0;

  lcd.setCursor(0,3);
  lcd.print("B:"); 
  if (bluePins[bl] < blueChannels) {
    value = SunLight(bluePins[bl],BluePWMHigh[bl],BluePWMLow[bl],BlueFull[bl],m_year,m_month,dayOfMonth,rtcHrs,rtcMins,m_second); 
    Serial.print(map(value,BluePWMLow[bl],BluePWMHigh[bl],0,100)); 
    Serial.print("% "); 
    analogWrite(bluePins[bl], value); 
    bl++;
  }else{
    bl=0;
  }

Is this code OK?

I want to add ORP&WI-FI module, and make this controller in china, are you agree?
If you disagree, I must stop it!
 
Last edited:
I was change code for PWM, not use loop. and add code update_leds() to ISR(TIMER4_COMPB_vect).

Is this code OK?

I want to add ORP&WI-FI module, and make this controller in china, are you agree?
If you disagree, I must stop it!

I don't think you can add that routine into ISR. The ISRs currently take about 100-200us time to execute. The LED functions contain a lot of floating point operations and will take a lot of time inside the ISR. Besides, you cannot call analogWrite inside an ISR, you have to write directly to timer registers. I can see a time based ramp up/ ramp down can work in ISR, but not a sunrise/sunset based function with a lot of floating point calculations.

What LED are you using? If I can get a unit to test and use, I can write a code for it.

It is possible to add ORP, Wifi etc. ORP and Conductivity/Salinity (specific gravity) probes are currently supported when using the htm with Neptune Apex controller. Arduino Wifi shield will be easier to convert. Using wifi like RN-XV wifly with serial interface will take a lot more work to convert. Do you have any low cost wifi module you plan to use?

Please email me regarding your plan with the controller.
 
I'm still thinking of the best way to hook up the jebao pump to the controller.
My controller currently use stereo jacks for connection. So for one stereo jack, I can put out 2 control lines plus ground to control two jebao pumps.

I have the option to open up the jebao controller case, and add a switched mono jack that will pass through the control signal if nothing is plugged into the jack, but will use the control line from the mono plug if plugged in.

The second option is to use a 3pin connector in series and pass through the 24v lines and use the control signal from my controller. This option does not require modifying the controller.
HTML:
jebao controller 3pin male =>  3pin female => 3pin male=>3pin female to pump
                                           ||
                                           \/
                                    to controller
or I could do away with the 3pin female side and just use a female DC jack to plug in the 24v power supply line.

I'm leaning towards option 2 with the DC jack. I can just unsolder the male connector from the controller and use that.
 
Sound good, so with option 2 how would the arduino control the different functions

The "to controller" in the diagram connects to PWM pin on arduino controller.
Once I complete the code, it will include a web interface to modify settings like select mode, cycle length, and limit max, and to select sync or anti-sync for a pair. I know a lot of people need a way to limit the max output of the jebao pumps for use in smaller tanks.
 
do we have to add a filter to make it analog

I have not tested it.
I am currently using the arduino default 490hz pwm.
If that does not work, I can try to bump up the pwm frequency.
In theory, it should work. It should not be an issue to add the RC filter if needed.
 
this build just keeps on getting better :) i am also planning to use the jebao powerheads in my upcoming build, will most likely start it in the next few weeks.
 
Is the Return outlet for the main return pump or it is for something else

main return. I only have one return pump.
The program is always on, so initial off time is 0 seconds, on time is 60*60*24 seconds, off time is 0 seconds, (on 24 hours a day).
 
I don't think you can add that routine into ISR. The ISRs currently take about 100-200us time to execute. The LED functions contain a lot of floating point operations and will take a lot of time inside the ISR. Besides, you cannot call analogWrite inside an ISR, you have to write directly to timer registers. I can see a time based ramp up/ ramp down can work in ISR, but not a sunrise/sunset based function with a lot of floating point calculations.

What LED are you using? If I can get a unit to test and use, I can write a code for it.

It is possible to add ORP, Wifi etc. ORP and Conductivity/Salinity (specific gravity) probes are currently supported when using the htm with Neptune Apex controller. Arduino Wifi shield will be easier to convert. Using wifi like RN-XV wifly with serial interface will take a lot more work to convert. Do you have any low cost wifi module you plan to use?

Please email me regarding your plan with the controller.

The LED is own Diy, have 5 channel:
1, Cree white 7000-8300K 8pcs;
2, Cree blue 465-470nm 8 pcs;
2, PHILIPS deepblue 450-455nm 8 pcs;
3, Purple 415-420nm 4 pcs;
Purple 400-410nm 4 pcs;
4, Yellow 585-595nm 2pcs;
Green 515-530nm 4pcs;
Red 655-660nm 4pcs;
Per cnannel 1 Meanwell LDD-1000H. The power is Meanwell 360W 36V.
I am using arduino 2560 pin 2,3,9,11,12 Control PWM is OK.

And how much wp25&wp40 in USA.
 
Last edited:
Back
Top