Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intro Tutorial #230

Closed
stuartabrown opened this issue Dec 21, 2018 · 72 comments
Closed

Intro Tutorial #230

stuartabrown opened this issue Dec 21, 2018 · 72 comments

Comments

@stuartabrown
Copy link

Hi,

First of all, awesome project! I installed on a RPi3 last night and all went smoothly.

I'm an experienced reptile keeper and reasonable in a few different programming languages but totally new to electronics.

As an intro to using TerrariumPi I would like to set up a heat and humidity sensor and use that to control a couple of different desk lights (ultimately of course these will be lights / humidifier in the vivarium, but I'll practice in a safe environment first!), however I'm unsure what hardware I need.

Going through the docs here I think I need:

Is that it or am I missing a few fundamental things? @theyosh if you're interested I'd be happy to try to write up a total newbie's guide to TerrariumPI documenting the process as I learn and add to the wiki once I get underway.

@Benjin
Copy link

Benjin commented Dec 24, 2018

I'm in the middle of upgrading a kickstarted terrarium/aquarium tank where the company went MIA for warranty to TerrariumPI + RPi3b. Before heading home for the holidays, I was able to get a temperature sensor (1Wire/I2C), an irrigation system, and misters (both GPIO-controlled) to simulate rainfall (bare minimum for being away for a week, as I have external lights) working all through custom hardware, and I'm documenting everything along the way.

If I don't beat you to the initial version, I'm absolutely down to help flesh yours own.

@theyosh
Copy link
Owner

theyosh commented Dec 24, 2018

Hi @stuartabrown

My software is build in a general way, so that you can choose from the sensors and swiches on: https://github.com/theyosh/TerrariumPI/wiki/Hardware

The DHTXX sensors are not that stable. I have experienced a lot of faulty readings if you want to operate it 24/7. I suggest to use somekind of a I2C setup with for example:

https://taaralabs.eu/1-wire-humidity-temperature-sensor/ with https://taaralabs.eu/category/1-wire/ (I have not used this, but it is known to work.

Or look at: http://www.sheepwalkelectronics.co.uk/product_info.php?cPath=22&products_id=30 with http://www.sheepwalkelectronics.co.uk/product_info.php?cPath=23&products_id=55

Al the humidity sensors do have a temperature sensor.

The GPIO relay is fine and will work.

If you want to use this in a production system, it is wise to by every hardware at least twice or more so you can create a setup to test and have backup hardware when one is failing.

If you are able to make a small tutorial, that is great. I do not find the time to write it all out. As English is not my native language it takes me more time then I have...

@stuartabrown
Copy link
Author

stuartabrown commented Dec 26, 2018

Thanks @theyosh, I have purchased the DHT22 now but they were very cheap and I'll just use for purposes of learning. Once I get my head around things i'll buy the production hardware!

@Benjin - would be awesome to collaborate on a tutorial. If your interested I'll set up a tutorial branch and perhaps we can work on that? @theyosh can you give me/us permission to push to a tutorial branch please?

@theyosh
Copy link
Owner

theyosh commented Dec 28, 2018

@stuartabrown how do you mean a tutorial branch? You will add that to my software? I was thinking of using something link https://medium.com/

Else I would either fork my repository and create your own and add there a tutorial branch.

And as latest, I can imagine you want access to this wiki, to add the tutorial there.

Else I am not sure what you mean. What is your preference?

@Benjin
Copy link

Benjin commented Dec 28, 2018 via email

@stuartabrown
Copy link
Author

@theyosh I've cloned the wiki locally - it's actually a different repo to your main main codebase https://github.com/theyosh/TerrariumPI.wiki.git (you can se the details on a wiki page). On my local I have a tutorial branch. I was thinking that there might be a way for you to give me and @Benjin permission to commit to the wiki repo so that we can collaborate and then create pull requests for the tutorials to be pulled into the main/master wiki?

@theyosh
Copy link
Owner

theyosh commented Dec 29, 2018

@stuartabrown that is not possible: https://help.github.com/articles/adding-and-editing-wiki-pages-locally/#cloning-wikis-locally-to-your-computer

Once you have cloned the wiki, you can add new files, edit existing ones, and commit your changes. You and your collaborators can create branches when working on wikis, but only changes pushed to the master branch will be made live and available to your readers.

Only the master branch will/can be shown. Also, that means you have write rights to my repository. I am not a fan of that.

So, I still think a website called https://medium.com is more suited for it. Or https://www.instructables.com/howto/reptile/

I do appreciate that you want to make a tutorial. But it should not end up that you need full write rights to my repo. Normal code you can create pull requests and those I can import. But for the wiki, it does not work that way.

@stuartabrown
Copy link
Author

@theyosh no problem, happy with that. I don't understand why the Github permissions don't allow owners to have separate permissions for the wiki and the main code - seems odd.

If you don't mind, before going the Medium route I'll create a fork of your repo and then try making a pull request to your documentation branch with wiki tutorial stuff. Should work as per https://help.github.com/articles/creating-a-pull-request-from-a-fork/

@stuartabrown
Copy link
Author

good grief, OK so that approach doesn't work for wikis! They make collaborative documentation really tough!

I'll go the Medium approach. Thanks for your patience!

@stuartabrown
Copy link
Author

Not really into the details yet but the first couple of tutorial posts are up at https://medium.com/@jinky32. Waiting for some sensors to arrive before getting to the interesting stuff :)

@theyosh
Copy link
Owner

theyosh commented Jan 8, 2019

Cool. I like your vivarium. Way cool below the stairs!

For the post on https://medium.com/@jinky32/setting-up-your-raspberrypi-and-installing-terrariumpi-97f2d2e8e6f I think it is handy to add something like:

When the software is installed, you can access it in your browser at: http://raspberrypi:8090

The hostname 'raspberrypi' is the default and mostly it will register it self at your router with that name. I think adding the line above to your tutorial, is a nice closing of the installation, and you can also check if the installation did work well. Even without any sensors, it should give a working web interface.

@stuartabrown
Copy link
Author

@theyosh thanks :). I've updated the post you mention and added a little bit extra too.

The sensors you suggested above
https://taaralabs.eu/1-wire-humidity-temperature-sensor/ with https://taaralabs.eu/category/1-wire/ arrived today. I can guess how these two items fit together, but could you point me in a direction where I can find out how https://taaralabs.eu/category/1-wire/ connects to my RPi3/TerrariumPI please?

@Benjin
Copy link

Benjin commented Jan 9, 2019

@stuartabrown Check this one out: https://tutorials-raspberrypi.com/raspberry-pi-temperature-sensor-1wire-ds18b20/

It shows how to wire it (you'll need a 4.7k ohm resistor) and how to confirm the pi can read it via the command line (no code necessary).

@stuartabrown
Copy link
Author

@Benjin thanks, will take a look. The guys at TaaraLabs have suggested

1-Wire board | Raspberry PI
GND          | 1 (GND)
5V           | 2 (5V)
3.3V         | 1 (3.3V)
D1           | 5 (SLC)
D2           | 3 (SDA)

for connecting the 1 Wire Shield https://taaralabs.eu/1-wire-shield-for-wemos-d1/ to the RPi3

@Benjin
Copy link

Benjin commented Jan 10, 2019 via email

@theyosh
Copy link
Owner

theyosh commented Jan 12, 2019

Ok, I have not used this before, but that shield will not fit directly on your pi. So that means a breadboard and some jumper cables to get it connected.

I use my self: https://pinout.xyz/pinout/rpi2_1_wire_adapter

But I do not know if that shield does work with your sensor. I do not know if they use the same wire schema for there connectors.

@stuartabrown
Copy link
Author

@theyosh next step in my intro tutorial is up answering a couple of your questions ;) https://medium.com/@jinky32/terrariumpi-adding-a-sensor-8afef4909fbe. Next step is to figure out how to do something (turn a light on and off) based on the readings.

cc @Benjin

@theyosh
Copy link
Owner

theyosh commented Jan 12, 2019

You should really try 1-wire: https://www.raspberrypi-spy.co.uk/2018/02/enable-1-wire-interface-raspberry-pi/ and https://www.raspberrypi-spy.co.uk/2013/03/raspberry-pi-1-wire-digital-thermometer-sensor/

The first url is enabling it for manual testing, my software does already that during installation. So you need only the second url for adding sensors.

It is really, really easy. Only 1 resistor needed and you can hook up X amount of temperature sensors. Will also by auto detected with my software

@stuartabrown
Copy link
Author

Thanks @theyosh I will look at those - I will certainly want to add multiple temperature sensors.

I've been looking at #167 to see how to get a device (light for example) to turn on/off based on sensor readings. Am I correct in thinking that my relay https://www.modmypi.com/raspberry-pi/relays-and-home-automation-1032/relay-boards-1033/8-channel-12v-relay-module should be connected to my RPi and then set as a switch in TerrariumPi and configured to turn devices on/off?

@theyosh
Copy link
Owner

theyosh commented Jan 13, 2019

@stuartabrown yes. Those relay modules will work. The logic for switching based on sensors should be configured in the environment part at the heater or sprayer part

@stuartabrown
Copy link
Author

thanks @theyosh . I hope you don't mind me asking all these questions, I appreciate they're all quite basic.

@theyosh
Copy link
Owner

theyosh commented Jan 14, 2019

Nope! Do you mind that I link to your medium posts on my wiki? ;)

https://github.com/theyosh/TerrariumPI/wiki

@stuartabrown
Copy link
Author

@theyosh haha no problem at all, small payback from me for all of your work!

@stuartabrown
Copy link
Author

Hello @theyosh . So I have my relay connected to my RPi and when I run this https://raw.githubusercontent.com/Mattrachwal/gpio-8channel-relay-test/master/gpio-relay-test.py it toggles through the inputs correctly and turns off the light that it connected to channel 1 (pin 26 in the code).
However when I add a switch and and set the GPIO address (I use 37 which I think is the physical address) without a timer the light doesn't turn on/off when I manually click it in GUI.
screen shot 2019-01-16 at 21 04 07
Any idea what I'm doing wrong here?

@Benjin
Copy link

Benjin commented Jan 16, 2019 via email

@stuartabrown
Copy link
Author

thanks @Benjin

@theyosh
Copy link
Owner

theyosh commented Jan 17, 2019

Your GPIO address should be indeed around 40. So address of 37 should work. But it could be that there is a bug, that when you add it, it is not correctly registered. So add it, and just restart my software. If it then works, then we have found a software bug. If it still does not work after restart, then it is very strange and needs more investigation.

Also I have made a stupid code bug, and you should chose for GPIO invert to use this. As the example code does the opposite of my code. One day that will be fixed. But my GPIO does work that way. But still with normal GPIO it should make the clicking sounds when changing the state.

So add it, and restart and see what happens. Also you could try to debug a bit: https://github.com/theyosh/TerrariumPI/wiki/FAQ#how-to-debug-terrariumpi and see if there are messages when you toggle the switch

@AndrejWeber
Copy link

Also I have made a stupid code bug, and you should chose for GPIO invert to use this. As the example code does the opposite of my code. One day that will be fixed.

There is no bug!
@stuartabrown you have to change the brown cable to lamp from nc1 to no1
it means "normaly open" and "normaly closed". Then the Lamp will also flasches up by using the test code and the switch in terrariumpi will also work as gpio (not inverted).

Can you also add a pic from above (raspi and relais board), so we can see, where you have connected the wires.

@AndrejWeber
Copy link

It looks like green is connected from pin39 (GND) to IN1.
if it is, try the yellow wire to IN1, this is pin37 GPIO26

@stuartabrown
Copy link
Author

@theyosh @AndrejWeber many thanks for your help with this.

@AndrejWeber you are right - I am connected to nc1 rather than no1, but my RPi connection is from pin37. It's not connected to the RPi atm so the below images won't show that but do show the nc/com connections.
img_20190117_214647
img_20190117_214720

Unfortunately my wife has just come home (obviously that is a wonderful thing ;-) ) so I have no more time to play tonight but I will set up asap tomorrow after work.

thanks again :)

@stuartabrown
Copy link
Author

thanks @theyosh , I'll try the settings suggested in #237 (comment). I'm still not sure though what the dimmer on and dimmer off values are for. How do they relate to the start / stop times if the lighting environment is set to timer?

BTW, new post is up for RPi camera tutorial. Thanks for your help with that. If you want any changes, let me know

@stuartabrown
Copy link
Author

@theyosh OK great. I have the light daytime ramp up and then ramp down working correctly. The only issue is that once the dimmer has turned the light back down to 0% it then turns it on again. Is this due to an incorrect dimmer down duration? Should that contain the amount of minutes between day stop and day start or something?

Once I've got this sorted I'll move on to controlling temps (disabling lights first so switch isn't used twice)

@stuartabrown
Copy link
Author

OK so I can get temp control working reliably too :) If someone can help me understand the purpose of dimmer on duration and dimmer off duration then I can start writing up my tutorial. And are these settings something to do with the light turning on against once it has reached 0% (as per above comment) when set as lighting environment?

@AndrejWeber
Copy link

Do you have still the dimmer used twice in light environment?
You only need to set it in day. Like last pictures it will dimm on at night time again.

@stuartabrown
Copy link
Author

stuartabrown commented Feb 24, 2019

thanks @AndrejWeber. Settings are as per below
screen shot 2019-02-24 at 13 17 09
screen shot 2019-02-24 at 13 17 32
screen shot 2019-02-24 at 13 17 40

logs

2019-02-23 11:27:39,936 - INFO    - terrariumSwitch      - Changed power switch 'PWM Dimmer' of type 'pwm-dimmer' at address '32' from state '25.0' to state '10.0' (Forced:False)
2019-02-23 11:28:09,942 - INFO    - terrariumSwitch      - Changed power switch 'PWM Dimmer' of type 'pwm-dimmer' at address '32' from state '10.0' to state '0.0' (Forced:False)
2019-02-23 11:28:32,840 - INFO    - terrariumSwitch      - Power switch 'PWM Dimmer' at address '32' is done at value 0.0% in 20.0 seconds

That all works fine, but then when the lights diminished to 0, they were then turned on again. I wonder if it is a wiring issue because as soon as I plug the light in that is connected to the PWM it comes on so that does seem to be it's default state. Here's how it is wired
img_20190216_114057

BTW what do you use dimmer on duration and dimmer off duration for?

@stuartabrown
Copy link
Author

stuartabrown commented Feb 27, 2019

OK I've been trying this again and I still can't get the light attached to the dimmer to stay off once it has dimmed to 0. Once it hits zero the light comes back on after approx 15 seconds. My assumption was that it should stay off from after the dimming ends (set in the lights environment, day, stop field) and then start to ramp up again when the time reaches the value set in the lights environment, day, start field. But this might be a misunderstanding on my part.

I've tried setting

  • timer on and timer off in lights environment to 0
  • setting dimmer on and dimmer off duration to 0 in the switch settings

but it makes no difference and was a totally random experiment anyway! Is the only way to keep the light off once it has dimmed to zero to use the dimmer in partnership with a relay as @AndrejWeber does in #178 ?

@AndrejWeber
Copy link

Normally your dimmer should work without Relais. Because you can reach 0% light level. My dimmer can only reach 1%, so will never turn off completely.

I wonder about your on and off duration in switch setting,
My settings are 5s, you have 600s.
I have set
Action duration: 20
Step: 1
On duration : 5
On percentage: 70
Off duration: 5
Off percentage: 0
For faster testing you can change step to 15
I do fade up and down very slow and also only up to 70%, because the t5 bulb with 54W is to much light.

@stuartabrown
Copy link
Author

@AndrejWeber many thanks for your help with this. So I have used your settings (with step as 15 rather than 1)
screen shot 2019-02-27 at 20 12 42

screen shot 2019-02-27 at 20 12 26

and here is a video https://youtu.be/3epRDUmCEBY?t=404 showing the effect that I get once bulb has gone to 0.

@AndrejWeber
Copy link

Is it a flickering, I’m not shure...
Then I have a solution

@stuartabrown
Copy link
Author

@AndrejWeber do you mean the state of the lamp in the last part of the video?

@AndrejWeber
Copy link

Yes, it looks not like normal “on”

@stuartabrown
Copy link
Author

any idea what it might be? Something to do with TerrariumPi settings? The dimmer? the Bulb?

@AndrejWeber
Copy link

Like it is written in the reviews of the dimmer, you should set a lower maxdim value.
It is in the terrariumSwitch.py
Line 585
In the Moment it is set to a PWM Value of 895.
Try some lower, for example 870
With a multimeter, you can measure from ground to pwm pin, you should measure something around 2.9V (DC)
It should not be more, then the Electronics get confused.

@stuartabrown
Copy link
Author

stuartabrown commented Feb 27, 2019

@AndrejWeber many thanks for that, gives me something to work on :) I don't have a multimeter with me at the moment but will have at the weekend. In case it is of use to you it looks like the default value has changed in terrariumSwitch.py
https://github.com/theyosh/TerrariumPI/blob/master/terrariumSwitch.py#L634

changing that value from 905 to 890 results in the same behaviour but bulb doesn't flicker. Will keep experimenting.

@AndrejWeber
Copy link

AndrejWeber commented Feb 27, 2019

you are right!
you shold try also without multimeter.
the developer says, the voltage should be about 2.85 to 2.90 V
so if we know, the raspi has 3.3V at 100% PWM ( @theyosh just invert this to 0% dim value )
we can do some mathwork.

maxdim = 2.85 / 3.3 * 1000
maxdim = 863

maxdim = 2.9 / 3.3 * 1000
maxdim = 878

try to use 870
If you get to low, the lamp will not go off, so nothing worse can happen

@stuartabrown
Copy link
Author

@AndrejWeber I love you! A value of 870 works perfectly!

BTW it's cool that you are dimming your T5s. I have Arcadia D5 Dragon Lamp and am currently running them on an on/off timer; I didn't realise they could be dimmed. I have daylight LEDs that mimic sunrise / sunset (https://zoomonster.com/epages/Shop_Econlux.sf/de_DE/?ObjectPath=/Shops/Shop_Econlux/Products/00011500) so I will eventually get the T5 to ramp up / down to the same schedule

@AndrejWeber
Copy link

they are perfect to be dimmed, but only with a dimmable ecg!
https://www.osram.com/ds/ecat/QUICKTRONIC%20INTELLIGENT%20DIM%20T5-ECG%20for%20FL%20and%20CFL,%20dimmable%20110%20V-ECG%20for%20fluorescent%20and%20compact%20fluorescent%20lamps-Electronic%20Control%20Gears%20for%20Lamps-Digital%20Systems-/com/en/GPS01_1027982/PP_EUROPE_Europe_eCat/ZMP_56666/
There are also some dali dimmer, but then you also need a i2c to dali interface and anyone, who implement a new hardware. ;D
Dali-ecg also do not need any relais to switch off the Lamp.

@theyosh
Copy link
Owner

theyosh commented Mar 2, 2019

So, because I expected it to work on 3.3Volts, I used a to high MAXDIM value? I will change it then a bit lower as mentioned here now.

theyosh added a commit that referenced this issue Mar 4, 2019
@stuartabrown
Copy link
Author

Phew - ok a few new guides at https://medium.com/@jinky32, including the PWM switch. As every feel free to request changes or additions. Thanks for all the help @theyosh and @AndrejWeber :)

@vacuumboots
Copy link

I just wanted to chime in and mention that it has been great to follow along with this open ticket / the medium articles! .
Thank you so much for all of the work put into this project @theyosh. @stuartabrown it's been great to follow along with your progress in near real-time.

@stuartabrown
Copy link
Author

Thanks @vacuumboots . I've been busy with some other stuff but back on it again now!

@theyosh re the UV sensors and specifically your comment #90 (comment) about only supporting one because they have the same I2C address, would it be possible to use an I2C multiplexor e.g. https://learn.adafruit.com/adafruit-tca9548a-1-to-8-i2c-multiplexer-breakout/overview?

@theyosh
Copy link
Owner

theyosh commented Mar 30, 2019

I would rather follow: https://www.instructables.com/id/Raspberry-PI-Multiple-I2c-Devices/ That will add more I2C buses and there fore you can have more of the same sensor. Every bus 1 sensor.
This is more stable than using a multiplexer board.

Also, using a multiplex board is harder to implement. Currently, multiple I2C buses is supported.

@stuartabrown
Copy link
Author

@theyosh that looks great, no additional hardware involved! So if that goes in I just connect up the various devices and 'it just works' ?

@theyosh
Copy link
Owner

theyosh commented Apr 22, 2019

Euh, I have not tested it, but my code can handle multiple I2C buses on the Pi. So yes, in theory it should just work.

@theyosh
Copy link
Owner

theyosh commented Jan 28, 2020

@stuartabrown lost this a bit out of sight? And I do understand that it is a lot to write. So are you still planning to make updates? Or can we close this issue?

@stuartabrown
Copy link
Author

@theyosh yes, there's been a few changes in personal circumstances so have had to pause on this. I still get quite a few questions etc on Facebook etc so I still help and point people to your project when I can. But yes, feel free to close this ticket.

I hope to get back involved in the future :)

@theyosh
Copy link
Owner

theyosh commented Feb 7, 2020

Damm, I have a Facebook representative :P :)

Thanks a lot for that. I do not have FB. And I still want to thank you for the first part of writing. It is still a nice part of work.

Then I will close it now. And we will see what the future brings.....

@theyosh theyosh closed this as completed Feb 7, 2020
theyosh added a commit that referenced this issue Mar 22, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants