Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. Weather Station with Scene Activator!!!

Weather Station with Scene Activator!!!

Scheduled Pinned Locked Moved My Project
51 Posts 3 Posters 30.2k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • BulldogLowellB BulldogLowell

    I added delays in the lua code and that seemed to help a lot:

    local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 60)
    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_1", value=temp}, 85)
    
    luup.sleep(750)
    
    local humid = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1","CurrentLevel", 63)
    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_2", value=humid}, 85)
    
    luup.sleep(750)
    
    local low = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61)
    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_3", value=low}, 85)
    
    luup.sleep(750)
    
    local high = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 62)
    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_4", value=high}, 85)
    
    luup.sleep(750)
    
    local conditions = luup.variable_get("urn:upnp-org:serviceId:Weather1","CurrentTemperature", 59)
    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 85)
    

    still struggling with this, however:

    if (message.type == V_VAR5)
    {
      conditions = String(message.data);
      DEBUG_PRINT(F("Received today's Conditions:"));
      DEBUG_PRINTLN(conditions);
    }
    

    not returning the present conditions....

    korttomaK Offline
    korttomaK Offline
    korttoma
    Hero Member
    wrote on last edited by
    #21

    @BulldogLowell

    I do have all 5 variables listed under my scene-controler device. Do you still get the failed for getting time in your serial print? Seems like you might have "general" communication issues, you have cap on the radio? Try a different power source or temporarily move your device closer to the gateway. I had some similar problems when trying to use the PA+LNA radio module so I switched to a regular one and that one works fine. I wanted to use the PA+LNA version because the device is quite far from GW and I did not think the regular one could handle the distance but it did.

    Thanks for showing me how to add a delay to the lua code btw, I newer figured that out so I only ewer sent two variables at a time. Btw, does the delay affect vera in any way? I thought I read somewhere that the unit does not do anything during sleep.

    • Tomas
    1 Reply Last reply
    0
    • BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by BulldogLowell
      #22

      Tomas,

      (and I'm opening this up to anyone who knows how to work messages into more than one device )

      well, I figured out the problem of "conditions" which was the wrong serviceId in the lua coding for that variable.

      Regarding the delay, if you luup.sleep() for anything that approaches a second, your Vera will restart :( so I figure that the 750ms would be OK. I am concerned about it being incommunicado so often, so I'll probably put the transmissions into different scenes.

      I definitely have a communication issue... and it bothers me a bit. I have all that, capacitors on the antenna, etc. I think I have a bad node and its likely my PhoneyTV. Whenever I 'manually' toggle the lights using the Vera interface, it seems to lock up the gateway.... More on that to come.

      I really appreciate your sharing the code. In retrospect, it seems that the latest mySensors implementation is a lot more elegant with respect to setting up communications like these, but the example helped immensely.

      I'm now tripping up on using variables in the second device: Can I recycle the variables here (e.g. V_VAR1) or must I create another instance of gw?

      MySensor gw;
      DHT dht;
      //
      MyMessage msgOn(CHILD_ID_SCENE, V_SCENE_ON);
      MyMessage msgOff(CHILD_ID_SCENE, V_SCENE_OFF);
      MyMessage msgVAR1(CHILD_ID_SCENE, V_VAR1);// outdoor temperature
      MyMessage msgVAR2(CHILD_ID_SCENE, V_VAR2);// outdoor humidity
      MyMessage msgVAR3(CHILD_ID_SCENE, V_VAR3);//today's low
      MyMessage msgVAR4(CHILD_ID_SCENE, V_VAR4);// today's high
      MyMessage msgVAR5(CHILD_ID_SCENE, V_VAR5);//conditions
      //
      MyMessage lightMsg(CHILD_ID_LED, V_LIGHT);
      //MyMessage msgMOTD(CHILD_ID_LED, V_VAR1); // message of the day//<<<<<<<<<<<<<<<<<
      //MyMessage msgAlarm(CHILD_ID_LED, V_VAR2); // alarm status//<<<<<<<<<<<<<<<<<<<<<<<<
      //MyMessage msgBrite(CHILD_ID_LED, V_VAR3); // led briteness (nice idea!!!!)<<<<<<<<<<<<<<<
      //
      

      setup() bit:

         //
        dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
        gw.begin(getVariables, RADIO_ID);
        gw.sendSketchInfo("WeatherClock", "1.0");
        gw.present(CHILD_ID_SCENE, S_SCENE_CONTROLLER);
        gw.present( CHILD_ID_LED, S_LIGHT);
        int clockTimer;
      

      used here:

      void getVariables(const MyMessage &message)
      {  
        if (message.type == V_VAR1)
        {
          OutdoorTemp = atoi(message.data);
          DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
          DEBUG_PRINTLN(OutdoorTemp);
        }
        if (message.type == V_VAR2)
        {
          OutdoorHumidity = atoi(message.data);
          DEBUG_PRINT(F("OutdoorHumidity recieved:"));
          DEBUG_PRINTLN(OutdoorHumidity);
         }
         if (message.type == V_VAR3)
        etc...
      

      any advice?

      best,

      Jim

      1 Reply Last reply
      0
      • korttomaK Offline
        korttomaK Offline
        korttoma
        Hero Member
        wrote on last edited by
        #23

        Did not try it but how about this:

        void getVariables(const MyMessage &message)
            {
                if (message.sensor==CHILD_ID_SCENE){  
                    if (message.type == V_VAR1){
                        OutdoorTemp = atoi(message.data);
                        DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
                        DEBUG_PRINTLN(OutdoorTemp);
                   }
                   if (message.type == V_VAR2){
                       OutdoorHumidity = atoi(message.data);
                       DEBUG_PRINT(F("OutdoorHumidity recieved:"));
                       DEBUG_PRINTLN(OutdoorHumidity);
                  }
                  if (message.type == V_VAR3)
                      etc...
        
                if (message.sensor==CHILD_ID_LED){  
                    if (message.type == V_VAR1){
                        DayMessage = atoi(message.data);
                        DEBUG_PRINTLN(DayMessage);
                   }
                   if (message.type == V_VAR2){
                       AlarmStatus = atoi(message.data);
                       DEBUG_PRINT(F("House is:"));
                       DEBUG_PRINTLN(AlarmStatus);
                  }
                  if (message.type == V_VAR3)
                     etc...
        
        • Tomas
        BulldogLowellB 1 Reply Last reply
        0
        • korttomaK korttoma

          Did not try it but how about this:

          void getVariables(const MyMessage &message)
              {
                  if (message.sensor==CHILD_ID_SCENE){  
                      if (message.type == V_VAR1){
                          OutdoorTemp = atoi(message.data);
                          DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
                          DEBUG_PRINTLN(OutdoorTemp);
                     }
                     if (message.type == V_VAR2){
                         OutdoorHumidity = atoi(message.data);
                         DEBUG_PRINT(F("OutdoorHumidity recieved:"));
                         DEBUG_PRINTLN(OutdoorHumidity);
                    }
                    if (message.type == V_VAR3)
                        etc...
          
                  if (message.sensor==CHILD_ID_LED){  
                      if (message.type == V_VAR1){
                          DayMessage = atoi(message.data);
                          DEBUG_PRINTLN(DayMessage);
                     }
                     if (message.type == V_VAR2){
                         AlarmStatus = atoi(message.data);
                         DEBUG_PRINT(F("House is:"));
                         DEBUG_PRINTLN(AlarmStatus);
                    }
                    if (message.type == V_VAR3)
                       etc...
          
          BulldogLowellB Offline
          BulldogLowellB Offline
          BulldogLowell
          Contest Winner
          wrote on last edited by
          #24

          @korttoma

          thanks, I'll give it a shot.

          another method for dispatching messages (with delays in between) from Vera with this type of lua function:

          (thanks to @RexBeckett for the assistance)

          function SendWeatherData(strstep)
          	local step = tonumber(strstep)
          	if step == 1 then
          		local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 60)
          		luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_1", value=temp}, 85)
          	elseif step == 2 then
          		local humid = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1","CurrentLevel", 63)
          		luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_2", value=humid}, 85)
          	elseif step == 3 then
          		local low = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61)
          		luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_3", value=low}, 85)
          	elseif step == 4 then
          		local high = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 62)
          		luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_4", value=high}, 85)
          	elseif step == 5 then
          		local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition", 59)
          		luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 85)
          	end
          	step = step + 1
          	if step <= 5 then
          		luup.call_delay(1,tostring(step))
          	end
          end
          
          SendWeatherData("1")
          
          1 Reply Last reply
          0
          • korttomaK Offline
            korttomaK Offline
            korttoma
            Hero Member
            wrote on last edited by
            #25

            wow, don't understand what that lua function does but I'll give it a try. Thanks @RexBeckett

            • Tomas
            BulldogLowellB 3 Replies Last reply
            0
            • korttomaK korttoma

              wow, don't understand what that lua function does but I'll give it a try. Thanks @RexBeckett

              BulldogLowellB Offline
              BulldogLowellB Offline
              BulldogLowell
              Contest Winner
              wrote on last edited by
              #26

              @korttoma

              "The following code calls the function SendWeatherData immediately and the function calls itself with a one second delay. Each time the function runs, it uses a step counter to chose a value to be read and sent. The step gets incremented on each run until it exceeds five after which the function stops calling itself." - rex

              This way, it shouldn't affect vera's watchdog.

              Rex is really helpful on matters of lua ;)

              1 Reply Last reply
              0
              • korttomaK korttoma

                wow, don't understand what that lua function does but I'll give it a try. Thanks @RexBeckett

                BulldogLowellB Offline
                BulldogLowellB Offline
                BulldogLowell
                Contest Winner
                wrote on last edited by
                #27

                @korttoma

                I was thinking that perhaps it may be easier/better to recycle V_VAR1 and transmit messages to the node with a leading char. then have the arduino sort out the message based on the header:

                for example:

                local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition", 59)
                conditions = "#" .. conditions
                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 85)
                

                then sort and strip out the char arduino-side... you could move a lot more message types through one variable

                new message types need to be hard coded into Arduino and Vera, so if we want to expand the data flow... it becomes easier this way, no? Perhaps there is a better message type to use for this type of effort...

                This device is in our guest house and since I have it open I want to add capabilities like:

                1: Message of the day
                2: quick SMS type of message
                3: alarm clock settable by mobile app
                4: twitter feed

                stuff like that...

                1 Reply Last reply
                0
                • korttomaK korttoma

                  wow, don't understand what that lua function does but I'll give it a try. Thanks @RexBeckett

                  BulldogLowellB Offline
                  BulldogLowellB Offline
                  BulldogLowell
                  Contest Winner
                  wrote on last edited by BulldogLowell
                  #28

                  @korttoma

                  Tomas, I just wanted to say thanks for the help. My (almost 100% completed) code is here and a couple of videos showing how it works:

                  first

                  link text

                  #define STATES 7
                  #define HUMIDITY_SENSOR_DIGITAL_PIN 4
                  #define DEBUG
                  
                  #ifdef DEBUG
                  #define DEBUG_SERIAL(x) Serial.begin(x)
                  #define DEBUG_PRINT(x) Serial.print(x)
                  #define DEBUG_PRINTLN(x) Serial.println(x)
                  #else
                  #define DEBUG_SERIAL(x)
                  #define DEBUG_PRINT(x) 
                  #define DEBUG_PRINTLN(x) 
                  #endif
                  
                  #include <avr/pgmspace.h>
                  #include <Wire.h>
                  #include <Time.h>
                  #include <SPI.h>
                  #include <MySensor.h>
                  #include <LiquidCrystal_I2C.h>
                  #include <DHT.h> 
                  //
                  #define RADIO_ID 11
                  #define CHILD_ID_SCENE 3
                  #define CHILD_ID_LED 4
                  //
                  LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
                  //
                  void (*lcdDisplay[STATES])();
                  //
                  byte state = 0;
                  byte lastState;
                  byte timeCounter = 0;
                  unsigned long lastTime;
                  unsigned long refreshInterval = 3000UL;
                  unsigned long lastClockSet;
                  boolean isMessage = false;
                  float insideTemperature;
                  float humidity;
                  int OutdoorTemp = -99;
                  int OutdoorHumidity = -99;
                  int todayHigh = -99; 
                  int todayLow = -99;
                  String conditions = "Not yet Reported";
                  String tomorrowWeather = "Not yet Reported";
                  String messageOfTheDay = "**Hello There!**";
                  unsigned long motdTimer;
                  int ledStatus;// to toggle LCD backlight led
                  boolean buttonPushed = false;
                  //
                  MySensor gw;
                  DHT dht;
                  //
                  MyMessage msgOn(CHILD_ID_SCENE, V_SCENE_ON);
                  MyMessage msgOff(CHILD_ID_SCENE, V_SCENE_OFF);
                  MyMessage msgVAR1(CHILD_ID_SCENE, V_VAR1);// outdoor temperature
                  MyMessage msgVAR2(CHILD_ID_SCENE, V_VAR2);// outdoor humidity
                  MyMessage msgVAR3(CHILD_ID_SCENE, V_VAR3);//today's low
                  MyMessage msgVAR4(CHILD_ID_SCENE, V_VAR4);// today's high
                  MyMessage msgVAR5(CHILD_ID_SCENE, V_VAR5);//conditions
                  //
                  MyMessage lightMsg(CHILD_ID_LED, V_LIGHT);
                  MyMessage msgMOTD(CHILD_ID_LED, V_VAR1); // message of the day
                  MyMessage msgAlarm(CHILD_ID_LED, V_VAR2); // alarm status
                  MyMessage msgBrite(CHILD_ID_LED, V_VAR3); // led briteness (nice idea!!!!)
                  //
                  void setup()  
                  { 
                    DEBUG_SERIAL(115200);
                    DEBUG_PRINTLN(F("Serial started"));
                    attachInterrupt(1, PushButton, CHANGE);
                    //
                    lcdDisplay[0] = lcdDisplay0;
                    lcdDisplay[1] = lcdDisplay1;
                    lcdDisplay[2] = lcdDisplay2;
                    lcdDisplay[3] = lcdDisplay3;
                    lcdDisplay[4] = lcdDisplay4;
                    lcdDisplay[5] = lcdDisplay5;
                    lcdDisplay[6] = lcdDisplay6;
                    //
                    dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
                    gw.begin(getVariables, RADIO_ID);
                    gw.sendSketchInfo("WeatherClock", "1.0");
                    gw.present(CHILD_ID_SCENE, S_SCENE_CONTROLLER);
                    gw.present( CHILD_ID_LED, S_LIGHT);
                    //
                    lcd.init();
                    lcd.clear();
                    lcd.backlight();
                    lcd.setCursor(0, 0);
                    lcd.print("Syncing Time");
                    lcd.setCursor(0, 1);
                    int clockCounter = 0;
                    while(timeStatus() == timeNotSet && clockCounter < 60)
                    {
                      gw.process();
                      gw.requestTime(receiveTime);
                      Serial.println("getting Time");
                      delay(1000);
                      lcd.print(".");
                      clockCounter++;
                      if (clockCounter > 16)
                      {
                        lcd.clear();
                        lcd.print(F("**Failed Clock**"));
                        lcd.setCursor(0,1);
                        lcd.print(F("*Syncronization*"));
                        delay(2000);
                        break;
                      }
                    }
                    lcd.clear();
                    lastTime = millis();
                  }
                  void loop()      
                  {
                    gw.process();
                    if (millis() - lastClockSet >= 60000UL)
                    {
                      gw.requestTime(receiveTime);
                      lastClockSet = millis();
                    }
                    if (millis() - lastTime >= refreshInterval)
                    {
                      state++;
                      if (state > STATES - 1) state = 0;
                      DEBUG_PRINTLN(F("State:")); 
                      DEBUG_PRINTLN(state);
                      lastTime += refreshInterval;
                      getTempHumidity();
                    }
                    if (state != lastState) 
                    {
                      fastClear();
                      lcdDisplay[state]();
                    }
                    lastState = state;
                    if (buttonPushed)
                    {
                      activateScene();
                    }
                    if (isMessage)
                    {
                      if (millis() - motdTimer > 86400 * 1000UL)
                      {
                        isMessage = false;
                      }
                    }
                  }
                  void fastClear()
                  {
                    lcd.setCursor(0,0);
                    lcd.print("                ");
                    lcd.setCursor(0,1);
                    lcd.print("                ");
                  }
                  //
                  void lcdDisplay0()
                  {
                    lcd.setCursor(0,0);
                    lcd.print(F("Time: "));
                    if (hourFormat12() < 10) lcd.print("0");
                    lcd.print(hourFormat12());
                    lcd.print(":");
                    if (minute() < 10) lcd.print("0");
                    lcd.print(minute());
                    if (isAM()) lcd.print(F("am"));
                    else lcd.print(F("pm"));
                    DEBUG_PRINT(F("Time:"));
                    DEBUG_PRINTLN(hourFormat12());
                    lcd.setCursor(0,1);
                    lcd.print(F("Date: "));
                    if (month() < 10) lcd.print("0");
                    lcd.print(month());
                    lcd.print("/");
                    if (day() < 10) lcd.print("0");
                    lcd.print(day());
                    lcd.print("/");
                    lcd.print(year());
                    DEBUG_PRINTLN(F("Date: ")); 
                    DEBUG_PRINT(month()); 
                    DEBUG_PRINT("/"); 
                    DEBUG_PRINT(day()); 
                    DEBUG_PRINT("/"); 
                    DEBUG_PRINTLN(year());
                  }
                  void lcdDisplay1()
                  {
                    lcd.setCursor(0,0);
                    lcd.print(F(" Indoor Temp:"));
                    lcd.print(int(round(insideTemperature)));
                    lcd.print(char(223));
                    DEBUG_PRINT(F("Indoor Temp:")); 
                    DEBUG_PRINT(int(round(insideTemperature))); 
                    DEBUG_PRINTLN(F("F"));
                    lcd.setCursor(0,1);
                    lcd.print("    Humidity:");
                    lcd.print(int(round(humidity)));
                    lcd.print(F("%"));
                    DEBUG_PRINT("   Humidity:");
                    DEBUG_PRINT(int(round(humidity)));
                    DEBUG_PRINTLN(F("F"));
                  }
                  void lcdDisplay2()
                  {
                    lcd.setCursor(0,0);
                    lcd.print("Outdoor Temp:"); 
                    lcd.print(OutdoorTemp); 
                    lcd.print(char(223));
                    DEBUG_PRINT(F("Outdoor Temp:"));
                    DEBUG_PRINTLN(OutdoorTemp);
                    lcd.setCursor(0,1);
                    lcd.print(F("    Humidity:")); 
                    lcd.print(OutdoorHumidity); 
                    lcd.print(F("%"));
                    DEBUG_PRINT(F("    Humidity:"));
                    DEBUG_PRINTLN(OutdoorHumidity);
                  }
                  void lcdDisplay3()
                  {
                    lcd.setCursor(0,0);
                    lcd.print(F("Today's High:"));
                    lcd.print(todayHigh); 
                    lcd.print(char(223));
                    DEBUG_PRINT(F("Today's High: "));
                    DEBUG_PRINTLN(todayHigh);
                    lcd.setCursor(0,1);
                    lcd.print(F("         Low:"));
                    lcd.print(todayLow); 
                    lcd.print(char(223));
                    DEBUG_PRINT(F("Today's Low: "));
                    DEBUG_PRINTLN(todayLow);
                  }
                  void lcdDisplay4()
                  {
                    lcd.setCursor(0,0);
                    lcd.print(F("Today's Weather"));
                    DEBUG_PRINTLN(F("Today's Weather: "));
                    lcd.setCursor(0,1);
                    lcd.print(conditions);
                    DEBUG_PRINTLN(conditions);
                  }
                  void lcdDisplay5()
                  {
                    lcd.setCursor(0,0);
                    lcd.print(F("Forcast Tomorrow"));
                    DEBUG_PRINTLN(F("Tomorrow's Forecast: "));
                    lcd.setCursor(0,1);
                    lcd.print(tomorrowWeather);
                    DEBUG_PRINTLN(tomorrowWeather);
                  }
                  void lcdDisplay6()
                  {
                    if (isMessage)
                    {
                      lcd.setCursor(0,0);
                      lcd.print(F("**NEW  MESSAGE**"));
                      DEBUG_PRINTLN(F("****Message****"));
                      lcd.setCursor(0,1);
                      lcd.print(messageOfTheDay);
                      DEBUG_PRINTLN(messageOfTheDay);
                      motdTimer = millis();
                    }
                    else
                    {
                      lcd.setCursor(0,0);
                      lcd.print(F("****Welcome!****"));
                      DEBUG_PRINTLN(F("****Message****"));
                      lcd.setCursor(0,1);
                      lcd.print(F("Have a Nice Day!"));
                      DEBUG_PRINTLN(F("Have a Nice Day"));
                    }
                  }
                  //
                  void getTempHumidity()
                  {
                    insideTemperature = dht.toFahrenheit(dht.getTemperature());
                    if (isnan(insideTemperature)) 
                    {
                      DEBUG_PRINTLN(F("Failed reading temperature from DHT"));
                    } 
                    humidity = dht.getHumidity();
                    if (isnan(humidity)) 
                    {
                      DEBUG_PRINTLN(F("Failed reading humidity from DHT"));
                    } 
                  }
                  //
                  void receiveTime(unsigned long time)
                  {
                    DEBUG_PRINTLN(F("Time value received: "));
                    DEBUG_PRINTLN(time);
                    setTime(time);
                  }
                  //
                  void PushButton()
                  {
                    static unsigned long last_interrupt_time = 0;
                    unsigned long interrupt_time = millis();
                    if (interrupt_time - last_interrupt_time > 200)
                    {
                      buttonPushed = true;
                    }
                    last_interrupt_time = interrupt_time;
                  }
                  //
                  void activateScene()
                  {
                    DEBUG_PRINTLN(F("ButtonPushed"));
                    fastClear();
                    for (byte i = 0; i < 10; i++)
                    {
                      lcd.noBacklight();
                      delay(50);
                      lcd.backlight();
                      delay(50);
                    }
                    lcd.setCursor(0,0);
                    lcd.print(F(" A/C Boost Mode "));
                    lcd.setCursor(0,1);
                    lcd.print(F("**** ACTIVE ****"));
                    delay(2000);
                    buttonPushed = false;
                    lastTime = millis(); //Reset the timer to even out display interval
                    ledStatus = gw.loadState(CHILD_ID_LED);
                    if (ledStatus > 0)
                    {
                      lcd.backlight();
                    }
                    else
                    {
                      lcd.noBacklight();
                    }
                  }
                  //
                  void getVariables(const MyMessage &message)
                  {
                    if (message.sensor == CHILD_ID_SCENE)
                    { 
                      if (message.type == V_VAR1)
                      {
                        OutdoorTemp = atoi(message.data);
                        DEBUG_PRINTLN(F("OutdoorTemp recieved:"));
                        DEBUG_PRINTLN(OutdoorTemp);
                      }
                      if (message.type == V_VAR2)
                      {
                        OutdoorHumidity = atoi(message.data);
                        DEBUG_PRINT(F("OutdoorHumidity recieved:"));
                        DEBUG_PRINTLN(OutdoorHumidity);
                      }
                      if (message.type == V_VAR3)
                      {
                        todayLow = atoi(message.data);
                        DEBUG_PRINT(F("Received Today's LOW:"));
                        DEBUG_PRINTLN(todayLow);
                      }
                  
                      if (message.type == V_VAR4)
                      {
                        todayHigh = atoi(message.data);
                        DEBUG_PRINT(F("Received Today's HIGH:"));
                        DEBUG_PRINTLN(todayHigh);
                      }
                      if (message.type == V_VAR5)
                      {
                        String newMessage = String(message.data);
                        int locator = newMessage.indexOf("@");
                        newMessage = newMessage.substring(0, locator);
                        conditions = newMessage;
                        DEBUG_PRINT(F("Received today's Conditions:"));
                        DEBUG_PRINTLN(conditions);
                      }
                    }
                    if (message.sensor == CHILD_ID_LED)
                    {
                      if (message.type == V_LIGHT)
                      {
                        int ledState = atoi(message.data);
                        if (ledState > 0)
                        {
                          lcd.backlight();
                        }
                        else
                        {
                          lcd.noBacklight();
                        }
                      }
                      if (message.type == V_VAR1)
                      {
                        // led briteness (nice idea!!!!)
                      }
                      if (message.type == V_VAR2)
                      {
                        // Extended Forecast
                        String newMessage = String(message.data);
                        int locator = newMessage.indexOf("@");
                        newMessage = newMessage.substring(0, locator);
                        tomorrowWeather = newMessage;
                        DEBUG_PRINT(F("Received Two Day Forecast:"));
                        DEBUG_PRINTLN(tomorrowWeather);
                      }
                      if (message.type == V_VAR3)
                      {
                        // message of the day
                        String newMessage = String(message.data);
                        int locator = newMessage.indexOf("@");
                        newMessage = newMessage.substring(0, locator);
                        messageOfTheDay = newMessage;
                        DEBUG_PRINT(F("Received Message of the Day:"));
                        DEBUG_PRINTLN(messageOfTheDay);
                        isMessage = true;
                      }
                    }
                  }
                  

                  fixed it

                  1 Reply Last reply
                  0
                  • korttomaK Offline
                    korttomaK Offline
                    korttoma
                    Hero Member
                    wrote on last edited by
                    #29

                    4 spaces in front of every line will be displayed as code. Please update your post. And I could not play the videos either.

                    • Tomas
                    BulldogLowellB 1 Reply Last reply
                    0
                    • korttomaK korttoma

                      4 spaces in front of every line will be displayed as code. Please update your post. And I could not play the videos either.

                      BulldogLowellB Offline
                      BulldogLowellB Offline
                      BulldogLowell
                      Contest Winner
                      wrote on last edited by BulldogLowell
                      #30

                      @korttoma

                      all fixed. I had to take the text into another editor

                      here is the lua

                       local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 60)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_1", value=temp}, 85)
                      
                       luup.sleep(750)
                      
                       local humid = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1","CurrentLevel", 63)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_2", value=humid}, 85)
                      
                       luup.sleep(750)
                      
                       local low = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_3", value=low}, 85)
                      
                       luup.sleep(750)
                      
                       local high = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 62)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_4", value=high}, 85)
                      
                       luup.sleep(750)
                      
                       local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition", 59)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 85)
                      
                       luup.sleep(750)  
                      
                       local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Forecast.1.Condition", 59)
                       luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_2", value=conditions}, 85)
                      
                       luup.sleep(750)
                      
                      1 Reply Last reply
                      0
                      • korttomaK Offline
                        korttomaK Offline
                        korttoma
                        Hero Member
                        wrote on last edited by
                        #31

                        Nice job on the sketch Jim, I especially liked the idea with "#define DEBUG". There were allso some other ideas I will be stealing some day when I find time to update my sketch.

                        So I guess you did not use the function by @RexBeckett then? I could not get it to work either. I'll try your suggestion with the delays.

                        • Tomas
                        BulldogLowellB 1 Reply Last reply
                        0
                        • korttomaK korttoma

                          Nice job on the sketch Jim, I especially liked the idea with "#define DEBUG". There were allso some other ideas I will be stealing some day when I find time to update my sketch.

                          So I guess you did not use the function by @RexBeckett then? I could not get it to work either. I'll try your suggestion with the delays.

                          BulldogLowellB Offline
                          BulldogLowellB Offline
                          BulldogLowell
                          Contest Winner
                          wrote on last edited by
                          #32

                          @korttoma

                          Thanks for your help and time, you made it a lot easier! I'm trying to write the code for an audience rather than myself so I'm focused more on what I'm putting into the sketch versus just 'getting it to work.' I'm going to get that led dimming next!

                          I messed around with the function but lost patience with it,,. I'll get my lua book out and tackle that one rainy day. Meanwhile, I have been using these delays without any issues (no Vera re-starts) and can probably work on shortening the delay times now that I have my Ethernet gateway working so well!!!

                          best network performance ever for me since I started with MySensors :)

                          I keep looking at your scene controller (and the one Henrik did) and I guess I just have to pick one to make!!

                          1 Reply Last reply
                          0
                          • korttomaK Offline
                            korttomaK Offline
                            korttoma
                            Hero Member
                            wrote on last edited by
                            #33

                            It was all my pleasure Jim, it is nice to have someone to exchange ideas with. I take it you mean the dimming of the backlight right? Let me know if you need some details.

                            I have also put together a Ethernet GW some time ago but newer got around to take it in to use. And then there was all this about the SPI issue so I guess I need to take it on again at some point. A bit unclear if it will work with the Ethernet board I have anyway.

                            • Tomas
                            BulldogLowellB 1 Reply Last reply
                            0
                            • korttomaK korttoma

                              It was all my pleasure Jim, it is nice to have someone to exchange ideas with. I take it you mean the dimming of the backlight right? Let me know if you need some details.

                              I have also put together a Ethernet GW some time ago but newer got around to take it in to use. And then there was all this about the SPI issue so I guess I need to take it on again at some point. A bit unclear if it will work with the Ethernet board I have anyway.

                              BulldogLowellB Offline
                              BulldogLowellB Offline
                              BulldogLowell
                              Contest Winner
                              wrote on last edited by
                              #34

                              @korttoma

                              yeah, I meant dimming the LED backlight, a nice touch to your project.

                              your ethernet board uses the same Wiznet chipset, so you may want to try what was posted on the other thread. I got frustrated with my Serial gateway losing its communication with Vera.

                              1 Reply Last reply
                              0
                              • C Offline
                                C Offline
                                cleight
                                wrote on last edited by
                                #35

                                Hello, I am building this same thing and have used the sketch and luup code above thanks to @BulldogLowell & @korttoma!

                                I am having issues though pulling a variable to send to the lcd screen via luup. I put this device under the Light Variable 4 code is at the bottom of the Lua below. This device is another mysensor that is visible in Vera so I am not sure what is wrong, any help someone could provide would be great.

                                Luup code:

                                local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 7)
                                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_1", value=temp}, 103)
                                luup.sleep(750)
                                local humid = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1","CurrentLevel", 10)
                                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_2", value=humid}, 103)
                                luup.sleep(750)
                                local low = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61)
                                    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_3", value=low}, 103)
                                 luup.sleep(750)
                                local high = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 62)
                                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_4", value=high}, 103)
                                luup.sleep(750)
                                local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition", 6)
                                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 103)
                                luup.sleep(750)  
                                local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Forecast.1.Condition", 59)
                                luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_2", value=conditions}, 103)
                                 luup.sleep(750)
                                  local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98)
                                 luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 103)
                                  luup.sleep(750)
                                

                                Sketch: weather_station.ino

                                1 Reply Last reply
                                0
                                • BulldogLowellB Offline
                                  BulldogLowellB Offline
                                  BulldogLowell
                                  Contest Winner
                                  wrote on last edited by
                                  #36

                                  @cleight said:

                                  local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98)
                                  luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 103)
                                  luup.sleep(750)

                                  it looks like you are making a call for the variable "conditions" and passing "HTTemp" in the two last commands. here:

                                  local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98) -- you get "conditions"
                                  
                                  luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 103) -- you set "HTTemp"
                                  
                                  luup.sleep(750)
                                  

                                  that could be it...

                                  C 1 Reply Last reply
                                  0
                                  • BulldogLowellB BulldogLowell

                                    @cleight said:

                                    local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98)
                                    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 103)
                                    luup.sleep(750)

                                    it looks like you are making a call for the variable "conditions" and passing "HTTemp" in the two last commands. here:

                                    local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98) -- you get "conditions"
                                    
                                    luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 103) -- you set "HTTemp"
                                    
                                    luup.sleep(750)
                                    

                                    that could be it...

                                    C Offline
                                    C Offline
                                    cleight
                                    wrote on last edited by
                                    #37

                                    @BulldogLowell I was under the impression that the value could be named what ever you want, is that not the case? changing the value to temp should fix the issue you think?

                                    BulldogLowellB 1 Reply Last reply
                                    0
                                    • C cleight

                                      @BulldogLowell I was under the impression that the value could be named what ever you want, is that not the case? changing the value to temp should fix the issue you think?

                                      BulldogLowellB Offline
                                      BulldogLowellB Offline
                                      BulldogLowell
                                      Contest Winner
                                      wrote on last edited by BulldogLowell
                                      #38

                                      @cleight said:

                                      changing the value to temp should fix the issue you think?

                                      now I am confused.

                                      You are (it seems to me) retreiving a value from device 98, no?

                                      You are then writing that to device 103, at VAR_4... yes?

                                      please clarify for me.

                                      (reference the snippet of code in my last post)

                                      C 1 Reply Last reply
                                      0
                                      • BulldogLowellB BulldogLowell

                                        @cleight said:

                                        changing the value to temp should fix the issue you think?

                                        now I am confused.

                                        You are (it seems to me) retreiving a value from device 98, no?

                                        You are then writing that to device 103, at VAR_4... yes?

                                        please clarify for me.

                                        (reference the snippet of code in my last post)

                                        C Offline
                                        C Offline
                                        cleight
                                        wrote on last edited by
                                        #39

                                        @BulldogLowell Thanks for pointing that out, I actually need to write VAR4 to device 105. I have made the necessary changes but still isn't working.

                                         local temp = luup.variable_get("urn:upnp-   org:serviceId:TemperatureSensor1","CurrentTemperature", 7)
                                         luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1",  "SendCommand", {radioId="11;3", variableId="VAR_1", value=temp}, 103)
                                        luup.sleep(750)
                                        local humid = luup.variable_get("urn:micasaverde-com:serviceId:HumiditySensor1","CurrentLevel", 10)
                                        luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_2", value=humid}, 103)
                                         luup.sleep(750)
                                         local low = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 8)
                                         luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_3", value=low}, 103)
                                         luup.sleep(750)
                                         local high = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 9)
                                         luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_4", value=high}, 103)
                                         luup.sleep(750)
                                         local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition", 6)
                                         luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;3", variableId="VAR_5", value=conditions}, 103)
                                         luup.sleep(750)  
                                         local conditions = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Forecast.1.Condition", 6)
                                         luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_2", value=conditions}, 105)
                                          luup.sleep(750)
                                          local temp = luup.variable_get("urn:upnp-micasaverde-com:serviceId:TemperatureSensor1","CurrentTemperature", 98)
                                          luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="11;4", variableId="VAR_4", value=HTTemp}, 105)
                                          luup.sleep(750)
                                        
                                        1 Reply Last reply
                                        0
                                        • korttomaK Offline
                                          korttomaK Offline
                                          korttoma
                                          Hero Member
                                          wrote on last edited by
                                          #40

                                          You are stil not giving HTtemp any value!

                                          • Tomas
                                          C 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          3

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular