OpenSprinkler Forums Hardware Questions Alternative hardware Reply To: Alternative hardware

#35936

loop_1
Participant

Ah! 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….