OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, I got too impatient and soldered the Relais input and status LEDs in a bad way:
FEE945BA-D37D-478D-84D8-29ADFE71537A.jpeg

Close up on the input:
457263A0-D51A-4CA9-8807-57510E357971.jpeg

I removed the input pins on the Relais Board and replaced them with 90 degree ones to save height. That’s ok so far.

The rest of the connections are a bit sloppy however. It will probably work, but there is too much open wire and weak connections in there.

I will probably remove the cables and connect the LEDs with header cables more cleanly on a mint board with header pins. Wish me luck :grinning-face-with-sweat:
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Just noticed: This circuit will probably not work ^^

the voltage at the Relais inputs will be the diode voltage, that makes it something like 2 Volts, which is probably too low to trigger the optocouplers with their 1k inline resistor and status LED in series.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Just to clarify this: the problem comes from two things:
- the ULN2803 is a sink type driver. So to supply the Relay input with +5V and GND I need a pull up resistor
----> Pull ups are generally high to limit the current when the ULN2803 is open
- I want a status LED that lights up when the relay is not triggered (since I want to connect to normally closed)
----> That means I want to drive them when the Relay's input is at 5V (Relay is active at low level)
----> however, any current coming in at 5V has to go through the pull-up resistor, which is designed for too low current

I will therefore either need to omit the status LEDs, change the relay connection to normally open, or drive the status LEDs with another transistor. I will try to go for the last option, but I am running out of space in the case as you can see in my earlier post ^^
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, I went back to straight pins and gave the Relais board a kind of HAT:
4E99D86C-ADE4-4B2C-AA98-693C1ED6CC4D.jpeg


To save space I will use a ULN2801 Darlington transistor array. A bit of an overkill, but it leads to a nice package. The front towards the DB9 Connector are the input pins connecting directly to the Relais inputs. Left and right are the current Leads to the LEDs in red and then color coded the lines to the ULN2801 outputs that triggers the LEDs.

Big thanks to @Ranjib , if you hadn’t mentioned the screw terminals I couldn’t have made it this beautiful :D

Made a few small errors though, as I didn’t give every LED their own resistor. That will lead to them losing a bit of brightness the more of them are on.
Also: the screw on terminals can’t be stacked well, if you add 4x2 together it causes stress and they will not stay straight. So you should use the right size from the start and not combine them to the required size.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Alright, I went back to straight pins and gave the Relais board a kind of HAT:
4E99D86C-ADE4-4B2C-AA98-693C1ED6CC4D.jpeg


To save space I will use a ULN2801 Darlington transistor array. A bit of an overkill, but it leads to a nice package. The front towards the DB9 Connector are the input pins connecting directly to the Relais inputs. Left and right are the current Leads to the LEDs in red and then color coded the lines to the ULN2801 outputs that triggers the LEDs.

Big thanks to @Ranjib , if you hadn’t mentioned the screw terminals I couldn’t have made it this beautiful :D

Made a few small errors though, as I didn’t give every LED their own resistor. That will lead to them losing a bit of brightness the more of them are on.
Also: the screw on terminals can’t be stacked well, if you add 4x2 together it causes stress and they will not stay straight. So you should use the right size from the start and not combine them to the required size.
looks awesome. the screw terminals should have fine grooves /notch to make a tight fit, at least the ones I used had it and side stacking was not an issue.. but I also have not tried a longer stretch (4-5 pins)
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, two days of soldering later I am the proud owner of this cramped power-supply and Relais-unit:
66A3C0A1-7D4F-4F8B-BBDB-E65186AE8D93.jpeg


78342008-A8AF-4458-BEB7-5C217062592E.jpeg


Maybe I need to think about adding one of the fans I bought ^^
@robsworld78 any experience with the thermals on those Relais and power supply ?

Next up: Uploading the circuit files on GitHub and building the main reef-PI unit !
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
985
Reaction score
1,325
Location
Edmonton, Canada
Rating - 0%
0   0   0
Looking good, looks like it was all meant to fit. The relays shouldn't put out any heat and the power supply it depends on the load. I'm willing to guess you won't be drawing much so can't see any excuse heat but yeah with it sealed shut it's hard to guess. Might be good to put a few slots for air flow or put a temp sensor inside just to see what temps it reaches.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
@robsworld78
Looks like it was ^^

I’ll calculate the expected load on the 2x5V + 12V rails and get back to you. Good thing I have a spare DS18B20 and drilled a few extra holes because I decided not to connect the AC wires to the lid after all.

