OfficeReefer

Well-Known Member
View Badges
Joined
May 25, 2020
Messages
630
Reaction score
497
Rating - 0%
0   0   0
It was the easiest way to get an editable project page, since I can’t do that here. At least not yet ^^
Still don't understand the need for this on here either. There's an edit button in the post, don't post until you are ready.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Still don't understand the need for this on here either. There's an edit button in the post, don't post until you are ready.
Not quite sure what you are saying in that first sentence.

The build Thread here and the GitHub page serve two different purposes.
The GitHub page is supposed to be a somewhat tidy overview.
This forum is to document all minor steps I took with pitfalls, dead ends and discussions like this.

Without editing the first post I could never achieve that overview here, but on GitHub there is no community to help me with Reef-Pi build issues ^^
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, I'm back from holiday and wanted to immediately test the flow sensor directly on the level shifted input.

However, my Pi Zero WH didn't start ... the LED stayed dead. I already had a little panic attack and started looking for a replacement, but I also wrote another Raspbian OS Lite on my Backup SD and could you imagine ... it worked again.

Seems like I somehow got my SD corrupted. Not sure how, since I always powered the PI off before killing the power, but hey. I'm grateful that it still works ^^
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, set everything up again and tested the flow meter directly on the level shifted input. It works better and exactly like I thought:
The flow meter sensor line is pulled up with a resistor, that gets pulled down by a kind of FET when it does not detect a magnetic field.

My level shifted line is basically a pulled up line with two 10k resistors, one to 3.3V and 5V each, as mentioned before. When I connect that to the Flow meter the signal line gets pulled down to something like 1.2-1.7V. Maybe that's due to wire and contact resistance limiting the pull-down over the contacts and long wire connecting my circuit with the flow sensor.

I'll try to measure and reduce contact resistance. Another funny thing: when I measure the voltage with a voltmeter, the moment of contact creates enough voltage drop to be registered by the PI as LOW and consequently leads to some flow being registered. So maybe I just need to add some 20k pull-down resistor and the flow will register fine.

Ultimately I may just go down the route @robsworld78 suggested: simply use a GPIO pin and drop the 5V to 3.3V using a resistor bridge ^^
 
Last edited:

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
Location
Edmonton, Canada
Rating - 0%
0   0   0
Alright, set everything up again and tested the flow meter directly on the level shifted input. It works better and exactly like I thought:
The flow meter sensor line is pulled up with a resistor, that gets pulled down by a kind of FET when it does not detect a magnetic field.

My level shifted line is basically a pulled up line with two 10k resistors, one to 3.3V and 5V each, as mentioned before. When I connect that to the Flow meter the signal line gets pulled down to something like 1.2-1.7V. Maybe that's due to wire and contact resistance limiting the pull-down over the contacts and long wire connecting my circuit with the flow sensor.

I'll try to measure and reduce contact resistance. Another funny thing: when I measure the voltage with a voltmeter, the moment of contact creates enough voltage drop to be registered by the PI as LOW and consequently leads to some flow being registered. So maybe I just need to add some 20k pull-down resistor and the flow will register fine.

Ultimately I may just go down the route @robsworld78 suggested: simply use a GPIO pin and drop the 5V to 3.3V using a resistor bridge ^^
I think your method using the BSS138 is better especially as you have it working with the DS18B20, I think the voltage divider with the resistors messes up the DS18B20 but I said that about the level shifter. :) Previously I was going to mention trying a strong pulldown resistor over 10k as I've noticed when doing something like this the stronger resistor usually wins but probably not very efficient or correct. Good luck. :)
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
I think your method using the BSS138 is better especially as you have it working with the DS18B20, I think the voltage divider with the resistors messes up the DS18B20 but I said that about the level shifter. :) Previously I was going to mention trying a strong pulldown resistor over 10k as I've noticed when doing something like this the stronger resistor usually wins but probably not very efficient or correct. Good luck. :)
Thanks ! The 10k pull down might actually be a good idea, that would pull the line from 5V down to 3.3V, since both the sensor and the level shifter have a 10k pull up. Just measured that with a multimeter. So I have an effective 5k pull up, so adding a 10k pull down drops the voltage to:
5V*10k Ohm / (10k Ohm + 5k Ohm)=3.3V

I did however find the problem with the direct connection to the Level shifter: I included a 2.7k series resistor in the signal cable to the flow meter to protect the originally planned npn transistor from overcurrent. Which I completely forgot ^^
This of course limits the pull down on the signal line to the observed 1.7V instead of GND 0.0V. Removing this resistor should remedy this problem and enable me to use the flow meter directly on the BSS138 level shifter.

stay tuned !
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, removed the series resistor from the flow meter's signal cable. Afterwards the sensor pulls the signal line perfectly to 0.0 V and gives 2.5V DC when I generate some flow in my flow sensor.

Testing with Reef-Pi and @robsworld78 's flowmeter script again shows nice flow, when I simulate flow by blowing some air through the backup flow meter:
1659555634864.png



So success !
Flow meters, at least the Seedstudio one I have as a backup, have an internal 10k pullup between signal and VCC and the sensor pulls this down with a FET whenever it doesn't detect a magnetic field. You can therefore directly plug the signal line into the BSS138 level shifter and measure it on the PI.

Now I have to hope that the one I already built into my filter line (an Adafruit one) works the same ^^

Next up: testing the Ph meter and all the other I2C devices.
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, I already tested my I2C Setup.
A9D4A306-09CE-44F4-A4BD-23F02D944ACF.jpeg

You can see the I2C connections on the PI HAT at the top right with 3.3V, GND, SDA and SCL (red, black, purple and grey respectively) with header cables into the I2C level shifter just between the 2 DC/DC converters on the left.

This connects into the switch board on the input board on the bottom right, where I have 4 blocks of 2x2 female headers. One block for 5V and GND each (red and black) and another two to split the level shifted SDA and SCL (purple and grey) to the I2C extender, the Real-Time Clock and the 2 USB breakout boards you see in red on the bottom left.
The USB breakout boards are stacked using extra-long stacking male header pins on the top board and female header sockets on the bottom board, so I can connect both boards with just one header cable, like on this post earlier.

I installed the Real-Time-Clock according to this guide, it registers at the correct address and reads the correct time, so I'm assuming that my setup works as expected and I can proceed to connect further modules via the I2C.

Wish me luck !
 
Last edited:

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
Location
Edmonton, Canada
Rating - 0%
0   0   0
Alright, removed the series resistor from the flow meter's signal cable. Afterwards the sensor pulls the signal line perfectly to 0.0 V and gives 2.5V DC when I generate some flow in my flow sensor.

Testing with Reef-Pi and @robsworld78 's flowmeter script again shows nice flow, when I simulate flow by blowing some air through the backup flow meter:
1659555634864.png



So success !
Flow meters, at least the Seedstudio one I have as a backup, have an internal 10k pullup between signal and VCC and the sensor pulls this down with a FET whenever it doesn't detect a magnetic field. You can therefore directly plug the signal line into the BSS138 level shifter and measure it on the PI.

Now I have to hope that the one I already built into my filter line (an Adafruit one) works the same ^^

Next up: testing the Ph meter and all the other I2C devices.
Right on, glad to hear you got it working with the BSS138. I have that Adafruit flow meter, I think it works the same. Good luck! :)
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
NeXT up: finishing the AC relay connection to the GPIO pins and the air quality module.

I noticed a problem wi the SCD-30 / SCD30 Sensor from Sensirion: it can run on 5V, but the SDA and SCL pins are supposedly always pulled up to 3V, so you would need a level shifter. I therefore ordered the Adafruit SCD-30 board, which includes a level shifter for just a few $ more and finished the whole module with the BMP280 air pressure sensor, since it’s quite easy and a quick way to test I2C module integration:
2EECBE96-74F1-4DC7-A447-D4B661F03184.jpeg

It’s simply the USB breakout board (red) on the front right that supplies 5V, SDA,SCL and GND through header pins to a Adafruit Stemma QT Connector on the Adafruit SCD-30 (green on black in the back) which is connected through the double connection to the BMP280 board (black in the front left). I basically just cut a STEMMA QT cable, soldered header pins to it and isolated them with shrink tube.
I also drilled some holes into the side and lid.

Tomorrow I’ll test if I can connect this to the main unit, wish me luck ;)
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Success !

I finished an I2C USB cable, I recommend everybody to afterwards try with a multimeter if you connected the right lines. I did of course solder it the wrong way, so when I plugged the USB into the socket I had to turn the cable around … had to resolder, but at least I found that out before blowing my new circuit ^^

The SCD30 lights up and correctly shows as address 0x61, as expected. I am still missing the BMP280, expected at 0x76, but I’m happy for now. Also: the RTC at address 0x68 is loaded and blocked correctly (see the "UU").
1659901833395.png


I also soldered and tested the first relay channel and it also clicks as expected when triggered and switches the status LED as intended:
6E89E6CE-8C1E-4EEE-96F6-D9CF7290079F.jpeg


You can see my air quality module in the bottom right with the I2C connection via USB cable. The SCD30 lights up correctly.
The AC power and relay module in the top right has 8 status LEDs, one of which is off, because I triggered it.

Whoooop, Whooop !
 
Last edited:
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, I patched a c++ program together using @robsworld78 's pH script and some code on the SCD30 I found on GitHub.
Took a bit of time, but now I get a CO2-value (currently uncalibrated):
1660332981219.png

Now I just need to adapt that to give all the values and save that to a file using @robsworld78 's flowMeter script and I'm good to go. I hope you don't mind that I'm scavenging your code ^^
It was the easiest and cleanest way, I could have used python, but that needs additional installs and packages, so I went with this.
 

robsworld78

Well-Known Member
View Badges
Joined
Feb 14, 2020
Messages
952
Reaction score
1,281
Location
Edmonton, Canada
Rating - 0%
0   0   0
Alright, I patched a c++ program together using @robsworld78 's pH script and some code on the SCD30 I found on GitHub.
Took a bit of time, but now I get a CO2-value (currently uncalibrated):
1660332981219.png

Now I just need to adapt that to give all the values and save that to a file using @robsworld78 's flowMeter script and I'm good to go. I hope you don't mind that I'm scavenging your code ^^
It was the easiest and cleanest way, I could have used python, but that needs additional installs and packages, so I went with this.
Nice job, glad it was useful, I much prefer c++, me and python don't get along.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Alright, I patched a c++ program together using @robsworld78 's pH script and some code on the SCD30 I found on GitHub.
Took a bit of time, but now I get a CO2-value (currently uncalibrated):
1660332981219.png

Now I just need to adapt that to give all the values and save that to a file using @robsworld78 's flowMeter script and I'm good to go. I hope you don't mind that I'm scavenging your code ^^
It was the easiest and cleanest way, I could have used python, but that needs additional installs and packages, so I went with this.
nice :)
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, my SCD30 program is progressing !

I started building a c++ class for control and communication.
That get's used in two programs:
- one command console based user-interface
- a service that regularly writes values into files (exactly like @robsworld78's flowmeters ^^)

The service part works by itself, now it only needs the install script to integrate it into the Pi Zero's services.
The user interface is basically non-existant, but it will be necessary for temperature compensation and setting-control. Currently the sensor shows 27°C in its box, even though the room has something like 24°C. Maybe I need to drill additional holes :grinning-face-with-sweat:
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Finally got the service-install up and running. Basically used @robsworld78's bash script. It did give me some problems because my editor (notepad++), decided to put a tabulator at the end every line for some reason. Which editors typically do not print for obvious reasons. The command console therefore complained that '\r' (the string representation of a tabulator) is not a valid command, go figure ... :grinning-face-with-sweat:

It does however work now:
1661256389538.png

It gives a nice uncalibrated baseline of 650ppm and shoots up to several 10.000 ppm and increased humidity and temperature when I blow into it (breath has something like 40.000ppm CO2). Nice.

Now I get to work on the Control program and the License ^^
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Alright, I managed to almost complete the control program to communicate Settings to the SCD30 from command line.

I’ll finish that soon and put it up on GitHub. I used @robsworld78‘s install script and the crc calculation and byte conversion from somebody else’s SCD30 library, so I’ll have to think about the license.
If possible I’ll simply use the standard Apache license that rob used as well, since this isn’t really my own product, just a simple interface.
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Alright, I managed to almost complete the control program to communicate Settings to the SCD30 from command line.

I’ll finish that soon and put it up on GitHub. I used @robsworld78‘s install script and the crc calculation and byte conversion from somebody else’s SCD30 library, so I’ll have to think about the license.
If possible I’ll simply use the standard Apache license that rob used as well, since this isn’t really my own product, just a simple interface.
Nice
 
OP
OP
S

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Just for reference: I finished the Air Quality SCD30 interface in its 1.1 version, there is a separate thread in this forum.

I could now calibrate the sensor (force calibrate a value of 450 ppm after opening the window wide for 15 min and waiting for the value to settle on equilibrium) and set the temperature offset (since the sensor is contained in an enclosure with holes it heats up this enclosure to roughly 3.8°C above room-temperature which is registered by 2 DS18B20 sensors sitting directly next to the SCD30 enclosure).

Currently I could only use the altitude correction to 75m, as I have not yet set up my pressure sensor to continuously feed the SCD30 the current ambient pressure. That's something for the future :)
 

Algae invading algae: Have you had unwanted algae in your good macroalgae?

  • I regularly have unwanted algae in my macroalgae.

    Votes: 44 35.2%
  • I occasionally have unwanted algae in my macroalgae.

    Votes: 27 21.6%
  • I rarely have unwanted algae in my macroalgae.

    Votes: 9 7.2%
  • I never have unwanted algae in my macroalgae.

    Votes: 10 8.0%
  • I don’t have macroalgae.

    Votes: 31 24.8%
  • Other.

    Votes: 4 3.2%
Back
Top