• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login

    Frustrated Newbie - Help with Nodes and Sensors

    Scheduled Pinned Locked Moved Troubleshooting
    46 Posts 4 Posters 5.4k Views 2 Watching
    Loading More Posts
    • 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.
    • EmenikeE Offline
      Emenike @Tag
      last edited by

      @tag @jkandasa

      My Sprinkler node is downstairs - just about 7 meters below the spot where the MySensors Gateway + MyController laptop is (with about 2 concrete walls separating them). Does this matter? For the records, I have capacitor on both MySensors Gateway, and the Water Sprinkler node.

      1 Reply Last reply Reply Quote 0
      • T Offline
        Tag MOD
        last edited by

        Can be an issue, can you try if you see the node if it is basically next to your gateway?

        EmenikeE 1 Reply Last reply Reply Quote 0
        • EmenikeE Offline
          Emenike @Tag
          last edited by

          @tag Okay I will move them closer until I conclude with all the bugs, then I will move them apart and see if distance is the issue

          by the way... is This project in this video a MySensors Gateway or something entirely new?

          T 1 Reply Last reply Reply Quote 0
          • T Offline
            Tag MOD @Emenike
            last edited by

            @emenike

            Okay, great!,
            Had a look at the link you send, it looks like mysensors, but it is something different...

            skywatchS 1 Reply Last reply Reply Quote 0
            • skywatchS Offline
              skywatch @Tag
              last edited by

              @Emenike

              This bit is wrong in your gateway sketch.....

              // Define a lower baud rate for Arduinos running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
              #if F_CPU == 8000000L
              
              //#define MY_BAUD_RATE 38400
              #define MY_BAUD_RATE 115200
              #endif
              

              The baud rate in the if statement should be 38400 as it says in the line above it.

              It won't matter if you are using a 5V arduino, but if you were to use a 3.3V one this would be a big problem.

              EmenikeE 1 Reply Last reply Reply Quote 0
              • EmenikeE Offline
                Emenike @skywatch
                last edited by

                @skywatch Thanks @skywatch

                Please note that I am using a Nano for my gate way...
                I thought the baud rate should be the same for Arduino and the Putty sniffer, I will revert to "38400"...

                T skywatchS 2 Replies Last reply Reply Quote 0
                • T Offline
                  Tag MOD @Emenike
                  last edited by

                  @emenike

                  Make sure that the same baudrate is used in the gateway sketch and mycontroller.....

                  EmenikeE 1 Reply Last reply Reply Quote 0
                  • EmenikeE Offline
                    Emenike @Tag
                    last edited by

                    @tag
                    😭 but that was exactly how it was until you said to change 38400 …. but it connected alright after | changed to 38400 and brought the node next to the laptop.

                    T 1 Reply Last reply Reply Quote 0
                    • skywatchS Offline
                      skywatch @Emenike
                      last edited by

                      @emenike said in Frustrated Newbie - Help with Nodes and Sensors:

                      @skywatch Thanks @skywatch

                      Please note that I am using a Nano for my gate way...
                      I thought the baud rate should be the same for Arduino and the Putty sniffer, I will revert to "38400"...

                      That part of the gateway sketch is an 'If' statement. It just tells the compilier that 'if' the board is a 3.3v 8MHz type, then reduce the baud rate to match. 8MHz boards are not reliable at 115200.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        Tag MOD @Emenike
                        last edited by

                        @emenike

                        Okay so if I understand correctly, all works if the nodes are basically next to each other... is that correct?

                        EmenikeE 1 Reply Last reply Reply Quote 0
                        • EmenikeE Offline
                          Emenike @Tag
                          last edited by

                          @tag Yes! All works well when they are next to each other on the same desk.
                          I have reverted the default baud rate and all is well. I have gone ahead to create Triggers and Conditions, Schedules, Actions, etc. But I somehow can not seem to tie all up to do what I want.

                          I want to do a whole lot of things, but lets start with the first one. I need to pull in time and date from the controller to my node. How do I do this? Can I have a simple example that shows the steps or syntax and I will try to do other stuff. The Mysensors node uses a project that pulls data from Weather Underground, which I learnt has stopped its free weather information services. I have researched the topic and found a likely alternative in Open Weather Service) . Is anyone using Open Weather? https://openweathermap.org/current)

                          1. I need to create Actions (or triggers that target all 8 objects from my node and set them all "on".
                          2. I need to create another action trigger that targets all 8 objects and sets them to "off"
                          3. I need to create an action trigger cycles through each value on the node and turn them on for a duration I have a variable in the Controller on each value to determine how long each one will run. Its a whole lot, and it appears I may have bitten off more than I can chew.
                          jkandasaJ 1 Reply Last reply Reply Quote 0
                          • jkandasaJ Offline
                            jkandasa @Emenike
                            last edited by

                            @emenike

                            To receive time in your node, you have to call requestTime(); from your node, then you will receive time on the following function(add this in your node code),

                            void receiveTime(unsigned long _timestamp){
                               // do actions with received time
                            }
                            
                            • Regards Wunderground: I have added details in https://forum.mycontroller.org/topic/215/weatherdata-structure-question/3 looks like they will give some access for personal use.
                            • Regards Open weather, we do not have any direct support, however, you may use a script to collect data.

                            I need to create Actions (or triggers that target all 8 objects from my node and set them all "on".

                            You need to create 8 Operations for each object. Send payload operation with 1(ON), Add all of them in a rule. define your condition in the rule.

                            I need to create another action trigger that targets all 8 objects and sets them to "off"

                            You need to create 8 Operations for each object. Send payload operation with 0(OFF), Add all of them in a rule. define your condition in the rule.

                            I need to create an action trigger cycles through each value on the node and turn them on for a duration I have a variable in the Controller on each value to determine how long each one will run. Its a whole lot, and it appears I may have bitten off more than I can chew.

                            Seems this is complex, we may not easy by simple rule definition/timer. A script will be a good solution for this.

                            Some of the discussions,
                            https://forum.mycontroller.org/topic/45/timers-and-scripts
                            https://forum.mycontroller.org/topic/262/how-to-automatically-turn-off-relay-after-defined-time

                            EmenikeE 1 Reply Last reply Reply Quote 0
                            • EmenikeE Offline
                              Emenike @jkandasa
                              last edited by Emenike

                              Thanks @jkandasa you are awesome support. I see the requestTime() function call in the sketch, but where in MyController do I add the node code?

                              void receiveTime(unsigned long _timestamp){
                                 // do actions with received time
                              }
                              
                              jkandasaJ 1 Reply Last reply Reply Quote 0
                              • EmenikeE Offline
                                Emenike
                                last edited by

                                I have created the UID Tags... See below, did I do it right?UID Tags.png

                                I then tried to create the JS script as described in your old reference you supplied... but I got an error.

                                RunQuery Error.png

                                What are I doing wrong?

                                jkandasaJ 1 Reply Last reply Reply Quote 0
                                • jkandasaJ Offline
                                  jkandasa @Emenike
                                  last edited by

                                  @Emenike

                                  I see the requestTime() function call in the sketch, but where in MyController do I add the node code?

                                  This code needs to be added to your MySensors node sketch, the example in your sprinkler sketch.
                                  Nothing to do with MyController to receive timestamp.

                                  1 Reply Last reply Reply Quote 0
                                  • jkandasaJ Offline
                                    jkandasa @Emenike
                                    last edited by jkandasa

                                    @Emenike said in Frustrated Newbie - Help with Nodes and Sensors:

                                    I then tried to create the JS script as described in your old reference you supplied... but I got an error.

                                    Did you modify the script? If yes, can you post your script?

                                    If not, you have to create all the UID, valve-status is not available in your UID's list also Value 1 is different then value01

                                    1 Reply Last reply Reply Quote 0
                                    • EmenikeE Offline
                                      Emenike
                                      last edited by

                                      Hello @jkandasa
                                      I have been out of town, haven't touched MYC for a while. Just popped intoday and tried my hands on the script. Ran it after creating the Operation and the Timmer to trigger and run it. But it wont tun. I get an error ```

                                      {
                                        "errorMessage": "TypeError: Cannot get property \"status\" of null in <eval> at line number 8"
                                      }
                                      

                                      Here is the JS script that I edited for 8 valves

                                      var myImports = new JavaImporter(java.io, java.lang, java.util);
                                      
                                      with(myImports) {
                                        
                                        var LoopThroughValves = mcApi.variable().get("Status");
                                      
                                        //Check already running?
                                        if(LoopThroughValves.status !== 'running'){
                                      
                                          //Update as running
                                          valveStatus.value = "running";
                                          mcApi.variable().update(valveStatus);
                                          mcApi.logger().debug("Loop Through Valve Script Triggered...");
                                          
                                          var masterValve = mcApi.uidTag(0).getByUid("All Zones").getResource();
                                          var valve01 = mcApi.uidTag().getByUid("Zone 1").getResource();
                                          var valve02 = mcApi.uidTag().getByUid("Zone 2").getResource();
                                          var valve03 = mcApi.uidTag().getByUid("Zone 3").getResource();
                                          var valve04 = mcApi.uidTag().getByUid("Zone 4").getResource();
                                          var valve05 = mcApi.uidTag().getByUid("Zone 5").getResource();
                                          var valve06 = mcApi.uidTag().getByUid("Zone 6").getResource();
                                          var valve07 = mcApi.uidTag().getByUid("Zone 7").getResource();
                                          var valve08 = mcApi.uidTag().getByUid("Zone 8").getResource();
                                      
                                          var delayTime = 1000 * 60 * 10; //10 minutes
                                        
                                          //Turn ON master valve and Valve01
                                          masterValve.value = "1"; //Update master valve ON state
                                          mcApi.sensor().sendPayload(masterValve); //sensd state
                                          valve01.value = "1"; //Update valve01 ON state
                                          mcApi.sensor().sendPayload(valve01); //sensd state
                                            
                                          //Update valve01 is running
                                          valveStatus.value2 = "value01";
                                          mcApi.variable().update(valveStatus);
                                          //Wait time
                                          Thread.sleep(delayTime);
                                        
                                          //Turn OFF valve01 and turn ON valve02
                                          valve01.value = "0"; //Update valve01 OFF state
                                          mcApi.sensor().sendPayload(valve01); //send state
                                          valve02.value = "1"; //Update valve02 ON state
                                          mcApi.sensor().sendPayload(valve02); //send state
                                          
                                          //Update valve02 is running
                                          valveStatus.value2 = "value02";
                                          mcApi.variable().update(valveStatus);
                                          
                                          //Wait time
                                          Thread.sleep(delayTime);
                                        
                                          //Turn OFF valve02 and turn ON valve03
                                          valve02.value = "0"; //Update valve02 OFF state
                                          mcApi.sensor().sendPayload(valve02); //send state
                                          valve03.value = "1"; //Update valve03 ON state
                                          mcApi.sensor().sendPayload(valve03); //send state
                                        
                                          //Update valve03 is running
                                          valveStatus.value2 = "value03";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                        
                                          //Turn OFF valve03 and turn ON valve04
                                          valve03.value = "0"; //Update valve03 OFF state
                                          mcApi.sensor().sendPayload(valve03); //send state
                                          valve04.value = "1"; //Update valve04 ON state
                                          mcApi.sensor().sendPayload(valve04); //send state
                                        
                                          //Update valve04 is running
                                          valveStatus.value3 = "value04";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                      
                                          //Turn OFF valve04 and turn ON valve05
                                          valve04.value = "0"; //Update valve04 OFF state
                                          mcApi.sensor().sendPayload(valve04); //send state
                                          valve05.value = "1"; //Update valve05 ON state
                                          mcApi.sensor().sendPayload(valve05); //send state
                                        
                                          //Update valve05 is running
                                          valveStatus.value4 = "value05";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                      
                                          //Turn OFF valve05 and turn ON valve06
                                          valve05.value = "0"; //Update valve05 OFF state
                                          mcApi.sensor().sendPayload(valve05); //send state
                                          valve06.value = "1"; //Update valve06 ON state
                                          mcApi.sensor().sendPayload(valve06); //send state
                                        
                                          //Update valve06 is running
                                          valveStatus.value5 = "value06";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                      
                                          //Turn OFF valve06 and turn ON valve07
                                          valve06.value = "0"; //Update valve06 OFF state
                                          mcApi.sensor().sendPayload(valve06); //send state
                                          valve07.value = "1"; //Update valve07 ON state
                                          mcApi.sensor().sendPayload(valve07); //send state
                                        
                                          //Update valve06 is running
                                          valveStatus.value6 = "value07";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                      
                                      
                                          //Turn OFF valve07 and turn ON valve08
                                          valve07.value = "0"; //Update valve07 OFF state
                                          mcApi.sensor().sendPayload(valve07); //send state
                                          valve08.value = "1"; //Update valve08 ON state
                                          mcApi.sensor().sendPayload(valve08); //send state
                                        
                                          //Update valve07 is running
                                          valveStatus.value7 = "value08";
                                          mcApi.variable().update(valveStatus);
                                        
                                          //Wait time
                                          Thread.sleep(delayTime);
                                      
                                          //Turn OFF valve08 and turn OFF master valve
                                          valve08.value = "0"; //Update valve08 OFF state
                                          mcApi.sensor().sendPayload(valve08); //send state
                                          masterValve.value = "0"; //Update master valve OFF state
                                          mcApi.sensor().sendPayload(masterValve); //send state
                                          
                                          //Update not running
                                          valveStatus.value = "stopped";
                                          valveStatus.value2 = "-";
                                          mcApi.variable().update(valveStatus);
                                          mcApi.logger().debug("Loop Through Valve Script Completed...");
                                        }else{
                                          mcApi.logger().warn("Loop Through Valve Script is already running...");
                                        }
                                      }
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • EmenikeE Offline
                                        Emenike
                                        last edited by

                                        What am I doing wrong? I am posting the Nodes and Sensors just incase... Sensors Script.png

                                        jkandasaJ 1 Reply Last reply Reply Quote 0
                                        • jkandasaJ Offline
                                          jkandasa @Emenike
                                          last edited by

                                          @Emenike Can you post your UID Tags and Variables repositorypage?

                                          1 Reply Last reply Reply Quote 0
                                          • EmenikeE Offline
                                            Emenike
                                            last edited by

                                            Sorry @jkandasa, I have been on the move travelled for the Christmas Holiday. so I am away from my nodes and sensors. But I have the MYC on my laptop. so here are the data you requested for.
                                            UID2.png

                                            and the Variables - Variable Repisotory.png

                                            jkandasaJ 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            0

                                            Online

                                            587

                                            Users

                                            529

                                            Topics

                                            3.4k

                                            Posts
                                            Copyright © 2015-2025 MyController.org | Contributors | Localization