reef-pi :: An opensource reef tank controller based on Raspberry Pi.

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
I was looking through the part list and for some items they do not list the detailed part number like for this TL432DBZ SMD-SOT23 but there are quite a few part numbers to choose from.
Welcome to component land where not much makes sense... 10 parts with basically the same model can really put you in jam. :)
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0
The good news is these are all pretty basic parts, and could even be built nearly fully assembled from the parts catalog of JLCPCB's hilariously cheap assembly service. I'll see about getting the centroid/part center/pick and place file out of KiCad.

TL432s come in two basic voltages, but the 2.495V reference is usually considered the standard one.
If you want to do this you'll know better than me. The one question I have is the adapter wanting 0-3.3v or 0-5v PWM signal. Something tells me ML's board is putting out 3.3v but I could be wrong.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
If you want to do this you'll know better than me. The one question I have is the adapter wanting 0-3.3v or 0-5v PWM signal. Something tells me ML's board is putting out 3.3v but I could be wrong.
I think he stated in the vipar thread that he was feeding 5v but that the vipar was ok with that voltage, I think he stated it used 3.3 but was ok with 5v.
Here is the reference - https://www.reef2reef.com/threads/controlling-viparspectra-lights.698216/post-7212790
 

robsworld78

Valuable Member
View Badges
Joined
Feb 14, 2020
Messages
1,029
Reaction score
1,293
Location
Edmonton, Canada
Rating - 0%
0   0   0

GaryE

Well-Known Member
View Badges
Joined
Mar 12, 2020
Messages
992
Reaction score
1,321
Location
Coatesville, Indiana
Rating - 0%
0   0   0
a quick update. I was trying to do this all in the arduino, but it seems it's really not up to the task of slurping in all of the metrics, parsing for the right data and then spitting out the right bit.. So... I decided to write a python script to do that part and output to a file, then will have the arduino connect and FTP the files to get the data and then display it. Should be way easier on the ardiuno side that way. Then it's a matter of finding a case and figuring out how I want to power it long term.. Fun stuff!!

On the positive side, this will make the gadget portable. Will not be tied to the tank. Just will need to plug it in somewhere and instant stats!

so far, this is the python code.


import requests

URL = "http://10.167.15.10/x/metrics"
tankTemp = "tank_temp_reading"
sumpTemp = "sump_temp_reading"
boxTemp = "box_temp_reading"

Another quick update.. the python side of things is complete, mostly, just need to figure out where on the PI that the files are going to live, however, everything works as needed.

You can assign any of the metrics that reef-pi emits in the metrics "dictionary" and it'll happily scrape that and plop the value in a text file named for the metric.

Next step will be to figure out the best way to have the arduino connect to the PI and read those files. I'm thinking I'll have to store the files in a separate directory and have the arduino just get a listing of the files and read any it finds.. (with whatever sanity checking I can figure out). Mind you, I am not a C programmer at all. For that matter, I'm not a python programmer, I spent a few minutes in the 90's working with Perl and a couple decades mucking around with PHP though.

# add metrics from the reef-pi/x/metrics end point here that you'd like to display on your # arduino or whatever else may be reading these files metrics = { "tankTemp": "tank_temp_reading", "sumpTemp": "sump_temp_reading", "boxTemp": "box_temp_reading", "boxFan": "equipment_fan_state" } # retrieve the metrics from the server and save them to a variable. from urllib.request import urlopen response = urlopen('http://10.167.15.10/x/metrics') html = response.read() html = html.decode() serverMetrics = html.split('\n') # split everything into lines. # function to remove the metric name from the line found in getTemp() def listToString(s): # initialize an empty string string = " " # return string return string.join(s) # while looping through the metrics dictionary, get the metric value from def getMetric(t, m): for line in m: if not line.startswith(t): # remove commented lines from metrics to reduce size in memory pass else: text = line.split(' ') # split everything into lines. text.pop(0) tempMetric = (listToString(text)) # strip the metric name from the line return tempMetric # loop the dictionary to get the values of the temp readings for key, value in metrics.items(): met = (getMetric(value, serverMetrics)) # get the values from the server metrics if met is None: metric = str("BROKEN!") # in the likely event that a sensor fails, rather than bork the script, return an error else: # all data should be good, so let's write some files... f = open(value, "w") f.write(met) f.close()
 
Last edited:

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,253
Reaction score
3,603
Location
Sacramento, CA area
Rating - 0%
0   0   0
Yup, @Michael Lane was making them but no longer, all of the files are up on git and I have been looking at having some boards made but I am a total noob. I know I would like some and I know there are some others as well trying to figure out what is the easiest way to accomplish it. I was looking through the part list and for some items they do not list the detailed part number like for this TL432DBZ SMD-SOT23 but there are quite a few part numbers to choose from. The boards look pretty straight forward but at least for me I would need some better descriptions for some of the parts listed, @Ranjib thought it would be you or @robsworld78 would be able to clarify and or figure out what was needed to order some up.

:)

Just as a test, since its a very simple adapter, I dropped a full turnkey order to JLCPCB for 15 units. This means everything except the headers will come pre-assembled on the boards. Due to some aggressive couponing ("please try our service!"), the whole thing was sub $50 including DHL. Its amazing how cheap some simple prototypes have gotten..

The part rotations needed some tweaking, and odds are I'm going to get the board back with all the diodes on backwards. Will report back when I get something in hand :)
 
OP
OP
Ranjib

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
Just as a test, since its a very simple adapter, I dropped a full turnkey order to JLCPCB for 15 units. This means everything except the headers will come pre-assembled on the boards. Due to some aggressive couponing ("please try our service!"), the whole thing was sub $50 including DHL. Its amazing how cheap some simple prototypes have gotten..

The part rotations needed some tweaking, and odds are I'm going to get the board back with all the diodes on backwards. Will report back when I get something in hand :)
whoa.. thank you for doing this.
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,253
Reaction score
3,603
Location
Sacramento, CA area
Rating - 0%
0   0   0
Just as a test, since its a very simple adapter, I dropped a full turnkey order to JLCPCB for 15 units. This means everything except the headers will come pre-assembled on the boards. Due to some aggressive couponing ("please try our service!"), the whole thing was sub $50 including DHL. Its amazing how cheap some simple prototypes have gotten..

The part rotations needed some tweaking, and odds are I'm going to get the board back with all the diodes on backwards. Will report back when I get something in hand :)

Small update: JLCPCB didn't feel like they could load SOD-123 diodes onto an 0805 sized pad (which is fair, its not really the right size). A few hours later, trying with SOD-323 diodes from their catalog. And saved an extra $5 in the process by using some mainland brand parts.


I have to say, if you can fall under the limits of the assembly service (not too many unique parts, using mostly parts already loaded on their machines, etc) the whole thing is a very good value.
 
OP
OP
Ranjib

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
Small update: JLCPCB didn't feel like they could load SOD-123 diodes onto an 0805 sized pad (which is fair, its not really the right size). A few hours later, trying with SOD-323 diodes from their catalog. And saved an extra $5 in the process by using some mainland brand parts.


I have to say, if you can fall under the limits of the assembly service (not too many unique parts, using mostly parts already loaded on their machines, etc) the whole thing is a very good value.
Thats awesome.
It makes a lot of sense to design boards specifically to fit this constrain
 

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
199
Rating - 0%
0   0   0
How you are moving the metric from reef-pi to influxdb ? You can not assign the metadata in that mechanism ?
it’s bit confusing on reef-pi end to specify those metadata since it’s not pushing metrics anywhere, it just publish the metrics in a handler/endpoint which prom scrapes . Any metadata is associated by the prom scrape config

The metrics re picked up by mosquitto then I pick them up in node red. Then node red populates infulxdb.

Here is the some data but flows are not reef-pi specific as I am still waiting for segregation so I do not have to redo everything

Capture1.JPG Capturedb.JPG mosq-Capture.JPG
 
Last edited:

marekd1

Active Member
View Badges
Joined
Dec 24, 2019
Messages
133
Reaction score
199
Rating - 0%
0   0   0
I think I get it now. You are talking about your work node red controller. Reef/pi does not uses any external db like influx , uses its own embedded database called boltdb. In this way reef-pi is significantly less component compared to the stack you are using . A full reef-pi does not need any external host to store metric or visualize charts . It has all those built in, and ships as single Debian package that comes with the entire db, backend, front end . For advance use cases (like arbitrary graphs, long term retention ) reef-pi allows Prometheus integration .

I've posted my flow in another post above. Basically I use the reef-pi as datasource through MQTT. Once MQTT topic is published (in Ree-Pi's case everything is one big clump of data and its not segregated under a specific topic say reef-pi-01 then I can pick this data up from MQTT and do anything I want. no dependency on internals of reef-pi. This method allows data collection from any device that published MQTT and then I can use most optimal platform to do post processing.

Here is an example of how MQTT reef-pi data looks in comparison to other MQTT providers

mqtt JPG.JPG
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Just as a test, since its a very simple adapter, I dropped a full turnkey order to JLCPCB for 15 units. This means everything except the headers will come pre-assembled on the boards. Due to some aggressive couponing ("please try our service!"), the whole thing was sub $50 including DHL. Its amazing how cheap some simple prototypes have gotten..

The part rotations needed some tweaking, and odds are I'm going to get the board back with all the diodes on backwards. Will report back when I get something in hand :)
Awesome, I have an order on pcbway but not sure on a couple of the components, if you could point me to what I need for d1-TL432DBZ, d2,d3 - 1n4148 and d4,d5 - D_Schottky? I am willing to chip in on the ones you had made, but would like to know how you figure out the part number for those items I listed. I am trying to learn to do more smd work so I am ok with putzing around with stuff.

Let me know how I can help the cause etc, really appreciate you doing this. :)

Update I didn't read down far enough, I think you answered a couple of the questions, man I wish I understood electronics a tenth of what you guys do, like its another language to me.
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,253
Reaction score
3,603
Location
Sacramento, CA area
Rating - 0%
0   0   0
Awesome, I have an order on pcbway but not sure on a couple of the components, if you could point me to what I need for d1-TL432DBZ, d2,d3 - 1n4148 and d4,d5 - D_Schottky? I am willing to chip in on the ones you had made, but would like to know how you figure out the part number for those items I listed. I am trying to learn to do more smd work so I am ok with putzing around with stuff.

Let me know how I can help the cause etc, really appreciate you doing this. :)

Update I didn't read down far enough, I think you answered a couple of the questions, man I wish I understood electronics a tenth of what you guys do, like its another language to me.

Here is a grab from the parts picked on JLCPCB:
1641532378358.png



