Surfbox Server - DIY Controller Software

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0


Hello everyone! I'm back at it again with another attempt to build something useful for the reefing community. Unfortunately my last "Surfbox" project which was a pure Arduino and Web-server type aquarium monitoring device was damaged severely upon moving to my new home last year! I took it as a blessing in disguise because I really do not think that it was applicable or relevant for most people here to replicate without extreme knowledge of computer science. About 6 months ago I hit the drawing board to build myself a personal new aquarium controller to replace my broken one and while I was doing so I happened to be working on a sophisticated SocketServer library for Java 8. Then I had it, a magnificent idea! Let's build the entire platform for the controller in JDK8 using my new SocketServer libray (Grab) this way the controller can be light and simple, all it has to do is send some simple data to the server and then the server will tell the device what to do. Then I had another grand idea! This server is in JDK8 which can be run on multiple platforms so why not just package it up in a simple way that everyone can configure it to exactly how they want it to build their own lightweight aquarium controllers.

What is SurfBox?

SurfBox is a back-end server platform that makes DIY aquarium controller-type projects much simpler!

When we think of a modern aquarium controller there are three key elements:

(1) The physical device
(2) Software that drives the device (Memory, messages, SMS alerts, conditional device control, etc)
(3) Either a Web, Phone, or Desktop application (Graphs, live data, manually turning devices on and off, etc)

With the SurfBox system you eliminate two of the three elements cutting 66% of the work out, leaving the only chore for you to do is download, configure, and get creative with your physical device! (Which you can find plenty of pre-made example on SurfBox's official website (coming soon))

I am not tech savvy! This seems too hard!

Don't knock it until you try it, this project is becoming increasingly easier for those who are not tech savvy at all to use. Simplicity is always taken into consideration every step of the way when creating new updates. Within a few minutes anyone can be streaming live data right from their aquarium to their home computer, just follow the guides carefully!

Features

  • Configuration manager makes it simple to edit files that normally would have to be done manually
  • Runs on Mac, Linux, Windows, Chrome OS, or Raspberry-pi
  • Command prompt/Terminal based program! No messy confusing windows.
  • Streams data live to API (JSON) for use with Smart home technology, Website, Desktop, and Phone applications
  • Compatible with virtually every probe, sensor, and relay boards
  • Connect to your server with virtually any platform that supports internet connection (Arduino, Raspberry-pi, etc.)
  • Virtually unlimited amount of probes/devices support
  • Advanced multithreaded timers
Download (with source files): http://www.github.com/andrewalexgit/SurfBox

DEMO WEB APP:

Screen Shot 2019-01-03 at 12.39.27 PM.png
 
Last edited:

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Looks very interesting. Do you have any screenshots of the UI or a list of features supported currently ?
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
It's meant to be ran in a shell it is a terminal based program, I might make a JavaFX GUI for it in the future but for now this works really well.

As of right now it has the ability to create a complex profile for each probes parameter; maximum, minimum, tolerance, target, and unit of measure. Each profile also has the ability to check itself and send back a calculated response. There is a module for controlling devices implemented as well but I haven't updated the CommandHandler yet.

Heres a screenshot of the program in action working with a simple temperature monitoring device, I booted it in the configuration mode to show how to change the amount of temp probes. I also purposely disconnected the device to show how the server remains idle as it waits for a reconnect to ensure that data isn't lost and resumes right back where it was.

Screen Shot 2018-12-17 at 1.28.26 AM.png


I will be uploading a short video on how to use the SBS with devices sometime tomorrow hopefully.
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
So I started working on a video describing how the server works, but I thought it would be best to push it off a few more days until I finished the device control. I will not leave anyone following the project empty handed tonight! I managed to make a semi-major update to the software by finishing the device abstract and created the first device included in the software package which is an "Outlet" control.

To use outlet controls go ahead and download the newest version of SBS from github (Version 3.1.0) and immediately start it up in configuration mode. After that you can use the 'update' command to change the number of 'outlets' in the configuration properties file. Once you have that done and all the other settings to your liking just use the 'exit' command to save and reboot the server in regular mode. You should notice after probes are done being setup a second setup happens for your devices.

Screen Shot 2018-12-17 at 8.56.53 PM.png
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
I figured it would be useful to make a quick list of packets that a client can send to request data from the server, I'll be making a section in the README on github for this as well.

To enter the command line for probes begin the packet with the letter 'p' followed by the address number of the probe.

newr [value] -> Stores new value into memory for specified probe, it creates a new key as well with a datetime stamp for that value.

getr -> Returns most recent value stored in memory for specified probe

pchk -> Returns a parameter check using the set tolerance, max, min, and target for specified probe

EXAMPLE1: p 1 newr 78.4 -> Probe at address one store a new value into memory of 78.4
EXAMPLE2: p 1 getr -> Returns value of 78.4

To enter the command line for devices begin the packet with the letter 'd' followed by the address number of the device.

switchon -> Sets device status to boolean true

switchoff -> Sets device status to boolean false

getd -> Gets the boolean status of the device

EXAMPLE1: d 1 switchon -> Sets device number 1 to boolean true for ON
EXAMPLE2: d 1 getd -> Returns boolean true to indicate that the device is ON

By sending the server the message kill the server will shut down.
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Now that devices and probes are both integrated into the software I need to tie them both together, but I'm running into a big problem. The configuration file is too primitive to associate devices with probe objects and other objects like timers and whatnot. I have an idea to fix this issue but it involves rewriting the entire probe and device initialization chunk and an overhaul of the configuration manager. So hopefully sometime this week I will have switched the configuration files over to a single JSON API in which case I could just add a bit of extra code and have the software update the API live with probe readings and whatnot making it both a configuration for the server and a useful live API
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Just finished and tested the new configuration manager, now all that is left to do is to integrate it into the probe and device initialization sequence and create a new configuration object to use to manipulate the data while the server is running, and finally create some demo web templates to use.
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Finally finished the BETA Test version of 3.6.0 which is what I plan on being the official first stable release for the software! You can download the project from my github and get started on your next DIY aquarium controller project!

NEW FEATURES ADDED

1) The biggest feature of all Live API for your aquarium! thats right, I spent long hours rewriting just about every corner of the already running application to switch from pure data structures and .properties files to a completely live JSON API! Every-time a new reading is stored into memory or a device is toggled on and off you can find it is constantly being refreshed in the config/data.json file. This means everyone can get involved in creating CUSTOM web-templates, the API also stores all configuration data for your probes and devices so you can play around with those values in the objects as well!

