Changeset 7 for trunk/Arduino/projects/OT_boiler/OT_boiler.ino
- Timestamp:
- Jun 28, 2019, 1:07:05 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/Arduino/projects/OT_boiler/OT_boiler.ino (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Arduino/projects/OT_boiler/OT_boiler.ino
r3 r7 1 1 #include <SPI.h> 2 2 #include <Ethernet.h> 3 #include <opentherm.h> 4 5 #define THERMOSTAT_IN 2 6 #define THERMOSTAT_OUT 4 3 #include <ot_slave_2.h> 7 4 8 5 byte mac[] = { 0x02, 0xDE, 0xAD, 0xDE, 0xAD, 0x01 }; … … 12 9 volatile bool _connected = false; 13 10 14 O penthermData message;11 OT_V2R2_Slave boiler; 15 12 16 13 EthernetClient client; … … 18 15 void setup() 19 16 { 20 pinMode(THERMOSTAT_IN, INPUT); 21 digitalWrite(THERMOSTAT_OUT, HIGH); 22 pinMode(THERMOSTAT_OUT, OUTPUT); // low output = high current, high output = low current 17 boiler.Setup(); 23 18 24 19 // Console … … 51 46 void loop() 52 47 { 48 /* 53 49 Serial.print("["); 54 50 Serial.print(++loops); … … 56 52 Serial.print(state,HEX); 57 53 Serial.println("]"); 54 */ 58 55 maintainEthernet(); 59 if (OPENTHERM::getMessage(message)) { 60 Serial.print("-> "); 61 OPENTHERM::printToSerial(message); 62 Serial.println(); 63 Sent_OT_Data(message); 64 65 delay(100); // Opentherm defines delay between request and response 66 message.type = OT_MSGTYPE_UNKNOWN_DATAID; // construct fake response 67 message.valueHB = 0; 68 message.valueLB = 0; 69 OPENTHERM::send(THERMOSTAT_OUT, message, listenAfterResponse); // send some response and wait for antoher request from thermostat set by callback 70 } else { 71 if (OPENTHERM::isSent() || OPENTHERM::isIdle() || OPENTHERM::isError()) { // wait for request from thermostat 72 OPENTHERM::listen(THERMOSTAT_IN, -1); 73 } 74 OpenthermData dummy; 75 dummy.type = OT_MSGTYPE_UNKNOWN_DATAID; 76 dummy.id = OT_MSGID_STATUS; 77 dummy.valueHB = (loops >> 8) & 0xFF; 78 dummy.valueLB = loops & 0xFF; 79 Sent_OT_Data(dummy); 80 } 56 boiler.Loop(); 57 /* 81 58 delay(1000); 59 */ 82 60 } 83 61 … … 132 110 } 133 111 } 134 135 void listenAfterResponse () {136 Serial.print("<- ");137 OPENTHERM::printToSerial(message);138 Serial.println();139 Serial.println();140 OPENTHERM::listen(THERMOSTAT_IN, -1);141 }
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/trac/Paradigma/chrome/site/paradigma.png)