Jump to content
Cultivated Reef

Easy, no-solder ReefPi setup - temperature monitoring and power strip control


WaterBoxer

Recommended Posts

In the spirit of nano-reno, I've decided to use what I had laying around along with some budget parts to put together an easy ReefPi controller for my 20g high office nano. This ReefPi controller will be built with a cheap temperature sensor off of Amazon, a raspberry pi 2 board that I got for free a few years back, and a Kasa HS300 smart power strip. All of this will allow me to control my one remaining non-smart light, powerheads, HOB filter/skimmer and heaters. For now it'll just act as an emergency cutoff and alert system for my heaters and I'll set up some custom macros for things like feeding and maintenance, but I can easily add on a PH probe board/sensor or some dosing pumps later with the space I have in the large project box I'm using. I'll be controlling and monitoring the ReefPi from an old Nexus 7 tablet that I had laying about as well.

 

At the base of this setup is the pi 2 b v1.1 board. I got this for free from an old job along with a few others that I still have sitting on my desk ready to be used. My old job was getting rid of them because they were either incompatible with some new system or had other issues that wouldn't affect an embedded build like this (an HDMI port broken on one and another that has a broken charging port, but that I could still power over 5v pin). This board does NOT have WiFi, but since this build is currently in my office I can just connect it via Ethernet to my old router that's acting as a switch/WiFi bridge right now. The board itself will be powered by a USB charging port on the Kasa power strip.

 

The DS18B20 temperature sensors I got ($10 for a 2 pack) include a 1 meter cable, a tiny board with an included 4.7k pull-up resistor and screw terminals for attaching the sensor cable wires, and cables for connecting said board to my pi 2. Unfortunately, the sensors themselves are stainless steel and I worry about them rusting with saltwater. My solution was to use some black marine heat shrink tubing around the sensor and crimp the end shut by covering it in parchment paper and pressing it with a hair straightener. Once the heat shrink tube was nice and soft, I pressed and held it together for a few minutes further with some gloves on and the paper still around it. I cut off the very top at the end to make it look a little bit neater and it's now ready to be put into saltwater! I think it came out pretty nice considering I don't have a heat gun and had to heat the shrink tubing with a hair dryer:

PXL_20221023_002303667.thumb.jpg.758cb05651fef5944996eaf0a590e965.jpg

 

Next up is my enclosure. You can really use whatever, but I do recommend using something so your boards are at least somewhat protected from water. I went with a fairly large (200mm x 120mm x 75mm) waterproof (until my modifications, that is) project box. This box gives me plenty of room down the line to add a PH probe, proper panel mount connectors, and even a couple dosing pumps if I want, but for now it just holds the pi and temp sensor board. I drilled one hole in the side and threw everything into the box. To keep the hole as small as possible, I ran some cat5e cable I had through the hole after the micro-usb cable and terminated the cable with an RJ45 connector before plugging it into the pi. I then wrapped all the cords together several times with electrical tape. This will hopefully help keep any of the cables from accidentally getting pulled out of the hole in the side of the box.

 

PXL_20221022_194028027.thumb.jpg.c355eb61e087b7b148d54afeb557628b.jpg

 

PXL_20221022_234749365.thumb.jpg.60b3950ae9fdb838c1990a251c351df7.jpg

 

As you can see above, I'm using a USB drive on my pi. This is actually where my OS is installed and running from instead of the microSD card. I can't seem to find most of my SD cards, but I did have plenty of flash drives and with them was an old 4GB microSD. Since this pi board version can't just run off of USB like the new ones can, I have to first get a boot partition onto the microSD and then edit the PARTUUID in /boot/cmdline.txt to match that of the USB drive's root partition instead of the microSD's.

 

The easiest way to do this is usually to use the Raspberry pi imager to write Raspbian to both the microSD card and USB drive, then edit the SD card's /boot/cmdline.txt. Unfortunately, the SD card I happened to have handy is too small for a full Raspbian install. Instead, I have to use Raspbian Lite for the SD card. A quick imaging, pop the SD card into the pi, and power on to finish the install. No graphical interface with Raspbian lite, but since the pi won't actually be booting up into this OS after this, that won't matter. Time to turn the pi back off.

 

I removed the SD card and edited the boot file, then popped it back into the pi to reboot again. This time it boots to the USB drive and we get to finish the install of the full Raspbian OS, with GUI! For these next steps, I had the pi plugged into my computer monitor and controlled it using an old Logitech wireless keyboard/mousepad with USB dongle.

 

