Closed kevinmic closed 8 years ago
Yes, you can use those additional pins. 24 and 26 are already used in relay_board, they are the last 2 of the 12 pins the plugin uses. For each pin you add to the list in "relay_board.py", you need to add an option line to "relay_board.html". For example, if you add pin 19 (giving you 13 channels), edit "relay_board.html" and find this line:
<option value="12" ${" selected" if m_vals[u"relays"]==12 else ""}>12</option>
below it add:
<option value="13" ${" selected" if m_vals[u"relays"]==13 else ""}>13</option>
note that I just changed 12 to 13 in 3 places.
Yes, the additional pins of the B+ and RasPi 2 can be used with the same technique described above.
Would you please answer a few questions to give me some feedback?
First, let me explain why I did a few things. Although the pin order looks random, there is some reason for it. I started with the pin order used by wiringPi, which first uses pins that are only for input and output (IO). Then I used pins that are IO and have a secondary function like I2C, SPI and serial. I stopped at 12 because it would be three 4-channel relay boards or an 8-channel and a 4-channel. I could go to 16, which is a nice round number for two 8-channel boards, but that would use one of the serial pins, but maybe most sprinkler users don't care.
Looking at the code and my initial assumptions again, I think I'd do things differently. So now the questions:
1 - Would it be best to have this plugin grab all available IO, even those with a secondary function (I2C, SPI, serial)?
2 - I could provide a new option on the settings webpage so the user can select to use all IO pins or only those that don't have a secondary function. This would be useful for users who are using those ports, for example, an I2C device plugged into their RasPi. Would adding this new option be helpful or confusing?
3 - The pin order I used, jumps around. I got it from wiringPi, but looking at it now there's no reason to stick with it. I'm thinking it might be easier to wire if the order started at the top of the connector and worked it's way down. What do you think? Would this change cause too much confusion, especially for people already using the current plugin?
4 - A better way to handle up to 128 channels is to use I2C 16 port expanders. These little boards cost $8.35 and each one could connect to two 8-channel relay boards. If you need more than 16channels you'd buy another expander taking you to 32 channels, and so on up to 8 expanders, 128 channels. This increases the cost of each channel by $0.50. I strongly prefer to write a new plugin for this. What do you think?
First some background.
I am coming from a perspective of I know how to program and know my way around linux, but I am noob to Raspberry Pi, python, and electronics. I originally tried the sprinklers_pi but had a bunch of errors trying to get working and finally found how to get the source code for OSPI. (You would think this is obvious but it really wasn't. I kept looking for OpenSprinker pi).
Thank you for pointing out to me that I need to change the html page to allow for more than 12 pins, I didn't think about that. I will try it and let you know if it works for me.
Your questions 1. For me, yes. But I am new to the pi and have no idea why grabbing the I2C, SPI, and serial would be bad. Also another note on this, I noticed when I initially tried to wire up my pi with the other 4 pins that the last pin was always "on" when the system booted up. I am not sure which pin this was but I would not want this behavior on my sprinkler system.
2. I would have used it (and am going to alter your code so I can do it). You might also have a way to specify for b+ users so that they can use the extra GPIO.
3. I think that having the pins go in order would be easier to follow. To be honest I had a hard time finding this github page. I was looking in your python code to figure out how to wire up my relay. I eventually found this page by finding your username in the manifest file in the plugin and then searching for "KanyonKris relay_board". It would be nice if you provided a link in the app to this page to help others wireup their pi. (maybe you did and I just missed it)
As for it causing confusion, yes it would probably cause some confusion? Do people keep their OSPi up to date? My plan was to setup my sprinkler system and once it is working not to really mess with it. So if/when people update they might get annoyed that the wrong sprinklers are turning on. But once you figured out there was a change it would be easy to fix things.
4. This sounds great, but I have no idea how to use a I2C. Also I run more sprinkler stations than almost else I know. I am currently at 12 and might expand up to 16. If I wanted more I would probably swap out my pi for a b+ to give me more IO. So while the idea sounds cool, I would probably never use it, and everyone I know that I could convince to setup a OSPi probably wouldn't need it either.
Thanks for the plugin and the help.
Thanks for the reply and feedback.
Regarding pins on at bootup, I'm glad you mentioned this so I could look into it. Turns out pins 3 and 5 have pull-up resistors so they will be high (on) when power is applied to the RasPi, and will stay on until the OS boots up or until ospi runs, not sure which. Personally my RasPi doesn't get power cycled very often and if it did and the water came on for a few seconds I don't care much. However if this would cause problems for you I wouldn't use those pins. Just edit the relay_pins to choose the pins you want to use. If you have a rev 2 you can use the 4 GPIO pins from P5, if you don't mind soldering a connector or wires. If you have a B+ or RasPi 2 there are 9 more GPIO.
For B+ and RasPi 2 I'll see if I can add some code to detect those boards and use the additional pins.
Thanks for letting me know it was difficult to find the docs on the web. There is a help button on the settings webpage, but it may be easy to miss. I'll add a link to the source code.
I just setup my OSPi sprinkler system and used your plugin. Thank you, it works great!
I had a question though. I would like to add more than 12 stations. Is it possible to use pins 19, 21, 23, 24, 26 on the raspberry pi b? (I tried to simply add them to your pin list and it didn't work).
How about the b+, can the additional pins be used?