OpenSprinkler › Forums › Hardware Questions › Alternative hardware
- This topic has 23 replies, 7 voices, and was last updated 9 years, 8 months ago by Ray.
-
AuthorPosts
-
July 30, 2013 at 1:31 pm #22567
andrewParticipantI’m very happy with my current setup (OS controller + RPi), but the other day I came across the SainSmart 8 Channel DC Relay (http://www.sainsmart.com/8-channel-dc-5v-relay-module-for-arduino-pic-arm-dsp-avr-msp430-ttl-logic.html), and was wondering whether this (plus a RPi) might be suitable as somewhat less expensive alternative. Any thoughts?
July 30, 2013 at 5:27 pm #25157
virtusParticipantWould that relay work with the 24V sprinkler valves? I’m using a smaller version (4 relays) of that to open / close my garage.
Also, I think the OS Pi is more than a bargain when you consider the software/coding, case, design, and instructions. But that’s the great thing about DIY projects, there are a lot of ways to get things done.
July 30, 2013 at 9:25 pm #25158
andrewParticipantOh indeed, there’s no question that the OS controller is a good deal. It has more features (single power source, shift registers for unlimited extendability), and requires relatively little in terms of install and setup. My question is mostly academic (I have no intention of changing things around at this point anyway). I do think that the relay works with 24VAC, the output is rated to AC250V and since all it’s doing is closing the circuit, smaller voltages shouldn’t be a problem (correct me if I’m wrong here).
One problem is that it seems to require wiring up some resisters and transistors to get it to interface with the RPi. What are you using to control your garage door?
July 31, 2013 at 3:42 am #25159
virtusParticipantI’m using the relay I mentioned in my other post. I’m still playing around with the code, but it’s connected to the garage door opener buttons in my garage. So when the relay closes it tricks the garage door opener into thinking a button has been pushed. It’s very simple but very effective.
August 1, 2013 at 3:09 am #25160
RayKeymasterIndeed you can use relay. Basically the relay’s data pin will be connected to the shift register, or directly to a GPIO pin if you don’t need shift register. But as I mentioned in another thread, I would still prefer triac because they are significantly cheaper than relay, more compact, and have faster switching speed.
If you are looking for the bare-minimum hardware, the OpenSprinkler zone expansion board is close to that. What you need at the minimum (to interface with sprinkler valves) are triacs, resistors, and optionally shift register (again, if you directly use GPIO pins you don’t need shift registers). On top of that, you need a microcontroller (like Arduino), or RPi to send control command, and an Ethernet shield, or USB dongle to handle web requests. So if budget is a major concern, you can build your own controller at a pretty low cost.
August 1, 2013 at 12:49 pm #25161
andrewParticipantAnd now I know what a triac is. It’s been a while since I took an EE class. Thanks for the info, Ray.
August 1, 2013 at 2:59 pm #25162
mattguyMemberYes they work just fine, in fact that is how I had my system running until I got my opensprinkler pi in the mail. The only problem that I really had with it was that it is normally high so when the raspberry pi goes down or something, your sprinklers come on. Doh! So I would recommend you get the solid state one that is normally low from here – http://www.sainsmart.com/8-channel-5v-solid-state-relay-module-board-omron-ssr-4-pic-arm-avr-dsp-arduino.html
Also you are going to need a shift register because the program isn’t written to use a pin per relay, so you can get those here
http://www.ebay.com/itm/10ea-74hc595-8-bit-shift-regester-ships-from-USA-/250862712322?All in all, honestly I would just spend the extra $25 to get a opensprinkler pi. I tried going the relay route and spent more $ and time than I would have on the opensprinkler pi (and I still ended up buying it).
September 9, 2014 at 2:48 pm #25163
haixMemberHi Guys,
I’m new in this Forum and I bought a Raspberry Pi, bought a 8 Releaycard and installed the OSPI on SD. Due to I’m from germany I try to use these components to bring the OSPI running in my house inviroment. Can anybody recomment which GPIO Ports should be used for OSPI and Releycard? I tested all Ports against Ground, but nothing reacts on switching in OSPI OS WebUI.
thanks in advance,
HAIXSeptember 9, 2014 at 3:18 pm #25164
RayKeymasterOSPi uses a 74HC595 shift register to generate 8 outputs. The shift register take 4 GPIO pins. It’s implemented this way so you can easily cascade additional shift registers to produce more outputs without using more GPIO pins (and that’s how the expansion boards work).
If you want to use 8 GPIO pins to directly drive relay board, you can use Rich Zimmerman’s sprinklers_pi program, which supports this option.
September 9, 2014 at 3:29 pm #25165
haixMemberHey Ray,
you’re amazing! Thank you so much. I will check this and try this first.
cheers, HAIX
March 2, 2015 at 9:24 am #35778
loop_1Participantbut if i use the Rich Zimmerman’s sprinklers_pi program i can’t use the iOS app, it’s correct?
Or there is also the possibility to use the iOS app?
March 2, 2015 at 7:22 pm #35783
RayKeymasterRich’s sprinklers_pi program doesn’t work with our iOS app. I strongly recommend trying the unified firmware which got just released yesterday:
https://opensprinkler.com/forums/topic/announcing-opensprinkler-unified-firmware-2-1-3-for-avrrpibbblinux/
Most features available in the sprinklers_pi program are available in the unified firmware, and it’s supported by our iOS app.March 3, 2015 at 8:06 am #35792
loop_1Participantoh yes! This night i have tried the unified firmware but i use a relay borad and there is non compatibility with it…
I hope in the new plugins! 🙂
March 4, 2015 at 8:48 am #35811
RayKeymasterIt’s actually not that difficult to modify the unified firmware to support relay board. I assume what you mean is that each station is controlled by an individual GPIO pin. I believe the following two functions need to be changed:
– in OpenSprinkler.cpp, function apply_all_station_bits(): this is where the station status bits are pushed to the shift register on OpenSprinkler. Change this to assigning status to each station GPIO pin instead.
– in OpenSprinkler.cpp, function begin(): this is where you need to initialize the GPIO pins. So change the first 6 lines (configure shift register) to configure your GPIO pins.March 4, 2015 at 6:48 pm #35819
Dan in CAParticipantThe Python Interval Program has a plugin named relay_board that allows the program to work with relay boards. You can install it from the plugin manager. Click the HELP button for configuration and wiring instructions or you can see the instructions at:
https://github.com/KanyonKris/sprinkler-weather/wiki/relay_board-Documentation
Dan
March 5, 2015 at 1:45 am #35825
loop_1Participantthanks Ray but also if i have only 3 stations + pump, this procedure is too diffucult for me!
Thanks Dan for the suggestion, but i see that the relay board is only for python interval program i would like to try the new firmware.
March 6, 2015 at 12:25 am #35833
RayKeymasterYou may be over-thinking about the difficulty: the way I described involves changing less than 10 lines of code.
March 6, 2015 at 2:40 am #35840
loop_1Participant🙂
ok the parts to change are this:
____________________________________________________________________
void OpenSprinkler::begin() {
// shift register setup
pinMode(PIN_SR_OE, OUTPUT);
// pull shift register OE high to disable output
digitalWrite(PIN_SR_OE, HIGH);
pinMode(PIN_SR_LATCH, OUTPUT);
digitalWrite(PIN_SR_LATCH, HIGH);
pinMode(PIN_SR_CLOCK, OUTPUT);
pinMode(PIN_SR_DATA, OUTPUT);
// Reset all stations
clear_all_station_bits();
apply_all_station_bits();
// pull shift register OE low to enable output
digitalWrite(PIN_SR_OE, LOW);
// Rain sensor port set up
pinMode(PIN_RAINSENSOR, INPUT);
____________________________________________________________________
and this:
____________________________________________________________________
// Apply all station bits
// !!! This will activate/deactivate valves !!!
void OpenSprinkler::apply_all_station_bits() {
digitalWrite(PIN_SR_LATCH, LOW);
byte bid, s, sbits;
// Shift out all station bit values
// from the highest bit to the lowest
for(bid=0;bid<=MAX_EXT_BOARDS;bid++) {
if (status.enabled)
sbits = station_bits[MAX_EXT_BOARDS-bid];
else
sbits = 0;
for(s=0;s<8;s++) {
digitalWrite(PIN_SR_CLOCK, LOW);
digitalWrite(PIN_SR_DATA, (sbits & ((byte)1<<(7-s))) ? HIGH : LOW );
digitalWrite(PIN_SR_CLOCK, HIGH);
}
}
digitalWrite(PIN_SR_LATCH, HIGH);
____________________________________________________________________
but i don’t undestand the function of pins PIN_SR_LATCH and PIN_SR_OE that i think to change with my pin outputs that are GPIO 17 (main pump) and GPIO18, GPIO22 and GPIO27 for the three zones. The pins PIN_SR_DATA and PIN_SR_CLOCK are for serial communication with the opensprinkler board, i think…
March 6, 2015 at 4:48 pm #35851
RayKeymasterPIN_SR_LATCH and PIN_SR_OE are pins relevant to the shift register. These don’t matter to you. For example, in the begin() function, comment out all lines that have to do with PIN_SR_LATH, _OE, _DATA, and _CLOCK, and instead, replace them with code that initialize your GPIO pins. Say if you are using GPIO18, GPIO22, GPIO27 for zones 1, 2, 3, just write:
pinMode(GPIO18, OUTPUT);
digitalWrite(GPIO18, LOW);
which sets GPIO18 as an output pin and initializes it to zero. Similar for the other two pins.For apply_all_station_bits(), that function reads out the station status, and pushes out the value to shift registers. You can comment out the entire section and replace it with something like:
byte brd_bits = station_bits[0]; // brd_bits stores the status of the first 8 stations, i.e. those on the main controller
digitalWrite(GPIO18, brd_bits & 0x01); // assigns the status of the first station to GPIO18
digitalWrite(GPIO22, (brd_bits >> 1) & 0x01); // second station to GPIO22
digitalWrite(GPIO27, (brd_bits >> 2) & 0x01); // third station to GPIO27March 10, 2015 at 4:32 am #35936
loop_1ParticipantAh! now i understand… i hope!
I do this:
void OpenSprinkler::begin() {
pinMode(GPIO17, OUTPUT); // pump
digitalWrite(GPIO17, LOW);
pinMode(GPIO18, OUTPUT); // sprinkler 1
digitalWrite(GPIO18, LOW);
pinMode(GPIO22, OUTPUT); // sprinkler 2
digitalWrite(GPIO22, LOW);
pinMode(GPIO27, OUTPUT); // sprinkler 3
digitalWrite(GPIO27, LOW);
// shift register setup
// pinMode(PIN_SR_OE, OUTPUT);
// pull shift register OE high to disable output
// digitalWrite(PIN_SR_OE, HIGH);
// pinMode(PIN_SR_LATCH, OUTPUT);
// digitalWrite(PIN_SR_LATCH, HIGH);
// pinMode(PIN_SR_CLOCK, OUTPUT);
// pinMode(PIN_SR_DATA, OUTPUT);
// Reset all stations
clear_all_station_bits();
apply_all_station_bits();
// pull shift register OE low to enable output
// digitalWrite(PIN_SR_OE, LOW);
// Rain sensor port set up
pinMode(PIN_RAINSENSOR, INPUT);
#if defined(ARDUINO)
digitalWrite(PIN_RAINSENSOR, HIGH); // enabled internal pullup
…….. continue
and:
void OpenSprinkler::apply_all_station_bits() {
byte brd_bits = station_bits[0]; // brd_bits stores the status of the first 8 stations, i.e. those on the main controller
digitalWrite(GPIO17, brd_bits & 0x01); // assigns the status of the first station to GPIO17 for the pump
digitalWrite(GPIO18, (brd_bits >> 1) & 0x01); // first station to GPIO18
digitalWrite(GPIO22, (brd_bits >> 2) & 0x01); // second station to GPIO22
digitalWrite(GPIO27, (brd_bits >> 3) & 0x01); // third station to GPIO27
// digitalWrite(PIN_SR_LATCH, LOW);
// byte bid, s, sbits;
// Shift out all station bit values
// from the highest bit to the lowest
// for(bid=0;bid<=MAX_EXT_BOARDS;bid++) {
// if (status.enabled)
// sbits = station_bits[MAX_EXT_BOARDS-bid];
// else
// sbits = 0;
// for(s=0;s<8;s++) {
// digitalWrite(PIN_SR_CLOCK, LOW);
// digitalWrite(PIN_SR_DATA, (sbits & ((byte)1<<(7-s))) ? HIGH : LOW );
// digitalWrite(PIN_SR_CLOCK, HIGH);
// }
// }
// digitalWrite(PIN_SR_LATCH, HIGH);
}
But i have a lot of problems…
In first, all the relays of the relay board are partial activated (a low light led but the relay don’t active) before to start Opensprinkler….
After the start, i have the sprinkler 1 and 2 always active and the third intermittent any command on the web interface changes anything…
I think that i make some mistakes….
March 10, 2015 at 7:37 pm #35948
RayKeymasterOK, do you know if your relay board is active high or active low logic? In other words, to activate the relay do you set its pin high or low? The reason I am asking is that I know there are many relay boards that are active low logic, in which case you will need to reverse the logic when calling digitalWrite on these pins.
When you said ‘all the relays of the relay board are partial activated (a low light led but the relay don’t active) before to start Opensprinkler….’, do you mean the 3 relays connected to OpenSprinkler, or other, unused relays (i.e. not connected to OpenSprinkler)?
March 11, 2015 at 2:13 am #35953
loop_1ParticipantI have a 4 relay board: no. 1 for the pump and no. 2-3-4 for the sprinklers.
if the relay board is low or high logic is sufficient change the digitalwrite LOW or HIGH but the problem is that i have 2 relays always active a few seconds after opensprinkler starts and one relay is intermittent… so i think that if the problem is only the logic of the board i must have all relays ON or all relays OFF, is correct?
So i think that there are some mistakes in my code…
Moreover, before start opensprinkler i see that all 4 relays of the relay board are not activated but the leds are light on (partially) I think that there isn’ta sufficient current in order to activate all relay at the same time…
On the same machine (there is only the raspi OS) with the Rich’s sprinklers_pi i don’t have this issue…
March 19, 2015 at 2:12 am #36108
loop_1Participantanyone? 🙁
March 19, 2015 at 8:47 am #36109
RayKeymasterWell, since you are using your own hardware, it’s difficult for me to help you diagnose. I think the issue boils down to activating your relay board — you can write a very simple program to test if each GPIO pin can activate the relay board. If this works, then it’s just the matter of plugging in this code to the OpenSprinkler firmware code, the rest of the firmware code should work as is.
-
AuthorPosts
- You must be logged in to reply to this topic.
OpenSprinkler › Forums › Hardware Questions › Alternative hardware