The part numbers (C####) can be popped into lcsc.com to get the details - in these cases, they're mainland (China) parts.

1N4148: As it says, anything with this part number, but sized to fit a SOD-323 (closest to an 0805).

TL432DBZ: You'll notice this is a TL432ASA.

The first letter is the tolerance, in this case A is worse than B, but no B parts were available and 1% vs 0.5% in this application isn't going to matter:

1641532561331.png


The "SA" is the package code for Diodes Inc for SOT-23-3. I'm unsure what the BZ in the original was after. TL432s come sometimes in a 1.24V version, but I picked the standard 2.495V.

"D_Schottky": Opted for a BAT54 in SOD-323 package. BAT45 is a pretty common "generic" part for a Schottky diode. Rated for 30V (more than enough) and 200mA (also more than enough). Usually, BAT54 is packaged in a SOT-23-3 (three leg part) as well, but there was a mainland brand packaged in a SOD-323, so just rolled with it.
 

im_jeremy5

Community Member
View Badges
Joined
Aug 14, 2019
Messages
41
Reaction score
60
Rating - 0%
0   0   0
Thats awesome.
It makes a lot of sense to design boards specifically to fit this constrain
Hey buddy, pal,

Due to some negligent actions on my part I can't access the gui. I need to reset reef-pi to factory settings without access to it. Is there a file location for the settings I can delete/edit? Or a command line way to reset it? Specifically I changed the adress on the configuration page, after that I can no longer access the gui.
 
OP
OP
Ranjib

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
Hey buddy, pal,

Due to some negligent actions on my part I can't access the gui. I need to reset reef-pi to factory settings without access to it. Is there a file location for the settings I can delete/edit? Or a command line way to reset it? Specifically I changed the adress on the configuration page, after that I can no longer access the gui.
answered on the other thread https://www.reef2reef.com/threads/reef-pi-5-0-release-announcement.874824/page-3#post-9764461
 
OP
OP
Ranjib

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
I've posted my flow in another post above. Basically I use the reef-pi as datasource through MQTT. Once MQTT topic is published (in Ree-Pi's case everything is one big clump of data and its not segregated under a specific topic say reef-pi-01 then I can pick this data up from MQTT and do anything I want. no dependency on internals of reef-pi. This method allows data collection from any device that published MQTT and then I can use most optimal platform to do post processing.

Here is an example of how MQTT reef-pi data looks in comparison to other MQTT providers

mqtt JPG.JPG
this has been fixed in main branch, will be out in next release. thank you for the detailed report, it helps a lot.
 
OP
OP
Ranjib

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
i was thinking about attending aquashella, but now with omicron rise, I don't know how I feel about it. There will be a lot of folks :-/ . Any of you are attending the event? orlando covid cases are on the rise.
Screen Shot 2022-01-08 at 10.47.00 AM.png


but I so want to be there :-( . may be I'll wait out another two weeks before making a call.
 

theatrus

Valuable Member
View Badges
Joined
Mar 26, 2016
Messages
2,253
Reaction score
3,603
Location
Sacramento, CA area
Rating - 0%
0   0   0
i was thinking about attending aquashella, but now with omicron rise, I don't know how I feel about it. There will be a lot of folks :-/ . Any of you are attending the event? orlando covid cases are on the rise.
Screen Shot 2022-01-08 at 10.47.00 AM.png


but I so want to be there :-( . may be I'll wait out another two weeks before making a call.

Personally, not for any of January, and indoors only with (KF95|KN95|N95). Will see if the current spike is so fast moving it burns its self out by Feb.
 

GaryE

Well-Known Member
View Badges
Joined
Mar 12, 2020
Messages
992
Reaction score
1,321
Location
Coatesville, Indiana
Rating - 0%
0   0   0
a quick update. I was trying to do this all in the arduino, but it seems it's really not up to the task of slurping in all of the metrics, parsing for the right data and then spitting out the right bit.. So... I decided to write a python script to do that part and output to a file, then will have the arduino connect and FTP the files to get the data and then display it. Should be way easier on the ardiuno side that way. Then it's a matter of finding a case and figuring out how I want to power it long term.. Fun stuff!!

On the positive side, this will make the gadget portable. Will not be tied to the tank. Just will need to plug it in somewhere and instant stats!

so far, this is the python code.


import requests

URL = "http://10.167.15.10/x/metrics"
tankTemp = "tank_temp_reading"
sumpTemp = "sump_temp_reading"
boxTemp = "box_temp_reading"

..... yadda yadda...
so, since this post I have mostly finished.. There are a few small changes I want to make, but until I find a good way to do them, this will do... (keep in mind, I'm neither a python, nor a C++ programmer, try not to point and laugh too much)

I was planning to use FTP to connect and get the file data, but HTTP was way easier. I was able to setup nginx in with autoindex on and set to JSON format, so it was a simple matter of using ArduionJSON to get the file names from the webserver and then use that list to pull the data from them. I'm sure if you know a little C/C++ you'll see what I'm doing there in the code and shake your head in amazement that it even does anything but cause a buffer over run and crash the Arduino.. It doesn't.. It happily churns out digits to me like I intended..



Python code:

Code:
# add metrics from the reefpi/x/metrics end point
# here that you'd like to display on your
# Arduino or whatever else may be reading these files


metrics = {
    "tankTemp": "tank_temp_reading",
    "sumpTemp": "sump_temp_reading",
    "boxTemp": "internal_box_temp_reading",
    "boxFan": "equipment_fan_state",
    "heater1state": "equipment_tank_1_heater_1_state",
    "heater2state": "equipment_tank_1_heater_2_state"
}

# retrieve the metrics from the server and save them to a variable.

from urllib.request import urlopen

response = urlopen('http://10.167.15.10/x/metrics')
html = response.read()
html = html.decode()
serverMetrics = html.split('\n')  # split everything into lines.


# function to remove the metric
# name from the line found in getTemp()


def listToString(s):
    # initialize an empty string
    string = " "
    # return string
    return string.join(s)


# while looping through the metrics dictionary,
# get the metric value from


def getMetric(t, m):
    for line in m:
        if not line.startswith(t):
            # remove commented lines from metrics to reduce size in memory
            pass
        else:
            text = line.split(' ')  # split everything into lines.
            text.pop(0)
            tempMetric = (listToString(text))  # strip the metric name
            return tempMetric


# loop the dictionary to get the values of the temp readings
for key, value in metrics.items():
    met = (getMetric(value, serverMetrics))  # get the values
    if met is None:
        metric = str("0")  # display error if a sensor fails
    else:  # all data should be good, so let's write some files...
        f = open("html/" + value + ".txt", "w")
        f.write(met)
        f.close()

Arduino code:

Code:
/**
 * BasicHTTPClient.ino
 *
 *  Created on: 24.05.2015
 *
 */

#include <Arduino.h>
#include <ArduinoJson.h>
#include <StreamUtils.h>
#include <WiFi.h>
#include <WiFiMulti.h>

#include <HTTPClient.h>

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

WiFiMulti wifiMulti;
HTTPClient http;

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET     -1
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
String url = "http://IPADDRESS:81/";

float getMetric (String name) {
  float met;
  String website = url + name;
  http.begin(website); //HTTP
  http.GET();
  String metric = http.getString();
  met = metric.toFloat();
  return met;
}

void setup() {
//    Serial.begin(9600);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
 display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
 display.clearDisplay();
 display.setTextSize(1);
 display.setTextColor(WHITE);
 delay(2000);
 display.clearDisplay();
 display.setCursor(0,0);
 display.println("Metrics Display \nSystem starting...");
 display.display();

 /*
    for(uint8_t t = 4; t > 0; t--) {
        Serial.printf("[SETUP] WAIT %d...\n", t);
        Serial.flush();
        delay(500);
    }
*/
    wifiMulti.addAP("SSID", "PASS");
}

void loop() {
    display.clearDisplay();
    display.setTextColor(WHITE);
    // wait for WiFi connection
    if((wifiMulti.run() == WL_CONNECTED)) {

//        Serial.print("[HTTP] begin...\n");
        http.useHTTP10(true);
        http.begin(url); //HTTP

//        Serial.print("[HTTP] GET...\n");
        // start connection and send HTTP header
        int httpCode = http.GET();

        // httpCode will be negative on error
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
//            Serial.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if(httpCode == HTTP_CODE_OK) {
              
                DynamicJsonDocument doc(4096);
                deserializeJson(doc, http.getString());
                display.clearDisplay();
                display.setCursor(0, 0);
                for (JsonObject item : doc.as<JsonArray>()) {

                    String name = item["name"];
//                    Serial.println(getMetric(name));
       
                      if (name == "tank_temp_reading.txt"){
                       display.print("Tank Temp: ");
                      }
                      else if (name == "sump_temp_reading.txt") {
                       display.print("Sump Temp: ");                  
                      }
                      else if (name == "internal_box_temp_reading.txt") {
                       display.print("Box Temp: ");                  
                      }
                      else if (name == "equipment_tank_1_heater_1_state.txt") {
                       display.print("Tank Heater: ");                 
                      }
                      else if (name == "equipment_tank_1_heater_2_state.txt") {
                       display.print("Sump Heater: ");                 
                      }
                      else if (name == "equipment_fan_state.txt") {
                       display.print("Fan : ");                 
                      }

                    display.println(getMetric(name));
                    display.display();
                  
                }     

            }
        } else {
//            Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
            display.clearDisplay();
            display.setCursor(0, 0);
            display.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
            display.display();
        }

        http.end();
    }

    delay(10000);
}
 
Last edited:

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Hey buddy, pal,

Due to some negligent actions on my part I can't access the gui. I need to reset reef-pi to factory settings without access to it. Is there a file location for the settings I can delete/edit? Or a command line way to reset it? Specifically I changed the adress on the configuration page, after that I can no longer access the gui.
Remove the database file should get you sorted, this is a good page that has troubleshooting tips - https://reef-pi.github.io/guides/troubleshooting/

Eh I see @Ranjib gave you a much better answer ignore my answer, although that troubleshooting page is a good resource. :)
 
Last edited:

TOP 10 Trending Threads

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

  • 100% live rock + bagged sand

    Votes: 38 26.6%
  • 100% dry rock + 100% live sand

    Votes: 48 33.6%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 32 22.4%
  • 75% live rock, 25% live sand

    Votes: 15 10.5%
  • 25% live rock, 75% live sand

    Votes: 10 7.0%
Back
Top