Domoticz and heater



  • Hi,
    How can I set setpoint from domoticz. I tried with gw.present(7, S_HEATER). I see in hardware that S_HEATER is present but there is no device reported. Also on that same node I have one dht22 and ds18s20 sensors and in domoticz humidity is reported on both sensors. Is there a way to send values so that domoticz separates them (I tried setting same child for temp and hum from dht22 and other id for ds18s20 but again I get combined temp/hum for both sensors)


  • Hardware Contributor

    Hi

    1. the node is not presented until the first value is reported - maybe thats the problem, try to send the current heater value on startup.
    2. I dont know, tried as well but didnt find any sollution.


  • You were right. It works now. Thank you.



  • Hello,

    Have you (or anyone else here) figured out the solution for 2nd problem (humidity reported for both sensors DTH22 and DS18S20 when in same node)? I have node with DTH22 for indoor temp/hum and DS18S20 for outdoor temp and get outdoor temp with indoor humidity in the Domoticz graph. 😞


  • Hardware Contributor

    @jlehtinen - Are they connected to the same node (ie presented as the same nodeid)? If so they will be merged as a weatherstation and presented as one. Thats how Domoticz i made and i dont know any sollution for this... there is a ongoing discussion at the moment on Domoticz forum about this and wind meter.



  • Yes, both sensor DTH22 and DS18S20 are connected to same physical node i.e. are reporting using same nodeid. OK, so the easiest solution is not to mix multiple temp and humidity sensors in same physical node. Time to built a dedicated node for outdoor temp. Thanks @sundberg84! 👍



  • @sundberg84 , @jlehtinen

    I've solved this problem with a LUA script in Domoticz. The script copies the values of temperature and humidity to a TEXT sensor (as a string). In the Arduino sketch (you need the MySensors development branch) the string is split in 2 separate values (Strings). Works like a charm.

    LUA script:

    
       tempString = ""
       stringReturn = ""
       sensor = '103OutsideTempHum'
       tempString = otherdevices_svalues[sensor]
    
       sep = ";"
       i=1
    
       for str in string.gmatch(tempString, "([^"..sep.."]+)") do
          stringReturn = stringReturn .. str .. "#"
          i = i + 1
       end
    
    commandArray = {}
    
       time = os.date("*t")
       if ((time.min % 5)==0) then--run script every 5 minutes
       commandArray[1] = {['UpdateDevice'] = 77 .. '|0|' .. tostring(stringReturn)} -- 77 = idx of TEXT sensor in Domoticz
       end
    
    return commandArray
    
    

    Arduino sketch:

    
    #include <SPI.h>
    #include <TFT_ILI9341.h>
    #include <MySensor.h> 
    
    #define MY_RADIO_NRF24
    #define CHILD_ID_TEXT 1
    #define CHILD_ID_BUTTON 2
    
    #define MIN_V 2600
    #define MAX_V 3200
    
    #define sclk 13  // Don't change
    #define mosi 11  // Don't change
    #define cs   17
    #define dc   16
    #define rst  15  // you can also connect this to the Arduino reset
    
    TFT_ILI9341 tft = TFT_ILI9341();
    
    void Button() {}
    
    int interrupt;
    String tempSensor;
    byte batteryPcnt;
    
    MyMessage msgTemp(CHILD_ID_TEXT, V_TEXT);
    MyMessage msgButton(CHILD_ID_BUTTON, V_STATUS);
    
    void presentation() 
    {
      sendSketchInfo("103 TEST", "1.0");
      present(CHILD_ID_TEXT, S_INFO);
      present(CHILD_ID_BUTTON, S_BINARY);
    } 
    
    void setup()
    { 
      Serial.begin(9600);
      pinMode(4, OUTPUT);
      digitalWrite(4, HIGH);
      
      pinMode(3, INPUT_PULLUP); // int 1 used by button
     
      attachInterrupt(digitalPinToInterrupt(3), Button,FALLING);
    }
    
    
    void loop() 
    {
      if(interrupt == 1)
      {  
        send(msgButton.set(1));  
        request(CHILD_ID_TEXT, V_TEXT);
        batteryPcnt = min(map(readVcc(), MIN_V, MAX_V, 0, 100), 100);
        sendBatteryLevel(batteryPcnt);
        wait(500);
        Screen();
        
        send(msgButton.set(0));
      }
      
      digitalWrite(rst, LOW);
      digitalWrite(4, HIGH);   
      wait(10);
    
      interrupt = sleep(1,FALLING);
    }
    
    void receive(const MyMessage &message) 
    {
      if (message.sensor == 1) 
      {
        tempSensor = message.getString();
      } 
      wait(200);
    }
    
    //====== Show screen after hitting button ==============================
    void Screen() 
    {
      digitalWrite(4, LOW);
      wait(10);
      tft.init();
      tft.setRotation(2);    
      
      char c_tmp[6];
      char c_hum[6];
    
      int sepIndex1 = tempSensor.indexOf('#');
      int sepIndex2 = tempSensor.indexOf('#',sepIndex1+1);
      String tmp = tempSensor.substring(0,sepIndex1);
      String hum = tempSensor.substring(sepIndex1+1,sepIndex2);
      
      tft.fillScreen(ILI9341_BLACK);
      wait(5);//don't touch this!!
      tft.setTextSize(1);
    
      tft.fillRoundRect(5, 5, 230, 180, 10, ILI9341_WHITE);
      tft.setTextColor(ILI9341_BLUE);
      tmp.toCharArray(c_tmp, 6); 
      tft.drawCentreString(c_tmp,120,50,8);
    
      tft.fillRoundRect(5, 190, 230, 90, 10, ILI9341_WHITE);
      tft.setTextColor(ILI9341_BLACK);
      tft.setCursor(10,200,4);
      tft.print("Humidity "); 
      tft.setTextColor(ILI9341_BLUE);
      tft.setCursor(120,200,4);
      hum.toCharArray(c_hum, 6); 
      tft.print(c_hum); tft.print(" %");
      tft.setCursor(200,245,4);
      tft.print(batteryPcnt); 
      wait(15000L); 
    }
    
    long readVcc() {
      // Read 1.1V reference against AVcc
      // set the reference to Vcc and the measurement to the internal 1.1V reference
      #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
        ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
        ADMUX = _BV(MUX5) | _BV(MUX0);
      #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
        ADMUX = _BV(MUX3) | _BV(MUX2);
      #else
        ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
      #endif                 
     
      delay(2); // Wait for Vref to settle
      ADCSRA |= _BV(ADSC); // Start conversion
      while (bit_is_set(ADCSRA,ADSC)); // measuring
     
      uint8_t low  = ADCL; // must read ADCL first - it then locks ADCH  
      uint8_t high = ADCH; // unlocks both
     
      long result = (high<<8) | low;
     
      result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
      return result; // Vcc in millivolts
    }
    
    


  • Thanks @HarryDutch! Good to know that there is a way around this hum temp issue. 👍


Log in to reply
 

Suggested Topics

  • 5
  • 8
  • 2
  • 1
  • 5
  • 2

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts