Announcement

Collapse
No announcement yet.

Arduino Uno interface

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

    Arduino Uno interface

    Hi all,

    Been a while since I touched the HA stuff, but have got myself hooked again!

    Anyway I have just discovered Arduino and got myself a UNO and Ethernet shield, and have been playing around with it, got it sending temps to a webpage but that's about as far as my knowledge takes me.

    Does anyone have a plugin or scripts and sketches that I could have all the I/O's from the Uno as devices via ethernet within homeseer? Should be straight forward to someone with more skills than me?

    Any help or direction would be greatly appreciated.

    Thanks

    #2
    Searching the board for Arduino Uno shows that MrHappy wrote a plugin and RMasonjr has written a script. That said it looks like neither have been published so I would ask them if they are willing to assist you.
    Jon

    Comment


      #3
      I have only experimented with the Uno and a standard USB interface (which in turn is actually a serial port). Using the firmata library I could get 8 inputs, 8 outputs (IIRC, the numbers may be slightly off - have a feeling I was not able to use pin 0 and 1) and all of the analogue ins working. There were however a few problems;

      1) The inputs were not sent to HS until one of them changed state, the arduino code said they were notified on startup but for some reason it never worked.
      2) All of the inputs/outputs needed grounding if they were unused to get them to report OK for some reason, I thought the arduino coped with that.
      3) I only supported a single board.

      I never used the arduino in the end, went back over to a picaxe.

      To write from scratch a HS plugin and arduino program is unfortunately not that straightforward, there is quite a bit to think about - I never ever got two way TCP socket communication working in any case for a different plugin I was trying. Serial comms is much easier to figure out.

      In short if you want the sourcecode for the plugin I created you are welcome to it however it is for the serial arduino not a network one, it has the above problems and for all I know may not even work with newer Firmata libraries.

      Comment


        #4
        Assuming you have a simple communication protocol made primarily of request/response, you could code up a no frills mini web server on the Arduino.

        Comment


          #5
          I expanded my script to be a true HS plugin, but have not released it to the community. It is a serial communication, though - not ethernet. I use it to only control relays on a relay shield. I was hoping to release it as an HS3 plugin when the time comes.

          Interfacing to HS is really easy with the arduino code and serial communications. You can pretty much define your own serial commands.
          HS4Pro on a Raspberry Pi4
          54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
          Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

          HSTouch Clients: 1 Android

          Comment


            #6
            Mmm,

            Not as simple as I thought then, I can get HS to fetch the output (temps in this case) from the Ethernet shield and display them in a popup, is there no way of using this to change device values?

            Thanks

            Comment


              #7
              Originally posted by supergee View Post
              Mmm,

              Not as simple as I thought then, I can get HS to fetch the output (temps in this case) from the Ethernet shield and display them in a popup, is there no way of using this to change device values?

              Thanks
              Yes there probably is if you are already getting the data into HS, exactly what are you doing to pop up the temperatures at the minute? It is likely you will need minimal code if you are doing it already and create a virtual device.

              When I said it was not easy it was for full integration between HS & an arduino. I have written in the past a simple IO protocol for a picaxe board and there is a bit to think about, plugins need a bit of work to get them to work seamlessly.

              Comment


                #8
                I have a script below running, at the moment I have the Arduino displaying 5 sensor outputs in the following format:

                1,20.00
                2,20.00
                3,21.01
                4,22.45
                5,18.89

                sub main()


                dim page

                page = hs.GetURL("192.168.2.177","/",TRUE,80)
                msgbox page

                end sub

                So for starters what I would like to do is pull each one of those temp readings and use it as a device value, but would like to communicate 2 both ways eventually.

                Any advice?

                Thanks

                Comment


                  #9
                  If it was not too much trouble I think instead of a seperated list I would put it all on one line and seperate it by another character like # or | so your sensor data is like this;

                  20.00|20.00|21.01|22.45|18.89

                  Then as you are doing you will end up with a string that you can read into HS. This is untested but the sort of script I would use...there is stuff to think about doing like testing whether the page contains the data, checking whether the array has been filled that could prevent any errors coming up

                  Code:
                  Sub Main(ByVal Parms As Object)
                  Dim Page As String = ""
                  Dim HC As String = "T" 'a housecode you want to use
                  Dim DC As Integer = 5 'the base device number you want to start from
                  Dim TSplit() As String
                  
                  Page = hs.GetURL("192.168.2.177","/",TRUE,80)
                  
                  TSplit = Page.Split("|")
                  
                  'then TSplit will contain the temperatures in order that they came from the above data
                  
                  For i As Integer = 0 to 4
                  hs.setdevicestring(HC & (DC + i), TSplit(i) & "°C", True)
                  hs.setdevicestring(HC & (DC + i), (Convert.ToInt32(TSplit(i) * 100)))
                  Next
                  
                  End Sub

                  Comment


                    #10
                    Thanks mrhappy,

                    That's what I was looking for, I will adjust the Arduino sketch and try the script tonight.

                    Cheers for the help

                    Comment


                      #11
                      Hi mrhappy

                      Worked out how to get the Arduino sketch to format the temp readings as suggested but Im getting this error from homeseer?

                      24/07/2012 19:17:22 - Error - Running script, script run or compile error in file: tempscript.txt1025:Expected end of statement in line 4 More info: Expected end of statement

                      Comment


                        #12

                        Comment


                          #13
                          Originally posted by supergee View Post
                          Hi mrhappy

                          Worked out how to get the Arduino sketch to format the temp readings as suggested but Im getting this error from homeseer?

                          24/07/2012 19:17:22 - Error - Running script, script run or compile error in file: tempscript.txt1025:Expected end of statement in line 4 More info: Expected end of statement
                          That was a vb.net script I posted so change the file extension to .vb and give that a go, also on the second line to set the devices it should be hs.setdevicevalue not hs.setdevicestring.

                          Comment


                            #14

                            Comment


                              #15

                              Comment

                              Working...
                              X