BTW to anybody who is interested: I created all holes by drilling, since I had a drill lying around, and filed them out using Tamiya modeling files. Small enough for the job and only cost about 10 bucks for a set of three.
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
985
Reaction score
1,325
Location
Edmonton, Canada
Rating - 0%
0   0   0
The relays will draw the most when they are all active, the Pi draws very little unless you use the USB ports and all the other circuits draw almost nothing. You should be well under an amp for everything.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Looked it up out of curiosity and you were absolutely right:

5V Main Pi draw:
- Pi Zero: 80-120 mA
- Ethernet: 180-280 mA
- SCD30 (CO2 sensor): 19mA
- EC Sensor: 3-6 mA
- Temp sensor (DS18B20): <1mA
- Barometer sensor (BMP280): <1mA
- Relay inputs (ULN2803 feeding optocouplers): 8 x 5mA (all relays running)
- Optocoupler Inpur for LED Dimming: 6 x 10 mA (all 6 channels running at 100%)
TOTAL (max): ~550mA (2.75 W)

5V Relay draw:
- Relais: 8 x 100 mA (all relais running, 4W)
- LED optocoupler driving side: 8 x 4 mA
TOTAL (max): ~850mA (4.25 W)

12V Relay draw:
- 5V Pi converter: 270 mA (2.75W / 85% efficiency)
- 5V Relay conerverter: 420 mA (4.25W / 85% efficiency)
- dosers 4 x 300 mA (max)
TOTAL (ave): 700 mA (8.4 W, ~56% from relais)
TOTAL (max):1900 mA (with all dosers running simultaneously)

So the realistic consumption is about 400-500 mA @12V (6W).
Assuming an efficiency of about 85% for the 12V supply @ 6W means about 1W of heat at the converter.

Not sure, but that sounds negligible.
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
985
Reaction score
1,325
Location
Edmonton, Canada
Rating - 0%
0   0   0
Looked it up out of curiosity and you were absolutely right:

5V Main Pi draw:
- Pi Zero: 80-120 mA
- Ethernet: 180-280 mA
- SCD30 (CO2 sensor): 19mA
- EC Sensor: 3-6 mA
- Temp sensor (DS18B20): <1mA
- Barometer sensor (BMP280): <1mA
- Relay inputs (ULN2803 feeding optocouplers): 8 x 5mA (all relays running)
- Optocoupler Inpur for LED Dimming: 6 x 10 mA (all 6 channels running at 100%)
TOTAL (max): ~550mA (2.75 W)

5V Relay draw:
- Relais: 8 x 100 mA (all relais running, 4W)
- LED optocoupler driving side: 8 x 4 mA
TOTAL (max): ~850mA (4.25 W)

12V Relay draw:
- 5V Pi converter: 270 mA (2.75W / 85% efficiency)
- 5V Relay conerverter: 420 mA (4.25W / 85% efficiency)
- dosers 4 x 300 mA (max)
TOTAL (ave): 700 mA (8.4 W, ~56% from relais)
TOTAL (max):1900 mA (with all dosers running simultaneously)

So the realistic consumption is about 400-500 mA @12V (6W).
Assuming an efficiency of about 85% for the 12V supply @ 6W means about 1W of heat at the converter.

Not sure, but that sounds negligible.
Yeah sounds like it should be ok. What EC circuit are you using? Let us know how that SCD30 works out, once and a while I get asked about co2. Curious about the barometer meter as well. Are you planning to run a script along side reef-pi and import data using the file driver?
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Yeah sounds like it should be ok. What EC circuit are you using? Let us know how that SCD30 works out, once and a while I get asked about co2. Curious about the barometer meter as well. Are you planning to run a script along side reef-pi and import data using the file driver?
Yeah, I think so too, even though I forgot the 0.5W that each relay itself will dissipate on top of that.
I’ll start using a CQRobot TDS sensor (see my GitHub) and also try the DIY version (GitHub and Reef2Reef). Both are analog circuits, I have an ADS1015 analog digital Converter and a DFRobot analog isolator for that.
The SCD30 (CO2 Sensor) is an I2C circuit, so I’ll probably have to use the file driver.
Only problem with this sensor is that you have to calibrate it regularly, meaning you have to completely vent the room with fresh air to reach the ~400ppm ambient level once a week or so.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, I checked all I2C addresses and had a bit of a panic moment, because Adafruit lists the SCD30 CO2 sensor at the same address (0x68 / #104) as the real-time-clock module (RTC, 0x68 / #104). The manufacturer, Sensirion, however lists the sensor at 0x61 / #97, so fingers crossed ^^

Here's the list (0x - hex, # - decimal)
  • real-time-clock:
    • PCF8523
    • 0x68 / #104
  • pH Sensor
    • robo-tank pH board
    • 0x62 / #98
  • AnalogDigitalConverter (ADC)
    • ADS1115
    • 0x48-0x4B / #72-#75
  • CO2 sensor
    • sensirion SCD30 (or SCD-30)
    • 0x61 / #97
  • Air + CO2 pressure and temperature
    • 2 x BMP280
    • 0x76 and 0x77 / #118 and #119
  • PulseWidthModulation (PWM)
    • PDA9685
    • 0x40-0x5E / #64-#95
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
985
Reaction score
1,325
Location
Edmonton, Canada
Rating - 0%
0   0   0
Alright, I checked all I2C addresses and had a bit of a panic moment, because Adafruit lists the SCD30 CO2 sensor at the same address (0x68 / #104) as the real-time-clock module (RTC, 0x68 / #104). The manufacturer, Sensirion, however lists the sensor at 0x61 / #97, so fingers crossed ^^

Here's the list (0x - hex, # - decimal)
  • real-time-clock:
    • PCF8523
    • 0x68 / #104
  • pH Sensor
    • robo-tank pH board
    • 0x62 / #98
  • AnalogDigitalConverter (ADC)
    • ADS1115
    • 0x48-0x4B / #72-#75
  • CO2 sensor
    • sensirion SCD30 (or SCD-30)
    • 0x61 / #97
  • Air + CO2 pressure and temperature
    • 2 x BMP280
    • 0x76 and 0x77 / #118 and #119
  • PulseWidthModulation (PWM)
    • PDA9685
    • 0x40-0x5E / #64-#95
I think the co2 will be 0x61, the datasheet seems to indicate this as well. All the RTC's use 0x68 so it would be very surprising if something else only had that address as an option. For the most part it appears companies are pretty careful when selecting addresses. For my pH circuit you can send a command and change the address to anything you want if needed. Atlas uses 0x62 for one of their circuits, I think ORP.

 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, made a few stupid mistakes. Just to explain:
  • I accidentally connected my circuits ground to the relay boards ground
    • this would of course ruin my effort for isolation
    • thankfully though, I could solve that by:
      • simply cut the wire that connected the relay board's ground to the PI circuit's ground (the DB9 GND)
      • move the GND input to another conveniently placed screw terminal
    • See picture on the right side
    • That was pretty lucky ^^
  • I replaced the AC input wire and of course, the new one had the leads exactly the other way around
    • so I had to switch the leads on the input (see bottom left)
  • I connected the leads incorrectly to the rocker switch, so everything was ON at the OFF setting
    • switched the leads to the correct positions (see bottom middle)
    • good thing I used blade connectors for that XD
  • I also screwed up the Relay Input and LED drive
    • thankfully that will be saved by replacing the ULN2801 with a ULN2803
    • now I have to wait for my overpriced ULN2803 to arrive ^^
Circuit.jpeg


Just to explain why that is necessary:
LEDDriveProblem_schem.png

That's effectively the circuit I had planned:
  • PI's GPIO with 5V on the left
  • driving a ULN2801 with a pull-up resistor (left)
    • provides the relay input signal over the DB9 (middle)
    • towards the relay input (right)
    • 5V on Input for normal operation, Relay OFF, AC ON
    • GND on Input for Shutdown, Relay ON, AC OFF
  • problem: I wanted to have an LED to show the AC status
    • So I put a ULN2801 in there to drive a LED when IN is at 5V
    • Problem there:
      • when the ULN2801 on the left is OFF, the 4,7k Pull-up and the ULN2801 Base to Emitter path to GND on the right form a resistance bridge
      • The Base-Emitter acts as a diode, dropping a constant ~0,7V
      • the pull-up drops the remaining 4,3V
    • The relais input therefore sees 0,7V so:
      • Relay probably triggers when it should be off
      • the relay probably kills the ULN2801 by constantly sinking 4,3 mA across the Base-Emitter
  • Solution:
    • replace the ULN2801 on the right with a ULN2803, which has an internal 2,7k input resistor
    • decrease Pull-Up in the PI-unit (left) to ~1k
    • That will lift the relay signal In to around 4V, turning the relay OFF
    • the ULN2803 Base should still get enough current to switch the status LED
    • the status LEDs only draw ~10mA of the rated 600 mA, so I need much less base current to trigger that
All in all, I seem to have more luck with this project than I deserve,
or to say it with @robsworld78 's words: Looks like it was meant to work ^^
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, I updated the drawings on GitHub.

As explained above I changed:
  • AC Relay Signal (Bottom in Pi Unit):
    • changed the transistor arrays ULN2801 IC to ULN2803 IC (the latter has internal 2,7k input resistance)
    • decreased the pull-up resistors in the PI Unit to 1k
    • moved GPIO pins
  • I2C circuitry (Upper part in Pi Unit):
    • included the I2C isolator ISO1540 (takes care of level shifting to 5V)
    • included the I2C booster LTC4311 (boosts I2C signals to deal with longer cables)
    • included I2C connection over USB socket
  • GPIO circuitry (left side in Pi Unit):
    • moved GPIO pins to utilize the 2 UART pins
    • BSS138 Level shifter
    • DS18B20 outlets
    • 1 flow meter
    • 2 GPIOs for possible expansions
  • Doser GPIO Pins (right side in PI unit):
    • occupy the last 4 available GPIO pins
  • Backup:
    • SPI0 pins
      • MOSI, MISO, CLK, CE0, CE1
      • SPI interface if needed
      • 5 more GPIO if needed
    • EEPROM pins
      • one more I2C Interface if needed
      • 2 more GPIO pins if needed
    • GPIO26
      • not wired in the HAT
      • usable if needed
PowerUnit_schem.png
PiUnit_schem.png
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,848
Reaction score
17,081
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
i <3 reading through your build logs. Thank you so much for sharing. The hardware setup details and implication originating from it is invaluable. Wherever you settle at the end design, I'd love to follow through this and amen the official docs to incorporate these learning.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, built the power side of the Main PI unit and started testing the BSS138 level shifter with the DS18B20. If that doesn’t work I’ll have to try adding 10k pull up resistors that work in parallel with the BSS138 board’s own 10k to bring it down to the 5k that’s generally used.

FD136AE9-C608-47B9-84C4-57CD4A862D82.jpeg


I had to get a little creative with the space, the DC/DC modules in the guide don't have a display and are therefore a lot smaller. Probably should have stacked them using standoffs.

Now I stacked the I2C chips on top with one screw, since they are very light and are only connected using header cables. Not the best solution, but the only one I have so far.

[UPDATE:] Aaaaand we are having power issues again ... Pi wont show up on network :loudly-crying-face:
Maybe I'll try removing that sensor or adding a capacitor to the 5.0 V supply voltage
 
Last edited:
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Okay, standard error in testing: don't change two things at the same time.

Seems I had two issues: power problems AND sensor problems:
  • The used 3.0A step down converter didn't seem to work, whether I connected the sensor or not
  • The previously sufficient 2,5A Phone charger only seems to work if I disconnect the DS18B20 sensor
Strangely enough, when I reconnected the DS18B20 sensor after the Pi booted up, I have no problems.
I'll keep testing and keep you updated, but for now I have a working temperature sensor even though it's connected through the Adafruit BSS138 level shifter board. Maybe that's because for pull-up operation (see the principle explanation), both of the 10k pull-ups on low and high side are connected until the MOSFET threshold is crossed, effectively pulling up with the typically used 5k at the start.
1657274468591.png


I read the same temperature as my room (21.7 °C as referenced by an air quality monitor by Hama) and when I touch the sensor it shoots up to 30°C and slowly cools down afterwards.

Something interesting for @Litserv : that exponential decay towards the room's 21.7°C after touching the sensor gives you its time constant / sluggishness in air. I estimate it's about 2-3 minutes, meaning that if the environment jumps by 8 degrees (in my case from 30° to 21.7°), it takes the sensor 2-3 minutes to register ~ 63% of that change and will roughly read the final temperature after 4 times that, e.g. 8-12 minutes. If you have your sensor in the airflow of a fan it will probably be lower though.

If you are mathematically inclined: the sensor's reaction to a step in temperature follows roughly:
T(time) = T0 + Tstep*(1-exp(-time/timeContant))
Mathematically speaking, this smooths the measured temperature with the exponential sawtooth you see in my measurement, e.g. most of the measurement is the current temperature, but it retains quite a bit of value from the last 2-8 minutes following that sawtooths tail.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
978
Location
Germany
Rating - 0%
0   0   0
Alright, I soldered a 10V 220µF electrolytic capacitor to two header cables and connected it to the PI's power rail.

First I tried the proven 5V 2.5A Phone charger to see if the capacitor causes problems. It didn't, PI showed up on network.
Afterwards I tried the DC/DC converters, did not seem to work.
I increased their voltage slightly from 5.0 to 5.1 and after some waiting the PI showed up. Huray !

Since I was wondering about the time it took before the PI showed up (~1-2 minutes maybe ?), I backtracked.
I tried without the capacitor, but with increased voltage, the PI showed up after some waiting.
I also decreased the voltage again and the PI showed up again, even though I am now back to where I started !

So I am thinking that maybe my Router is not the fastest or that the Adafruit Ethernet Hub causes some problems.

Either way, I have the PI up and running with the intended 5V step down converters, so the project can continue as planned !
 
Back
Top