Moonlight for a Neptune Apex controlled Aquarium

garbled

Well-Known Member
View Badges
Joined
Nov 10, 2018
Messages
772
Reaction score
1,044
Rating - 0%
0   0   0

A word of warning​

This is a pretty advanced DIY. You will need basic soldering skills, and reasonably good computer skills to pull this off. You also probably have to have built your own DIY LED's to make use of this. This is by no means plug and play. But if you are up to the challenge, by all means, this works, and is pretty awesome. I provided Amazon links to the specifc parts I used, however, you can substiute most of them if you know what you are doing. The only critical part is the digital potentiometer.

The problem​


The Neptune Apex is an amazing aquarium controller, but one of the few things it's missing, is a way to provide true moonlight simulation on anything bigger than a nano-tank. Sure, you can buy the LSM (Lunar Sim Module), but that provides you with 5 tiny little LED's. On a larger tank, they wouldn't even light up the rim of the tank.

I currently have 5 5W COB LED's over my tank for moonlight, driven by a MeanWell driver.

20181124_111142.jpg


MeanWell drivers are great, because they provide what is called 3-in-1 dimming. You can dim them with either 0-10V, 0-10V PWM, or 0-100K Ohm resistance. For an Apex, they are ideal, because you can hook them directly to a VDM port, and dim them up and down as needed with no magic whatsoever.

The problem though, is the Apex has only partial moonlight simulation. It has a lunar table, which calculates what time the moonrise/moonset is on a given day. With this, you can setup your moonlights to come on at the correct time of day and period. However, it has no way to set the intensity of the moonlight. You can't say "on the full moon run at 100%, and on waxing crescent run at 45%". You can just turn them on or off.

What you need, is some kind of external control, that says, "today the moon is 40% of bright, so set the lights to 40%". Enter the ESP8266.

20201227_111954


With this little microcontroller, an LED moonlight driven by a MeanWell driver, a free outlet on your EB8/EB832 for the driver power, and a few other parts, you can now have real moonlight on your aquarium.

How it works​

The ESP8266 will connect to NTP to get the current date and time. From this, it will calculate the current lunar phase, and illumination level.

Once it has these, it will poll your Apex every 3 minutes for a VDM port you have configured with a ramp profile. This tells it the desired illumination. You setup your Apex with a few programs and profiles so it ramps the moonlight up from 0% to 100% over an hour or so, then runs at 100% for the majority of the moontime, then ramps back down from 100% to 0% to simulate moonset. Finally, your Apex will control the outlet that the driver is plugged into to turn it fully on or off.

So an example. Lets say it's now 30 minutes into moonrise, and the moon is 50% of full. Your ramp profile should currently have the VDM output at about 50%. The ESP has calculated the moon, and says that it is 50%. It then multiplies these two values, and sets the internal potentiometer to 25k Ohms, and your driver runs at 25%.

Parts list​

  1. Wemos D1 Mini -
  2. 128x64 OLED Display (i2c) -
  3. Stripboard -
  4. DFRobot Digital potentiometer 100k - https://www.dfrobot.com/product-1650.html
  5. 2 Position Screw terminal -
  6. Micro USB cable and wall wart, any will do.

You will need some basic soldering tools, little bits of wire, and a multimeter helps to test things, and a PC with the arduino IDE installed. https://www.arduino.cc/en/software

You will also need a Neptune Apex, a VDM module (an external one, not the one builtin to the unit), and an LED moonlight with MeanWell driver (with 3-in-1 dimming).

How to build​

Schematic_ESPLunarSim_2020-12-16_04-52-20.png


https://cdn.hackaday.io/images/3380191608129656184.png


Take the perfboard, and on the side with the copper traces, use a knife or saw, and cut the traces down the middle of the board. You just need to break the strip-lines so the right half doesn't connect to the left half anymore. Use a multimeter to verify the traces are broken all the way down the board.

Use the headers supplied with the ESP and the digital pot to mount them to the board, so they straddle the cut line, with leads on either side. Make sure the ESP is mounted on the edge of the board, so the USB connector sticks out the back and you can power it up easily.

Follow the schematic to wire all the little connections to one another. It's actually pretty simple:
  1. 3v3 on the ESP goes to the OLED VCC and VCC on the digital pot.
  2. GND on the ESP goes to the OLED GND and GND on the digital pot.
  3. D1 on the ESP goes to SCL on the OLED.
  4. D2 on the ESP goes to SDA on the OLED.
  5. D5 on the ESP goes to SCK on the digital pot.
  6. D6 on the ESP goes to SO on the digital pot.
  7. D7 on the ESP goes to SI on the digital pot.
  8. D8 on the ESP goes to CS on the digital pot.
  9. PB0 on the digital pot goes to one of the pins of the wire terminal (doesn't matter which).
  10. PW0 on the digital pot goes to the other pin of the wire terminal.
You should probably double check your connections with the multimeter once it's all wired up. Just make sure your solder joints are all good and each connection goes where you think it does, and not somewhere else.

Now install the arduino IDE on your PC. You will also need to install the support for the ESP8266. These instructions will help: https://randomnerdtutorials.com/how-to-install-esp8266-board-arduino-ide/

You will need to go to the library manager of the arduino IDE, and install some libraries (Tools -> Manage Libraries):
If you can't find some of these in the library manager, simply download them from github into directories in your "libraries" directory of your arduino install.

Then download the code for the lunar simulator from my github: https://github.com/garbled1/ESP_Apex_LunarSim

You just need the .ino file.

Connect the ESP8266 to a USB port of your computer, start the IDE, open the .ino file, and go down to line 23 in the code. Change the APEX_HOST to the hostname or IP of your Apex on your local network. Also, change the NTP_SERVER on line 24 to another ntp server, like 0.debian.pool.ntp.org

Click verify to make sure everything compiles, and once it does, you can click upload to upload the code to your ESP. You can watch on the serial monitor to make sure everything is working correctly.

You should see it print the words "Initializing" on the display, and then switch to the normal display, which shows the current date and time, and the lunar phase and illumination.

Now you need to program the Apex.

Programming your Apex​

A full set of profiles and outlet programming is available here: https://github.com/garbled1/ESP_Apex_LunarSim/blob/main/ApexProgram.md

Basically you need to do the following:
  1. Plug your MeanWell into an EB8/EB832 outlet, and program it to turn on and off with the If Moon statement.
  2. Build 3 ramp profiles, MoonRise, MoonSet, MoonOn, to ramp up/down the moon and set it to 100%.
  3. Build 3 virtual outlets, to control when the moonrise/set/on run.
  4. You need an UNUSED port on the VDM. Luckily, the VDM has a serial port, which most people do not use. You can use one of these, and still have the 4 normal VDM ports available for your use. I picked the BLU one from the serial. Program this with your ramp profiles.

Setting up the ESP​

Once the ESP is powered up, it will need information to setup your WiFi. Luckily, it creates a simple access point for you. You can scan for WiFi connections with your phone, and find the ESP on your available connections. If you connect to it, it will display a simple little web page where you can configure it with your router and SSID details, as well as set some of the settings. Once you do so, it will disconnect from your phone, and connect to your local network.

Once it's up on your local network, you can enter it's IP into your browser to get a simple web page that shows the current moonlight, and lets you modify a few settings. There is also a link to an info page that gives more details about what is going on behind the scenes.

1609160472441.png

The settings you care about are:
  • Apex hostname or IP: The hostname or IP address of your apex on the local network.
  • Max illumination: A number between 0.0 and 1.0. If you want your moonlights to never run above say, 50% of full power, you could enter 0.5 here, and it will scale the calculations between 0-50% of the driver's maximum power.
  • Minimum Pot Res: The minimum potentiometer resistance in kOhms. It defaults to 5, which is 5% of driver power. You can set this to whatever, and it is the lowest value the system will set for moonlight.
  • Apex Moon Device: Case sensitive, the name of the VDM port you chose when setting up the Apex.
  • Apex Poll in seconds: How often to check the Apex for updated data from the VDM port.
Finally, at the bottom of the info page, there are also instructions to upload new code to the device. If you want to make changes to the code, or fiddle with it, you can upload new code to it with the /update URL, without having to hook your PC up to it directly.

Final connections​

Plug the ESP into a USB wall-wart with a micro-USB cable. Attach the two dimmer lines from the MeanWell into the terminal block on your circuit. It doesn't matter which wire goes where. At this point, everything should be working!

20201227_111939


I made a little 3d-printed box for mine (which is just barely adequate, but, eh) and assembled it with some M2.5 screws I had lying about. It's not the perfect box, but you can download the STL from my github page.

And with this, let there be moonlight!

References​

 
Last edited by a moderator:

Josh@BVA

Active Member
View Badges
Joined
Jan 5, 2017
Messages
152
Reaction score
271
Location
West Springfield MA
Rating - 0%
0   0   0
seems like a whole lot of work and knowledge needed just to get Moonlighting. is having the moon light really that neccisary or do u find it to just be a fun kool looking addition. I feel like if you alrdy have these skills then yea why not but to invest time and money into this build and just get some night time mood lighting out of it doesnt make sense to me. to each their own tho. well written instructions btw
 
OP
OP
garbled

garbled

Well-Known Member
View Badges
Joined
Nov 10, 2018
Messages
772
Reaction score
1,044
Rating - 0%
0   0   0
You absolutely don't need moonlight to grow healthy corals. However, if you want to push the envelope a bit, and experiment with things, it's one of the areas that has alot of potential. For example, if you want your corals to spawn (most people do NOT want this), you want accurate moonlight. Many fish alter breeding and other behaviors, or are at least believed to, by phases of the moon and lunar cycles.

Personally, I want to emulate the natural environment as close as I can. For me personally, part of the hobby is experimenting with different care techniques and learning what I can, and doing a bit of DIY.

I'm personally interested in seeing what effect this has on my fish and corals. Will the fish act differently? Who knows? If not, it was fun to build.
 

Josh@BVA

Active Member
View Badges
Joined
Jan 5, 2017
Messages
152
Reaction score
271
Location
West Springfield MA
Rating - 0%
0   0   0
You absolutely don't need moonlight to grow healthy corals. However, if you want to push the envelope a bit, and experiment with things, it's one of the areas that has alot of potential. For example, if you want your corals to spawn (most people do NOT want this), you want accurate moonlight. Many fish alter breeding and other behaviors, or are at least believed to, by phases of the moon and lunar cycles.

Personally, I want to emulate the natural environment as close as I can. For me personally, part of the hobby is experimenting with different care techniques and learning what I can, and doing a bit of DIY.

I'm personally interested in seeing what effect this has on my fish and corals. Will the fish act differently? Who knows? If not, it was fun to build.
this explains a lot thanks. i totally get spawning requirements of moonlight I guess ive personally just never been that ambitious to try it and def never thought of going thru these lengths to achieve the goal. I love the feedback tho thank you
 

Justin Aretz

Active Member
View Badges
Joined
Apr 29, 2019
Messages
114
Reaction score
123
Rating - 0%
0   0   0
I’m not sure there is hard scientific evidence that moonlight promotes health. All it’s done for me is promote spawning, which was a disaster when I had 100s of stylos growing in every nook and cranny of my rock work. Was nice when my shrimp and fish were spawning regularly as it was a nice treat for all vertebrate critters. I no longer run moonlight.

This being said, very interesting project and sounds like you’ve had a desirable outcome. Congrats
 

GregOyeah

Well-Known Member
View Badges
Joined
Feb 6, 2017
Messages
586
Reaction score
685
Rating - 0%
0   0   0
Looks like a fun and interesting project for any hardcore DIYer. Very cool and great job explaining. While I don’t have a ton of interest in moonlights for my tank, I have this saved and plan on trying it out when I have some free time, seems like fun
 
OP
OP
garbled

garbled

Well-Known Member
View Badges
Joined
Nov 10, 2018
Messages
772
Reaction score
1,044
Rating - 0%
0   0   0
One thing worth noting if you are familiar enough with Arduino code to hack up the code:
I'm using the Apex local API to pull the current value of the VDM output from the Apex to adjust the lighting. It wouldn't be super difficult to hack this up, and control something other than a digital potentiometer with it. For example, you could use a relay instead and control a vent fan in the room or something based on some number from the Apex. Or since the ESP8266 has wifi, you could use it to talk to the API on some other device, like a WiFi light controller/dosing pump/etc that doesn't have Apex integration, and basically make your own DIY Apex bridge.

If someone wants to attempt this, I'd be more than glad to help hack up the code.

I might also throw together a different DIY for a humidity sensor that closes the contact on an IO port from a breakout box, since nobody sells those anymore that I can find. That one would be *way* more simple.
 

MnFish1

10K Club member
View Badges
Joined
Dec 28, 2016
Messages
22,778
Reaction score
21,928
Rating - 100%
1   0   0
I thought it was a well written article and interesting. That said - (this is a question not a criticism) - if you bought a light with moonlight settings - wouldn't it be much easier to just not run it through the apex? I.e. I'm all for the moonlight part - I'm just not sure its worth it just to go through the Apex (note part of that is that for me the lighting options with the apex are for lower standard than just using whatever controller/software came in the box with the light (Radions, for example or AI).
 
OP
OP
garbled

garbled

Well-Known Member
View Badges
Joined
Nov 10, 2018
Messages
772
Reaction score
1,044
Rating - 0%
0   0   0
Well it depends on what you want from moonlight. There are a few types of moonlight:

1) I want a nightlight for the aquarium
2) I want a nightlight for the aquarium that gradually ramps up and down over the course of a "month"
3) I want it to perfectly(well, as close as possible) mimic the moon

For 1, that's easy, reverse schedule, don't need this.

For 2, thats slightly harder, you can't pull off a schedule in Apex that spans a month, you can however do a weekly schedule, and with some really fancy programming reverse it on the next week. My solution could do this, if you simply do reverse schedule and don't use If Moon.

For 3, You want either the neptune LSM, or this, or something else that can do it. The Apex has a lunar schedule builtin that correctly sets the moonrise and moonset each day. Like today moonrise is say 16:00, and tomorrow it's 16:45 or whatever. The moon doesn't always rise at 8pm or whatever, it shifts over the month, so sometimes it's up in the middle of the day. That's what the "If Moon" programming statement does, it's like the If Sun, when you use the sunrise schedule (which changes the photoperiod according to the seasonal chart), but instead changes the lunar photoperiod according to the lunar chart. What it doesn't give you, is the phase, which is what my "module" hacks in. It sets the illumination % to match. So with mine, you can do: "Today the moonrise is at 16:00, and the phase is 50%, so gradually ramp up from 0-50% over the course of an hour, run until 1 hour before moonset, then ramp down for an hour and shut off."

So back to your question, my answer is, if the builtin on the light you own, like a radion or AI does the type of moonlight you want, then absolutely use that. I don't know if radions have the lunar rise/set schedules builtin, but if they do, yeah, don't do it my way, my way is hard. I think most vendors however implement option 2, not 3. In my specific case, I'm using DIY lights, so there is no vendor option at all. I want to mimic as close as possible the real moon, and this solution gives me that. If that's builtin to an AI, then yeah, use that if you've got one.

