Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <max6675.h>
- #include <ESPArto.h>
- ESPARTO_CONFIG_BLOCK cb={
- {CONFIG(ESPARTO_SSID),"MELINET"},
- {CONFIG(ESPARTO_PASSWORD),"THISISMYNETWORK"},
- {CONFIG(ESPARTO_DEVICE_NAME),"Burn"},
- {CONFIG(ESPARTO_WEB_USER),"admin"},
- {CONFIG(ESPARTO_WEB_PASS),"admin"},
- {CONFIG(ESPARTO_MQTT_SRV),"192.168.0.12"}, // can also be domain name
- {CONFIG(ESPARTO_MQTT_PORT),"1883"}, // note it is still a string
- {CONFIG(ESPARTO_MQTT_USER),""}, // can omit
- {CONFIG(ESPARTO_MQTT_PASS),""}, // can omit
- {CONFIG(ESPARTO_WILL_TOPIC),"lwt"}, // can omit
- {CONFIG(ESPARTO_WILL_MSG),"Esparto has crashed!"} // can omit
- };
- ESPArto Esparto(cb);
- // Global variables
- // Pin definitions
- int const thermoDO = D5;
- int const thermoCLK = D3;
- int const thermoCS_0 = D0;
- int const oneWireBus = D7;
- int const pumpRelay = D8;
- int const fanRelay = D6;
- int const fanSwitch = D4;
- // Constants
- #define debounce 20 // debounce value in ms
- #define frequency 100
- // functions for handling fan switch press
- void shortPress(int hilo, int unused){
- // Turn fan on
- Esparto.logicalWrite(fanRelay,ON);
- }
- void longPress(int hilo, int unused){
- // Turn fan off
- Esparto.logicalWrite(fanRelay,OFF);
- }
- void progress(int stage, int unused){}
- // Functions for handling flue temperature
- MAX6675 t0(thermoCLK, thermoCS_0, thermoDO);
- int const pumpOnTemp = 60;
- void flueCheck(){
- Esparto.publish("hello/world", "boo");
- Serial.println("Doing flue temp check");
- int flueTemp = t0.readCelsius();
- if (flueTemp >= pumpOnTemp){
- Esparto.logicalWrite(pumpRelay, ON);
- }else if(flueTemp < (pumpOnTemp * 0.6)){
- Esparto.logicalWrite(pumpRelay, OFF);
- Esparto.logicalWrite(fanRelay, OFF);
- }
- }
- void onMqttConnect(void){
- Serial.println("MQTT connected");
- }
- void setupHardware() {
- Serial.begin(115200);
- //ESPARTO_HEADER(Serial); // not necessary, just helps does the Serial begin for you
- // define BUILTIN_LED as output. Most ESP8266 have LED as "active LOW" i.e. it is ON when pin is 0
- // and is OFF when pin is 1
- // Turn of BUILTIN_LED as it needs to be an input for the switch!
- //Esparto.Output(BUILTIN_LED);
- // Fan switch
- Esparto.Output(fanRelay, HIGH, OFF);
- Esparto.MultiStage(fanSwitch,INPUT,debounce,frequency, // notify every 100ms
- progress,
- {
- {1000,shortPress}, // anything up to 1sec is "short"
- {5000,longPress} // 1s - 5s is "long"
- }
- );
- // Flue thermocouple
- Esparto.Output(pumpRelay, HIGH, OFF);
- Esparto.every(10000,flueCheck);
- //Esparto.flashLED(1000);
- Serial.println("Hello world");
- ESPARTO_CONFIG_BLOCK::iterator it = cb.begin();
- while(it != cb.end()){
- Serial.println(it->first.c_str());
- Serial.println(it->second.c_str());
- it++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement