Announcement

Collapse
No announcement yet.

Need help to create script for RS232 sensor

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

    Need help to create script for RS232 sensor

    Hi.
    I'm about to receive a capacitive sensor from CAPNAVI to measure the level of my heating diesel tank.
    The idea is to use the sensor to monitor the level of the tank in realtime, thus providing me with the ability to assess the consumption of the diesel and to make Homeseer give me some kind of warning when a ceirtain level is reached, or even automattically send an e-mail requesting a refill.
    The sensor costs about 120 US Dollars, including the calibration cable and it comes from Russia.

    The sensor is this one:
    http://www.capnavi.com/en/shop/showproduct/12/

    It gives an ASCI output every second with the level of the tank trough a RS232 port, with a resolution of up to 4096 points.

    The data protocol is this one:
    http://www.linhadafrente.net/Luis/Se...20protocol.pdf

    I'm a complete newbee to Homeseer. Is there someone who may be able to help me create a script to measure the level of my tank?

    Thank's

    #2
    Please read the following with regard to Intrinsic Safety. The vapor space in a fuel oil tank is vented to the atmosphere and so can potentially contain an explosive mix of hydrocarbon vapor and air.

    http://en.wikipedia.org/wiki/Intrinsic_safety

    Has the device been certified for use in the EU?

    Best Regards

    Mark

    Comment


      #3
      Good point, Mark!

      Here is an untested script to get you started, luisr320:

      PHP Code:
      sub Main(ByVal strReceived As String)

          
      dim LogResults as string
          dim FrequencyVal 
      as string
          dim TemperatureVal 
      as string
          dim LevelVal 
      as string


          LogResults 
      =        "y1"        ' enable/disable logging
          FrequencyVal =        "y2"        ' 
      received frequency
          TemperatureVal 
      =    "y3"        ' received temperature
          LevelVal =        "y4"        ' 
      received level
      ' use the following to debug your connection to the sensor
          if hs.IsOn(LogResults) then
              hs.writelog ("CAPLLS Data",Cstr(strReceived))
          end if
      Parse the received string
          
      if InStr(strReceived,"=") <> 0 then    ' look for the expected string
              FrequencyVal =         trim(hs.StringItem(strReceived,1,"="))
              TemperatureVal =     trim(hs.StringItem(strReceived,2,"="))
              LevelVal =         trim(hs.StringItem(strReceived,3,"="))
          else
              hs.writelog ("CAPLLS Unexpected String = ",Cstr(strReceived))    
          end if

      end Sub
      '
      =============================================================
      ' Run this once whenever starting HomeSeer
      '
      =============================================================
      sub StartCom(parm as object)            ' no need to pass a parameter

          dim COM1 as string = "1"        ' 
      change to the correct serial port
          dim e 
      as string
          hs
      .closecomport(COM1)            ' close the port in case was already open
          e=hs.OpenComPort(COM1,"19200,n,8,1",1,"CAP_LLS.vb","main")
          if e<> "" then
              hs.writelog "Error opening com"+COM1,e
          else
              hs.writelog "COM"+COM1, "Setup complete for CAP LLS"
          end if

      end Sub 
      http://www.midondesign.com

      Comment


        #4
        Thank for your interest.
        I'm not sure if it is EU certified. I'm guessing it is not. However, the sensor electronics is contained in a cap on top of it that remains outside the tank. The probe is two concentric tubes with air between them. As they are filled with fuel, the capacitive property of these tubes change, being the fuel the dielectric mean.

        I haven't received the sensor yet but will try the script and give you some feedback ASAP.
        How would you go about to make the data arrive to HS wirelessly?

        How about this? http://www.usconverters.com/index.ph...roducts_id=186
        It costs about 50US.

        Or this: http://www.usconverters.com/index.ph...roducts_id=228
        It's also about 50US but uses bluethoot, which my computer already have.
        Last edited by luisr320; March 8, 2011, 03:06 PM.

        Comment

        Working...
        X