2) SurfboxConfigurationManager has been rewritten from the ground up to support this update and I managed to make it just as simple and fast to change the settings for your devices and probes as well as add new ones.

Everything has been updated on my github to reflect this update as well so if you're interested in the opensource part of this project then definitely check it out!

Edit: I am updating the main post of this thread to reflect changes and include a new list of commands for the config manager and regular program
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Anyone who is interested in helping out with building some WebApps using the new JSON API is more than welcome just pm me if you're feeling up for the challenge!
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Just created a comprehensive command sheet for using the software:

Surfbox Command Sheet
---------------------

// Configuration Manager //

KEY WORDS:

`p` - Probe
`d` - Device
`add` - Add new blank object
`update` - Edits the value in format `key` `value`
`get` - Gets value in from `key`

DEVICES:

Add new blank device - `d add`
Update devices values - `d update [ADDRESS] [KEY] [VALUE]`
Display devices information - `d get [ADDRESS]`

PROBES:

Add new blank probe - `p add`
Update probes values - `p update [ADDRESS] [KEY] [VALUE]`
Display probes information - `p get [ADDRESS]`

MAIN PROGRAM COMMANDS:

`ls` - Lists all device and probe information with corresponding addresses
`exit` - Saves all changes to API and boots up SurfboxServer with new settings

// Server Functions //

KEY WORDS:

`p` - Probe
`d` - Device
`gets` - Gets status of device
`getr` - Gets most recent probe reading
`newr` - Inserts new probe reading into memory
`pchk` - Tests most recent readings against probes configuration settings and give logical response
`switchon` - Changes device status to true
`switchoff` - Changes device status to false

DEVICES:

Get device status - `d [ADDRESS] gets`
Switch device on - `d [ADDRESS] switchon`
Switch device off - `d [ADDRESS] switchoff`

PROBES:

Gets most recent probe reading - `p [ADDRESS] getr`
Inserts new reading into memory - `p [ADDRESS] newr [VALUE]`
Get logical response for probe parameter check - `p [ADDRESS] pchk`

MAIN PROGRAM COMMANDS:

`kill` - Safely disconnects server from client and waits for a new connection
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Happy holidays everyone! I just updated the software to 3.6.1 and it is available and should be running smoothly. The update includes some bug and also includes a new system in which the software locates the data.json (The main API file) so now you can move it over to your webserver folder on your computer and change the filepath in "api.properties" and get your webapps launched with live aquarium data !

As always reach out to me for any help or issues!
 
Last edited:
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
I've been focusing a lot on creating some example webapps that use the live API so people have some pre-done stuff or at least a template for their own project. I'm using HTML5, SCSS, Vanilla JavaScript, and jQuery to build the apps I'm by no means a front-end guy but I hope to launch a website with an example application streaming my actual tanks live data along with downloads, tutorials, and videos on how to use the software.
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Happy New Years R2R goers! I just returned back from a small weekend vacation and am ready to continue rolling out more of Surfbox!

As for the Server and the next version (3.7.0) I will be making two new additions to the software:

1) New options in configuration manager to edit the port that the server runs on
2) A way for the server to recognize a change in device status directly from the API so WebApps can control devices directly from the web

I have built a website to support Surfbox but it's still not quite done yet, I'm not the most amazing website designer so it's taking me a bit of extra time to get this up and running. This will open up a whole new set of useful features for everyone to enjoy!

1) Organized documents which will include; a set-up guide for the software, a few do-it-yourself devices with parts lists and instructions on how to put it all together. This is the part thats really taking the most time because I'm trying to make the guides as clear as possible with a lot of pictures.
2) Downloads that will include the latest version of the software, any supporting software, and easy to useWebApp templates for your aquarium! I hope to have over some time more than just my own WebApps featured for download.
3) My favorite part; a live streaming WebApp (template available for download) of my 60 Gallon reef in my living room that will be up 24/7! I figured it would be fun to show the flexibility of what you can do with the software, why not share my tank with the world!
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Here's a preview of whats to come! Feel free to criticize and have an input on my poor webdesign skills!

Screen Shot 2019-01-03 at 12.39.27 PM.png
 
OP
OP
Andrewalex11

Andrewalex11

Reef Technology
View Badges
Joined
Jan 27, 2017
Messages
323
Reaction score
270
Rating - 0%
0   0   0
Update (More for the nerds): Not much to show picture-wise, but thats the whole point!

So just a heads up to everyone out there; Raspberry-pi Zero W's are going around these days for $5 USD at most electronics dealers! I have a great electronics dealer by me fortunately, they seem to be fading away.

Anyway I purchased a Pi-Zero W and a 32GB microSD for a total of $9 fired it up and via SSH downloaded: SurfboxServer, Apache, Screen (a task manager for linux), and the Webside / WebApp that i've been working on. As of now the Server, Website, and all live-data from the aquarium is streaming through the Pi. It's amazing because I have a few USB cords that are no more than an inch in length from end to end so I used one of these on the board and plugged it into a free USB-Port on my router!

NOTE: This isn't something that you have to do to get your SurfBox up and running but it is definitely an option and again shows the flexibility of the software! This also makes it easier for me to share with you all on the soon coming website.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
how much CPU / memory utilization you are seeing with your server running on pi zero ? JDK / java based apps are bit memory hungry
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 34 27.9%
  • 100% dry rock + 100% live sand

    Votes: 42 34.4%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 27 22.1%
  • 75% live rock, 25% live sand

    Votes: 11 9.0%
  • 25% live rock, 75% live sand

    Votes: 8 6.6%
Back
Top