Announcement

Collapse
No announcement yet.

Arduino - Projects by topics

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Arduino - Projects by topics

    I'm new to Arduino and the integration of it with this plugin. Thru the help of this board and the owner of this plugin, I was able to implement several projects. Although it comes natural to some of you, I'm sure there are lot of people at my same level of expertise. Most of you already have great projects implemented. It would be really cool and I'm sure will help more people to adopt Arduino if we create a discussion post for each project. As an example, there would e a topic for how to install and display the temperature and humidity via the API and normal plugin, another one for the soil moist level and etc. We could have them a the top of the posts so it would be easy accessible, what do you think?


    Aldo

  • #2
    As I'm just getting into this as well, I second Aldo.

    Robert
    HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

    Comment


    • #3
      Yes that would be very helpfull, especially examples with the api would be educational.
      I want to make an PWM output on an NodeMCU for dimming led lights, but i dont have a clue where to begin.
      It could help me if there where some examples that give me a start point.

      Comment


      • #4
        I just migrated from the basic sketch to the API based sketch this last weekend. My sketch handles PIR for motion, DHT11 for temp/humidity and a digital pin for door/window sensors. If you know Arduino programming, it is easy to understand. If you don't know about how to handle devices and sensors on an Arduino, get a breadboard and a sensor kit and start learning. Then integrating your code into the API sketch will be pretty easy.

        If you look in the basic API sketch, at the first you will find HSSetup and HSloop. These are roughly equivalent to the standard setup and loop functions in any Arduino sketch.

        I am including my code that was added to the first of the sketch. I don't claim it is anything great but it does work. You will notice some commented code for the OneWire devices such as the Dallas temp sensor. It hasn't been tested yet which is why it is commented.

        Code:
        //**************Declare your variables here******************* 
        
        #include <SimpleDHT.h>
        //#include <OneWire.h>
        //#include <DallasTemperature.h>
        
        //  This is the place where you define the hardware that is attached to this device. That hardware attaches thru a PIN on the Arduino.
        //  PINS (cross referencing the UNO to the 12E)
        
        int DHT11_Sensor  = 2;     //  ESP 12E pin D4
        int Motion_Sensor = 13;    //  ESP 12E pin D7
        int Door_Sensor   = 12;    //  ESP 12E pin D6
        
        /*int DS18B20_Sensor = 4;    //  ESP 12E pin D2
        
        OneWire oneWire(DS18B20_Sensor);
        
        // vars used within this Sketch (locally)
        int Loop_Delay = 1000;
        int pirState = LOW;             // we start, assuming no motion detected
        int val = 0;                    // variable for reading the pin status
        */
        
        // DHT11 variables
        byte DHT_Temperature = 0;
        byte DHT_Humidity = 0;
        byte DHT_Data[40] = {0};
        int DHT_Return;
        unsigned long DHTCurrentMillis = 0;
        unsigned long DHTPreviousMillis = 0;
        
        /*
        // 18B20 variables
        
        // Pass our oneWire reference to Dallas Temperature.
        DallasTemperature sensors(&oneWire);
        
        float DS18B20_temp = 0;
        */
        
        SimpleDHT11 dht11;
        
        //motion PIR variables
        int PIRCurrentState = 0;
        int PIRPreviousState = -1;
        
        int DoorCurrentState = 0;
        int DoorPreviousState = 100;
         
        void HSSetup() {
          
          //************************
          //Add YOUR SETUP HERE;
          //************************
        
        pinMode(DHT11_Sensor, INPUT);
        pinMode(Motion_Sensor,INPUT);
        pinMode(Door_Sensor, INPUT);
        
        DHTCurrentMillis = millis();
        DHTPreviousMillis = millis();
        
        Serial.begin(9600);
        
        //sensors.begin();
        }
        
        
        void HSloop() {
            //************************
            //Add YOUR CODE HERE;
            //************************
            /* To Send Data to Homeseer use SendToHS(Device,Value)
             Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
             To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.
             Eg.. FromHS[5] would be the data from API Output device 5
             All code that is located just below this block will execute regardless of connection status!
             You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
             If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
             */
        
            /*Execute regardless of connection status*/
        
         
        
         if (IsConnected == true) {
           /*Execute ONLY when HomeSeer is connected*/
           
         // **************  Start Motion Sensor *****************    
          PIRCurrentState = digitalRead(Motion_Sensor);
          if (PIRCurrentState != PIRPreviousState) {
             if (PIRCurrentState == HIGH) {
                SendToHS(1,100);  
             } 
             else {
                SendToHS(1,0);
             }
             PIRPreviousState = PIRCurrentState;   
          }
        // **************  End Motion Sensor *****************   
        
        // **************  Start Door Sensor ***************** 
          DoorCurrentState = digitalRead(Door_Sensor);
          if (DoorCurrentState != DoorPreviousState) {
             if (DoorCurrentState == HIGH) {
                SendToHS(2,100);  
             } 
             else {
                SendToHS(2,0);
             }
             DoorPreviousState = DoorCurrentState;   
          }
        // **************  End Door Sensor ***************** 
        
        // **************  Start DHT11 Sensor *****************  
          DHTCurrentMillis = millis();
          if (DHTCurrentMillis - DHTPreviousMillis >= (5 * 60 * 1000)) {      // Update every 5 minutes
             DHT_Return = 1;
             DHT_Return = dht11.read(DHT11_Sensor, &DHT_Temperature, &DHT_Humidity, NULL);
             if (DHT_Return == 0) {
                DHT_Temperature =  (DHT_Temperature * 18 + 5)/10 + 32;    // adjust from C to F
        //        Serial.print("T = ");
        //        Serial.print((int)DHT_Temperature); 
        //        Serial.print(" F,   ");
        //        Serial.print("H = ");
        //        Serial.print((int)DHT_Humidity); 
        //        Serial.println(" %");
                SendToHS(3,DHT_Temperature);
                SendToHS(4,DHT_Humidity);    
                DHTCurrentMillis = millis();
                DHTPreviousMillis = DHTCurrentMillis;
             }
          }   
        // **************  End DHT11 Sensor *****************   
        
          }    // end of 'if (IsConnected == true) {'
        
        }
        
        //************Do not change anything after Here*****************

        Comment


        • #5

          Comment


          • #6
            Thank you, it is great to see so many people sharing their projects.

            Sent from my SM-G935V using Tapatalk

            Comment


            • #7
              Edit: I had to download this library from https://github.com/winlinvip/SimpleDHT/releases

              Thanks.

              Logbuilder, thanks for sharing. I get this error when I try to compile, it sounds like I do not have a library that is required when I use this #include <SimpleDHT.h>

              Arduino: 1.8.1 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

              E:\Aldo\Downloads\APIBoard4\APIBoard4.ino:12:23: fatal error: SimpleDHT.h: No such file or directory

              #include <SimpleDHT.h>

              ^

              compilation terminated.

              exit status 1
              Error compiling for board NodeMCU 1.0 (ESP-12E Module).

              This report would have more information with
              "Show verbose output during compilation"
              option enabled in File -> Preferences.


              Originally posted by logbuilder View Post
              I just migrated from the basic sketch to the API based sketch this last weekend. My sketch handles PIR for motion, DHT11 for temp/humidity and a digital pin for door/window sensors. If you know Arduino programming, it is easy to understand. If you don't know about how to handle devices and sensors on an Arduino, get a breadboard and a sensor kit and start learning. Then integrating your code into the API sketch will be pretty easy.

              If you look in the basic API sketch, at the first you will find HSSetup and HSloop. These are roughly equivalent to the standard setup and loop functions in any Arduino sketch.

              I am including my code that was added to the first of the sketch. I don't claim it is anything great but it does work. You will notice some commented code for the OneWire devices such as the Dallas temp sensor. It hasn't been tested yet which is why it is commented.

              Code:
              //**************Declare your variables here******************* 
              
              #include <SimpleDHT.h>
              //#include <OneWire.h>
              //#include <DallasTemperature.h>
              
              //  This is the place where you define the hardware that is attached to this device. That hardware attaches thru a PIN on the Arduino.
              //  PINS (cross referencing the UNO to the 12E)
              
              int DHT11_Sensor  = 2;     //  ESP 12E pin D4
              int Motion_Sensor = 13;    //  ESP 12E pin D7
              int Door_Sensor   = 12;    //  ESP 12E pin D6
              
              /*int DS18B20_Sensor = 4;    //  ESP 12E pin D2
              
              OneWire oneWire(DS18B20_Sensor);
              
              // vars used within this Sketch (locally)
              int Loop_Delay = 1000;
              int pirState = LOW;             // we start, assuming no motion detected
              int val = 0;                    // variable for reading the pin status
              */
              
              // DHT11 variables
              byte DHT_Temperature = 0;
              byte DHT_Humidity = 0;
              byte DHT_Data[40] = {0};
              int DHT_Return;
              unsigned long DHTCurrentMillis = 0;
              unsigned long DHTPreviousMillis = 0;
              
              /*
              // 18B20 variables
              
              // Pass our oneWire reference to Dallas Temperature.
              DallasTemperature sensors(&oneWire);
              
              float DS18B20_temp = 0;
              */
              
              SimpleDHT11 dht11;
              
              //motion PIR variables
              int PIRCurrentState = 0;
              int PIRPreviousState = -1;
              
              int DoorCurrentState = 0;
              int DoorPreviousState = 100;
               
              void HSSetup() {
                
                //************************
                //Add YOUR SETUP HERE;
                //************************
              
              pinMode(DHT11_Sensor, INPUT);
              pinMode(Motion_Sensor,INPUT);
              pinMode(Door_Sensor, INPUT);
              
              DHTCurrentMillis = millis();
              DHTPreviousMillis = millis();
              
              Serial.begin(9600);
              
              //sensors.begin();
              }
              
              
              void HSloop() {
                  //************************
                  //Add YOUR CODE HERE;
                  //************************
                  /* To Send Data to Homeseer use SendToHS(Device,Value)
                   Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
                   To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.
                   Eg.. FromHS[5] would be the data from API Output device 5
                   All code that is located just below this block will execute regardless of connection status!
                   You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
                   If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
                   */
              
                  /*Execute regardless of connection status*/
              
               
              
               if (IsConnected == true) {
                 /*Execute ONLY when HomeSeer is connected*/
                 
               // **************  Start Motion Sensor *****************    
                PIRCurrentState = digitalRead(Motion_Sensor);
                if (PIRCurrentState != PIRPreviousState) {
                   if (PIRCurrentState == HIGH) {
                      SendToHS(1,100);  
                   } 
                   else {
                      SendToHS(1,0);
                   }
                   PIRPreviousState = PIRCurrentState;   
                }
              // **************  End Motion Sensor *****************   
              
              // **************  Start Door Sensor ***************** 
                DoorCurrentState = digitalRead(Door_Sensor);
                if (DoorCurrentState != DoorPreviousState) {
                   if (DoorCurrentState == HIGH) {
                      SendToHS(2,100);  
                   } 
                   else {
                      SendToHS(2,0);
                   }
                   DoorPreviousState = DoorCurrentState;   
                }
              // **************  End Door Sensor ***************** 
              
              // **************  Start DHT11 Sensor *****************  
                DHTCurrentMillis = millis();
                if (DHTCurrentMillis - DHTPreviousMillis >= (5 * 60 * 1000)) {      // Update every 5 minutes
                   DHT_Return = 1;
                   DHT_Return = dht11.read(DHT11_Sensor, &DHT_Temperature, &DHT_Humidity, NULL);
                   if (DHT_Return == 0) {
                      DHT_Temperature =  (DHT_Temperature * 18 + 5)/10 + 32;    // adjust from C to F
              //        Serial.print("T = ");
              //        Serial.print((int)DHT_Temperature); 
              //        Serial.print(" F,   ");
              //        Serial.print("H = ");
              //        Serial.print((int)DHT_Humidity); 
              //        Serial.println(" %");
                      SendToHS(3,DHT_Temperature);
                      SendToHS(4,DHT_Humidity);    
                      DHTCurrentMillis = millis();
                      DHTPreviousMillis = DHTCurrentMillis;
                   }
                }   
              // **************  End DHT11 Sensor *****************   
              
                }    // end of 'if (IsConnected == true) {'
              
              }
              
              //************Do not change anything after Here*****************

              Comment


              • #8
                This is what I have so far, unfortunately I do not get any values for the temperature and humidity. I removed the code for the motion and other devices and use only the humidity sensor. I hope I will help others as well.

                Code is from Logbuilder




                Code:
                //**************Declare your variables here******************* 
                #include <SimpleDHT.h>
                
                int DHT11_Sensor  = 2;     //  ESP 12E pin D4
                
                // DHT11 variables
                byte DHT_Temperature = 0;
                byte DHT_Humidity = 0;
                byte DHT_Data[40] = {0};
                int DHT_Return;
                unsigned long DHTCurrentMillis = 0;
                unsigned long DHTPreviousMillis = 0;
                
                SimpleDHT11 dht11;
                //****************************************************************
                
                
                
                 
                void HSSetup() {
                  
                  //************************
                  //Add YOUR SETUP HERE;
                  //************************
                
                pinMode(DHT11_Sensor, INPUT);
                
                DHTCurrentMillis = millis();
                DHTPreviousMillis = millis();
                
                // Serial.begin(9600);
                
                //sensors.begin();
                }
                
                void HSloop() {
                    //************************
                    //Add YOUR CODE HERE;
                    //************************
                    /* To Send Data to Homeseer use SendToHS(Device,Value)
                     Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send
                     To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes.
                     Eg.. FromHS[5] would be the data from API Output device 5
                     All code that is located just below this block will execute regardless of connection status!
                     You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue.
                     If you only want code to execute when HomeSeer is connected, put it inside the if statement below.
                     */
                
                    /*Execute regardless of connection status*/
                
                 
                
                 if (IsConnected == true) {
                   /*Execute ONLY when HomeSeer is connected*/
                   
                // **************  Start DHT11 Sensor *****************  
                  DHTCurrentMillis = millis();
                  if (DHTCurrentMillis - DHTPreviousMillis >= (5 * 60 * 1000)) {      // Update every 5 minutes
                     DHT_Return = 1;
                     DHT_Return = dht11.read(DHT11_Sensor, &DHT_Temperature, &DHT_Humidity, NULL);
                     if (DHT_Return == 0) {
                        DHT_Temperature =  (DHT_Temperature * 18 + 5)/10 + 32;    // adjust from C to F
                //        Serial.print("T = ");
                //        Serial.print((int)DHT_Temperature); 
                //        Serial.print(" F,   ");
                //        Serial.print("H = ");
                //        Serial.print((int)DHT_Humidity); 
                //        Serial.println(" %");
                        SendToHS(1,DHT_Temperature);
                        SendToHS(2,DHT_Humidity);    
                        DHTCurrentMillis = millis();
                        DHTPreviousMillis = DHTCurrentMillis;
                     }
                  }   
                // **************  End DHT11 Sensor *****************   
                
                  }    // end of 'if (IsConnected == true) {'
                
                }
                
                //************Do not change anything after Here*****************
                Attached Files

                Comment


                • #9
                  Aldo,

                  Have a look Here

                  Greig.
                  Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
                  X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
                  Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
                  Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
                  Scripts =
                  Various

                  Comment


                  • #10
                    So my project has a requirement to activate 1 or 4 relays individually at a time. I'd like to add 4 remote buttons as well and when a particular button is pressed, it would activate one of the relays but de-activate the others - I can only have one on at a time. I'm wondering which is the best way to handle this? Through events using the standard sketch or does it make more sense to use the API version of the sketch and code within it? From what I can tell, if you want specific control to occur within the Arduino, that this is the way to best handle it.
                    Am I correct with this assumption.

                    Still climbing ropes with this...

                    Robert

                    EDIT: As I think about it, creating 4 separate events would be simple enough. Within each event, just send a command to turn off the other 3 output (relays) whether they are on or not, and only activate the one desired.
                    Last edited by langenet; June 8th, 2017, 08:13 AM.
                    HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

                    Comment


                    • #11
                      Robert, you have your answer...you can turn things off that are already off just incase :-)

                      Cheers...
                      HS 2.2.0.11

                      Comment


                      • #12
                        Thanks... I have another issue - though more of an annoyance. It seems that if I reboot my server or start stop the Arduino plugin, that the I2c LCD screen I use displays garbage and the only way to clear it is to unplug the power to the board and power on again. When it powers up, it works great and immediate displays correctly. I've tried using the clear command on the device manager but that doesn't work at all. Are others experiencing this too.
                        I need reliable display should conditions above occur.
                        Just using the sda/sdc to drive the I2C controller...

                        Anyone have a suggestion with this?

                        Robert
                        HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

                        Comment


                        • #13
                          I have a project in mind that I can finally begin considering investing some time into now that the NodeMCU works with HS! I want to build a small metal frame that will hold 4 different air freshener cans, each with an electric solenoid that will depress the trigger and cause it to spray. A NodeMCU will be connected to a relay block with 4 relays, one for each solenoid/air freshener. Then I will cut a small rectangular hole in my furnace vent that supplies the air to all the registers in the house, so basically after the blower fan. Then mount this frame with the nozzles aimed into the furnace ducting.

                          Then when the furnace turns on, during different times of the day a different scent can be released into the house... I even had another idea of putting one in the duct that feeds each bathroom, then if the door is closed for X amount of time and the lights are on...turn the furnace fan on and give that specific zone a quick spray. The NodeMCU makes this possible as you only need 120v nearby. No need to run Cat cable and power to the specific node.

                          I may even consider building these as kits for sale as well as I do own/operate a metalworking shop; which has a CNC plasma table, sheet metal brake and powdercoating capability as well.

                          Comment


                          • #14
                            @Conrad_Turbo

                            That is a really neat idea.

                            Too bad that smell is not like color. It would be cool if you could mix 3 or 4 basic smells and be able to come up with any smell. Maybe match the smell to the weather. Beautiful spring morning and you smell wild flowers.

                            Comment


                            • #15
                              Originally posted by logbuilder View Post
                              @Conrad_Turbo

                              That is a really neat idea.

                              Too bad that smell is not like color. It would be cool if you could mix 3 or 4 basic smells and be able to come up with any smell. Maybe match the smell to the weather. Beautiful spring morning and you smell wild flowers.
                              I plan on doing essential oils mixed in a solution and in a spray bottle. Then you could do something based on time to either blend smells or just have them on their own. With 4 bottles you could have quite a few permutations, the harder part would be having the HS event parse out a weather report and then decide what combination to spray. Or heck if you're expecting an important email when the furnace turns on and the house smells like mint...you know you've got mail! lol.

                              PS I live in a log house too.

                              Comment

                              Working...
                              X