Ignore:
Timestamp:
Jun 28, 2019, 1:07:05 AM (7 years ago)
Author:
markus
Message:
  • Moving class OT_V2R2_Slave to library "ot_slave_2"
  • Modified sketch OT_boiler for first combined prototype OT + ETH


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Arduino/projects/OT_boiler/OT_boiler.ino

    r3 r7  
    11#include <SPI.h>
    22#include <Ethernet.h>
    3 #include <opentherm.h>
    4 
    5 #define THERMOSTAT_IN 2
    6 #define THERMOSTAT_OUT  4
     3#include <ot_slave_2.h>
    74
    85byte  mac[] = { 0x02, 0xDE, 0xAD, 0xDE, 0xAD, 0x01 };
    … …  
    129volatile bool  _connected = false;
    1310
    14 OpenthermData message;
     11OT_V2R2_Slave boiler;
    1512
    1613EthernetClient client;
    … …  
    1815void setup()
    1916{
    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();
    2318
    2419  // Console
    … …  
    5146void loop()
    5247{
     48/*
    5349  Serial.print("[");
    5450  Serial.print(++loops);
    … …  
    5652  Serial.print(state,HEX);
    5753  Serial.println("]");
     54*/
    5855  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/*
    8158  delay(1000);
     59*/
    8260}
    8361
    … …  
    132110    }
    133111}
    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.