Open aviateur17 opened 5 months ago
Yeah, I see those lines are missing, not sure how that happened. Trying to see if I can fix that and then look at the checkCoils() function.
I can't figure out checkCoils. It seems like it should be showing me 1 as the status of the "off" ones, but they are all showing 0. Using the GET command retrieves the correct pin status, which confuses me even more. Here's the readout after setting a value. Everything works, and the relay clicks on:
20:58:21.738 -> [2] Incoming ESP-NOW DataReading from 0x1
20:58:21.738 -> [1] Received SET cmd. Address: 102 value: 15.00
20:58:21.738 -> [1] Address 102 coil pin 17 on.
20:58:21.738 -> [1] Address 102 coil pin 17 on for 15 seconds.
20:58:21.738 -> Id: 101 - Type: 0 - Data loaded: 0.00
20:58:21.738 -> Id: 102 - Type: 0 - Data loaded: 0.00
20:58:21.738 -> Id: 103 - Type: 0 - Data loaded: 0.00
20:58:21.738 -> Id: 104 - Type: 0 - Data loaded: 0.00
20:58:21.738 -> Sending FDRS Packet!
20:58:21.738 -> Packet received by gateway
20:58:37.175 -> Id: 102 - Type: 0 - Data loaded: 1.00
20:58:37.176 -> [1] Address 102 coil pin 17 turned off.
20:58:37.176 -> Sending FDRS Packet!
20:58:37.176 -> Packet received by gateway
Ope, found it! It was the tiniest parenthesis misplacement on line 120. Should be if (digitalRead(cont[i].coilPin) == HIGH){
. There is another change I'm going to try later today, essentially I want to change to this:
typedef struct irrigController
{
uint address;
int coilPin;
bool updatePending = false;
unsigned long status = 0;
} irrigController;
So that the initialization can look like this:
irrigController cont[] = {
[0] = { .address = CONTROL_1, .coilPin = COIL_1 },
[1] = { .address = CONTROL_2, .coilPin = COIL_2 },
[2] = { .address = CONTROL_3, .coilPin = COIL_3 },
[3] = { .address = CONTROL_4, .coilPin = COIL_4 },
I'd also like to change cont
to... not sure maybe coils
?
When it turns off a pin using the timer, then sends back the status: I think the status should be read from the pin like in other cases. I don't know if that feature will ever be useful, but hypothetically maybe there's a leak and the relay board malfunctions. If the relay/solenoid was still powered somehow after we changed the IO to off, that would be incredibly good to know.
I just published this branch with the updated irrigation sketch and all of the changes I discussed above. You can just copy it into here if it all looks good to you.
Timm, thanks for that example in your branch. I think those last two commits should have everything. Let me know if you see any issues.
Something's still wrong with this from my mistake I think.... The sketch is still messed up, for example it doesn't have the definition for
irrigController
. I'll post your complete and updated sketch below for reference. Sorry again for the hassle.Your new sketch seems to work great, except that it doesn't seem to send back accurate pin statuses in checkCoils(). I'll keep looking into that.