Announcement

Collapse
No announcement yet.

Arduino - HC-SR04 Ultrasonic Sensor Distance Module

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

    #16
    Originally posted by aldo View Post
    Quick question:
    I have attached the picture, what the input and output should be set at?

    After making changes or adding pins, do I need to download the sketch and make your changes into the new uploaded sketch?

    Thanks, Aldo
    There is no output set up in the code so you only need the input for the moment.

    If you are using Ethernet then you can not use some of the pins as they are used for the shield. Pins 12 and 13 are two of them so change the pins in the code to pins 8 and 9 and connect the sensor to them and upload the code again.

    You do not need to update the code if you make changes to the plugin config only if you change the code for the API.

    For the normal Sketch you do not need to update the board once it is set unless you change the IP config or change it from IP to a com port.

    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


      #17
      Edit: I need to play with this some more, in the mean time I think I have found the issue with Unknown, I was setting the status to value, I changed it to string and it seem to be working ok. Still not sure if the refresh is right or needs to be adjusted.

      Thanks Greig, almost there. Sometime it reads the values like Dim 73% then mostly shows the value Unknown, I think it can not keep up with the value changes.
      these are the messages I get in the log
      May-15 6:36:26 PM Arduino Plugin Sent to IP:192.168.0.47 Port No:8900 = 1 h ,Ack Command
      May-15 6:36:26 PM Arduino Plugin Sent to IP:192.168.0.47 Port No:8900 = 1 h ,Ack Command
      May-15 6:36:26 PM Arduino Plugin Sent to IP:192.168.0.47 Port No:8900 = 1 h ,Ack Command
      May-15 6:36:26 PM Arduino Plugin Sent to IP:192.168.0.47 Port No:8900 = 1 h ,Ack Command
      May-15 6:36:26 PM Arduino Plugin Sent to IP:192.168.0.47 Port No:8900 = 1 h ,Ack Command

      Trust me, I'm reading as much as I can and getting my brain to overload, I saw it in your manual at one point but I recollected it after you told me.

      If I would like to integrate the switch into the API. Let me know if I'm doing it incorrectly:

      #define inputPin 5
      --
      pinMode(inputPin, INPUT);
      --
      SendToHS(2,inputPin);

      Then create in the plugin an input pin.
      Last edited by alphatech; May 15, 2017, 06:18 PM.

      Comment


        #18
        Not sure why but the values given by the sensor are sporadic, anything that we would need to adjust in the code?

        I'm also trying to implement the water level switch as part of this implementation, it has been already tested in the normal Arduino code, I would like to implement it into the API, is this the code that I would need to add to the API?

        #define inputPin 5
        --
        pinMode(inputPin, INPUT);
        --
        SendToHS(2,inputPin);

        Then create in the plugin an input pin.

        Thanks,
        Aldo

        Comment


          #19
          Originally posted by aldo View Post
          Not sure why but the values given by the sensor are sporadic, anything that we would need to adjust in the code?

          I'm also trying to implement the water level switch as part of this implementation, it has been already tested in the normal Arduino code, I would like to implement it into the API, is this the code that I would need to add to the API?

          #define inputPin 5
          --
          pinMode(inputPin, INPUT);
          --
          SendToHS(2,inputPin);

          Then create in the plugin an input pin.

          Thanks,
          Aldo
          Aldo Sorry I missed this post.
          Yes this is the code to add to the API but also add a change detection "IF" because this will send the value to HS every time the code loops and this is very fast so will likely crash the plugin.

          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


            #20
            Thank you Greig.

            Comment


              #21
              Reviving this old thread, I'm going to use a similar sensor setup to monitor the water level in a reservoir.

              Checking here to see if the code referenced in this thread is still good or does it need to be tweaked\updated? I will also use this waterproof version of the sensor:
              https://store-usa.arduino.cc/product...39726235320527

              Thank you!

              Comment


                #22
                Follow-on, there seems to be a Newping library for Arduino that is compatible with the mega and sensor mentioned. Will give this a try
                https://bitbucket.org/teckel12/ardui...newping-sketch

                Assuming I can load the library\sketch and this should work with Homeseer Arduino?

                Comment


                  #23
                  I see no reason for this to not work with the Arduino plugin API sketch. Just make sure you do not use delay and only send updates to HS when the value changes. Please post back if you get this working or not and we can help you out if you get stuck.

                  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


                    #24
                    Good deal, I have a mega, ethernet hat and sensor kit on order.

                    New user on the plugin and Arduino in general, I've been running RaspberryIO with a Pi0W as a remote board that I think has finally bit the dust.


                    Edit: moved code to current post

                    Comment

                    Working...
                    X