Also note that a lunar month is like 29.5 some odd days, so, again, if you are trying to perfectly mimic, then does the solution you are using do so? I dunno. I also don't know that it actually matters at all. I do not claim an actual benefit to this, it's just something I want. I have no idea if a fish or coral will notice that your lunar period is a month instead of 29.5 days, I suspect not.
 

MnFish1

10K Club member
View Badges
Joined
Dec 28, 2016
Messages
22,778
Reaction score
21,928
Rating - 100%
1   0   0
Well it depends on what you want from moonlight. There are a few types of moonlight:

1) I want a nightlight for the aquarium
2) I want a nightlight for the aquarium that gradually ramps up and down over the course of a "month"
3) I want it to perfectly(well, as close as possible) mimic the moon

For 1, that's easy, reverse schedule, don't need this.

For 2, thats slightly harder, you can't pull off a schedule in Apex that spans a month, you can however do a weekly schedule, and with some really fancy programming reverse it on the next week. My solution could do this, if you simply do reverse schedule and don't use If Moon.

For 3, You want either the neptune LSM, or this, or something else that can do it. The Apex has a lunar schedule builtin that correctly sets the moonrise and moonset each day. Like today moonrise is say 16:00, and tomorrow it's 16:45 or whatever. The moon doesn't always rise at 8pm or whatever, it shifts over the month, so sometimes it's up in the middle of the day. That's what the "If Moon" programming statement does, it's like the If Sun, when you use the sunrise schedule (which changes the photoperiod according to the seasonal chart), but instead changes the lunar photoperiod according to the lunar chart. What it doesn't give you, is the phase, which is what my "module" hacks in. It sets the illumination % to match. So with mine, you can do: "Today the moonrise is at 16:00, and the phase is 50%, so gradually ramp up from 0-50% over the course of an hour, run until 1 hour before moonset, then ramp down for an hour and shut off."

So back to your question, my answer is, if the builtin on the light you own, like a radion or AI does the type of moonlight you want, then absolutely use that. I don't know if radions have the lunar rise/set schedules builtin, but if they do, yeah, don't do it my way, my way is hard. I think most vendors however implement option 2, not 3. In my specific case, I'm using DIY lights, so there is no vendor option at all. I want to mimic as close as possible the real moon, and this solution gives me that. If that's builtin to an AI, then yeah, use that if you've got one.

Also note that a lunar month is like 29.5 some odd days, so, again, if you are trying to perfectly mimic, then does the solution you are using do so? I dunno. I also don't know that it actually matters at all. I do not claim an actual benefit to this, it's just something I want. I have no idea if a fish or coral will notice that your lunar period is a month instead of 29.5 days, I suspect not.
With radions - you can 'set' the start and end of 'night' - but after that the brightness follows the lunar calendar. For example - I start my 'day' at noon and end at '9PM' - after that - between whenever the moon is 'up' the program automatically programs the lunar cycle. "**Moonlights will be dimmed according to the current lunar schedule. and will only achieve your programmed maximum brightness during a full moon**"
 
OP
OP
garbled

garbled

Well-Known Member
View Badges
Joined
Nov 10, 2018
Messages
772
Reaction score
1,044
Rating - 0%
0   0   0
It sounds like they implement method 2, more or less. If you didn't care about the ramp up and down at the start/end of the night, you could probably set the start and end of the night to be 24 hours, and then maybe control the on/off of the channel with If Moon, assuming there is a way to connect to that channel on the radion to switch it on/off.. But I assume they don't have an extra cord for that. Yeah, if #2 is all you want, the Radion builtin is probably the way to go. I'm not even sure you could wire my circuit into a radion sanely.

Basically my DIY is meant for method 3, and 2 if you are running DIY lights or something similar. You could possibly make it work with some kind of WiFi controllable light, assuming there is an API of any kind where you could feed it numbers to control the channel.

Although, re-reading your statement "between whenever the moon is up" might mean method 3? Not sure..
 

MnFish1

10K Club member
View Badges
Joined
Dec 28, 2016
Messages
22,778
Reaction score
21,928
Rating - 100%
1   0   0
It sounds like they implement method 2, more or less. If you didn't care about the ramp up and down at the start/end of the night, you could probably set the start and end of the night to be 24 hours, and then maybe control the on/off of the channel with If Moon, assuming there is a way to connect to that channel on the radion to switch it on/off.. But I assume they don't have an extra cord for that. Yeah, if #2 is all you want, the Radion builtin is probably the way to go. I'm not even sure you could wire my circuit into a radion sanely.

Basically my DIY is meant for method 3, and 2 if you are running DIY lights or something similar. You could possibly make it work with some kind of WiFi controllable light, assuming there is an API of any kind where you could feed it numbers to control the channel.

Although, re-reading your statement "between whenever the moon is up" might mean method 3? Not sure..
My impression is that it ramps up to what ever the moon is supposed to be - and then ramps down (rather than flipping on and off) - On my tank - it changes over the course of the night (not that I have watched it all night lol) - in any case - not trying to derail the thread.
 

Caring for your picky eaters: What do you feed your finicky fish?

  • Live foods

    Votes: 19 30.2%
  • Frozen meaty foods

    Votes: 52 82.5%
  • Soft pellets

    Votes: 10 15.9%
  • Masstick (or comparable)

    Votes: 7 11.1%
  • Other

    Votes: 3 4.8%
Back
Top