I made sure my pi was up to date on all software updates, set my hostname to 'nanoreef', rebooted, installed ReefPi, and then rebooted again for good measure. A quick check to make sure I could navigate to the ReefPi interface at https://nanoreef.local from my phone and computer and I know we're good with the install. Set system to sync time with the internet, enabled 1-wire in raspi-config for the temperature sensor to work, and then disabled SPI to free up some more GPIO pins if I ever need them. After that we're all done and the system can be controlled from the ReefPi web interface from here on out. I did also enable SSH in case I ever need to get into the pi 2's OS again, but for the most part that shouldn't be necessary.

 

That's all for tonight! Tomorrow, I'll be mounting the project box under my tank, setting up the Kasa power strip, and setting up the ReefPi software to start monitoring temperature and controlling all my equipment that'll be plugged into the Kasa HS300.

  • Like 4
Link to comment

Ran into some issues today after mounting the Reef-Pi project box under my tank.

 

First problem was when I tried to connect to the web interface again; no good. Tried to ping the pi from my computer and still no connection. Uh oh!

 

After trying to re-terminate the ends of my Ethernet cable, I gave up on it and determined that it must've been damaged at some point. It was pretty kinked and tangled when I pulled it out of the storage tote it was in, so I grabbed another that I knew worked. Clipped off one end, fed it into the project box in place of the other, and slapped an RJ45 on the end. Rebooted the pi and I confirmed that I could connect to it again before proceeding.

 

Now it was time to test the temperature sensor before I re-taped the wires and closed up the box again. From within the Reef-Pi web interface, I went to Temperatures and tried to set up my sensor, but it was missing! *sigh*

 

I SSH'd into the pi using PuTTY (see, it's already coming in handy!) and double-checked my settings in raspi-config. Everything looked good, so I continued troubleshooting. After trying to manually add the 1-wire modules to /etc/modules, swapping out the sensor and board, and checking my connections again, I finally had an 'Aha!' moment.

 

When I turned on 1-wire support in raspi-config before, it changed/added a line in /boot/config.txt. The problem is, it changed /boot/config.txt on the flash drive, not the SD card. A quick edit to the config file on the SD card to enable 1-wire and I rebooted the pi. Success! Temp sensor now shows up.

 

With the temp sensor set up, I'm going to let it monitor temps for a few days before I give it control of my heaters. Next up is the Kasa power strip.

 

I already set the Kasa's IP address from within my router's settings, so I added the hs300 driver and pointed it at the IP I chose. After that, it was simply a matter of adding the Kasa's outlets one by one under Equipment.

 

Since everything was working now, I finished mounting the Kasa power strip under the tank and closed up my project box. Cords are still a bit messy, but I can clean that up later:

PXL_20221023_220655700.thumb.jpg.af24cb011b53555d4749b0c749fa9dd8.jpg

 

PXL_20221023_220807464.thumb.jpg.22a1945ebaf50136789bc7069c0b1bd1.jpg

 

Finally, I set up a couple macros for feeding. While I can control individual outlets from the main dashboard, I also want some macros that will turn off certain equipment for me and then turn them back on automatically after a set time so I don't have to remember to. At this point my fish had been watching me struggle for a couple hours and were getting pretty feisty, so I decided to test out one of the macros. I clicked run and my powerheads and skimmer turned off. Fed the fish and a few minutes later powerheads came back on. I checked back a while later and the skimmer had also come back on as planned.

Screenshot_20221023-182606.thumb.png.81b8ba60a817133c5b0bc3e5f83d5b31.png

Screenshot_20221023-185430.thumb.png.e8a23fa8196ae726055b69aa58d01e09.pngScreenshot_20221023-185440.thumb.png.0cac84444155e1a2e03c4c8915896c8e.png

 

I'm sure I'll mess with the macro timing as I continue, but for now my test worked! With everything up and running, all I have left to do is set up some email alerts and configure the Reef-Pi to shut off my heaters once I'm comfortable with how it's running and monitoring my temps. Both of those will have to wait for another day, though, since I still need to do my water change and I also have to get to bed early to drop off my wife at the airport in the morning.

  • Like 2
Link to comment

Cool project, thanks for posting. Got me inspired to go ahead and set one up just for temp alerts to start off with as I have a couple Pi's sitting around. I've had a dead heater all but kill a tank once before so love just knowing that the temp is OK. Might add actual controls later.

 

Thanks 

  • Like 1
Link to comment
7 hours ago, The Rainy Day Aquarium said:

They are all but impossible to get now days! 😂 

You can try rpilocator and follow them for alerts, but I agree that it's really a pain to get them nowadays.

 

It looks like you might be able to snag a Zero WH kit for a decent price from the leviathan website. The leviathan board is also a good option for those looking for easier builds that want something a little more diy than robo-tank.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recommended Discussions

×
×
  • Create New...