Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. OpenHAB
  4. [Tutorial] openHAB with serial gateway

[Tutorial] openHAB with serial gateway

Scheduled Pinned Locked Moved OpenHAB
78 Posts 25 Posters 76.3k Views 16 Watching
  • 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.
  • Dave DanD Offline
    Dave DanD Offline
    Dave Dan
    wrote on last edited by
    #57

    hey @nikos1671,

    good to hear you have it under control.

    Also, please take a look to the 'sensorToItemsMap' definition. If I remember correctly, the last item in the last item, otherwise the compiler is waiting for another item.

    This is something that happened to me every time I include any new item (you know, copy & paste ... bad thing :P).

    The fact that you have to wait hours to get the battery status is odd. When I restart one of my nodes ( one with battery level) I have the information inmediately available, well ... as soon as the node sends the information, and fully refreshed in openhab site.

    it's true I've had different update speeds but basically because I did my first tests with ah Raspberry Pi 1 and now I have all the system working in a Pi 2 ... so goes faster (very much).

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SiLeX
      wrote on last edited by
      #58

      Hey guys, on my Raspberry Pi 2 the first rule execution takes about 15 seconds. If you have changed the rules file, the xtent logic has to be re-compiled to java code again. But after the first rule execution it takes only about 10-50ms for execution.

      Also, @nikos1671 I would turn off the DEBUG mode on your gateway. Receiving data works and this is what you would debug. You see incoming data without debug, too so you can securely get rid of it :grin:

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nikos1671
        wrote on last edited by
        #59

        Hi ,

        I think the problem is this msg 3;255;4;0;0;FFFFFFFFFFFFFFFF0300 is this something with the OTA firmware? i think the rule dont recognise this msg and give an error (Error during the execution of rule 'Decode incoming MySensors data': 5). Can the author of the rule please confirm if this it the problem of the error??

        S 1 Reply Last reply
        0
        • N nikos1671

          Hi ,

          I think the problem is this msg 3;255;4;0;0;FFFFFFFFFFFFFFFF0300 is this something with the OTA firmware? i think the rule dont recognise this msg and give an error (Error during the execution of rule 'Decode incoming MySensors data': 5). Can the author of the rule please confirm if this it the problem of the error??

          S Offline
          S Offline
          SiLeX
          wrote on last edited by SiLeX
          #60

          @nikos1671 In case of unhandled messages (when there is no openhab item assigned to this nodeID;childID;-combination in your sensorToItemsMap), they will just be ignored (and print the data field).
          This happens here in the code: https://gist.github.com/gersilex/13f39b3419427b35636a#file-default-rules-L211

          This will look like this:

          3;255;4;0;0;FFFFFFFFFFFFFFFF0300
          No item matches nodeId=3, childId=255. Data received: FFFFFFFFFFFFFFFF0300
          

          However, this was never tested with debugging enabled on the Gateway. This is why I asked you to disable debugging and recompile/reupload the code to your gateway arduino without the DEBUG flag inside MyConfig.h.

          There is a know problem which is not catched currently:

          • Data can only be decoded, if the String has exactly 6 fields, seperated by a semicolon.

          Please go and try to disable the DEBUG on your gateway arduino.

          1 Reply Last reply
          0
          • HenryWhiteH Offline
            HenryWhiteH Offline
            HenryWhite
            wrote on last edited by
            #61

            Can someone help me? I want to integrate a motion sensor in OpenHAB but I don't know how to distinguish between the motion start and end. here's my openhab console log:

            bewegungsmelder_fehler.png

            1 Reply Last reply
            0
            • HenryWhiteH Offline
              HenryWhiteH Offline
              HenryWhite
              wrote on last edited by
              #62

              Can somebody help..?

              1 Reply Last reply
              0
              • Dave DanD Offline
                Dave DanD Offline
                Dave Dan
                wrote on last edited by
                #63

                Try removing DEBUG in the Serial GW and review messages.

                I receive a 0 or 1 depending if the motion is detected or the sensor is resetting to normal status.

                HenryWhiteH 1 Reply Last reply
                0
                • Dave DanD Dave Dan

                  Try removing DEBUG in the Serial GW and review messages.

                  I receive a 0 or 1 depending if the motion is detected or the sensor is resetting to normal status.

                  HenryWhiteH Offline
                  HenryWhiteH Offline
                  HenryWhite
                  wrote on last edited by
                  #64

                  @Dave-Dan i tried it, but the motion sensor is still sending only zero's.... even if it is not triggered.
                  I got these motion sensors: http://www.amazon.de/Pyroelectrische-Infrarot-Bewegung-Sensor-Detektor/dp/B008AESDSY/

                  1 Reply Last reply
                  0
                  • HenryWhiteH Offline
                    HenryWhiteH Offline
                    HenryWhite
                    wrote on last edited by
                    #65

                    When I look at the serial monitor output for my motion sensor, it clearly gives me a "0" or "1" depending if movement is detected or not.

                    But when I look at the serial monitor of my gateway, it only receives the same message no matter if motion started (motion sensor serial monitor: 1) or ended (motion sensor serial monitor: 0)

                    12345.png

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      TimO
                      Hero Member
                      wrote on last edited by
                      #66

                      @HenryWhite The node is requesting for an id and not sending any status. You'll need to define a static id in the sketch of your node:

                      http://www.mysensors.org/download/sensor_api_15#the-full-api

                      Look for "Starting up the library" and the "begin()" function.

                      HenryWhiteH 1 Reply Last reply
                      1
                      • T TimO

                        @HenryWhite The node is requesting for an id and not sending any status. You'll need to define a static id in the sketch of your node:

                        http://www.mysensors.org/download/sensor_api_15#the-full-api

                        Look for "Starting up the library" and the "begin()" function.

                        HenryWhiteH Offline
                        HenryWhiteH Offline
                        HenryWhite
                        wrote on last edited by
                        #67

                        @TimO thank you so much! it works now. Any idea why i had to assign a static id? i thought the gateway should tell the node a dynamic id automatically..

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          TimO
                          Hero Member
                          wrote on last edited by
                          #68

                          @HenryWhite You're welcome. The id is assigned by the controller, in your case OpenHAB. There is a post in the forum about how to add a rule for id assignment, but I don't use it myself.

                          1 Reply Last reply
                          1
                          • L Offline
                            L Offline
                            lundebc
                            wrote on last edited by
                            #69

                            I have a real noob question, and I am way better with the electronics that I am the software. I can see my motion detector show up in my gateway, and in the events.log, so I know that I am getting to the Raspberry Pi I deployed opneHAB on.

                            Here's some detail:
                            So I have build the MySensors.org motion detector (and a separate temp/humidity sensor), loaded up the NRF24l01+ and PIR.
                            I created a gateway out of a nano with NRF24l01+.
                            I followed the tutorial on how to do the serial bindings.
                            I see in the terminal window runtime.busevents that the motion detector is detecting movement, and later changing back to 0, along with the other sensor I have, which is the DHT11 for temp and humidity.

                            2016-01-10 18:48:12 - Arduino state updated to 0;0;3;0;9;read: 4-4-0 s=1,c=1,t=0,pt=7,l=5:21.0
                            4;1;1;0;0;21.0
                            2016-01-10 18:48:12 - livingTemp01 state updated to 21.0
                            2016-01-10 18:49:32 - Arduino state updated to 0;0;3;0;9;read: 10-10-0 s=1,c=1,t=16,pt=0,l=1:1
                            10;1;1;0;16;1
                            2016-01-10 18:49:35 - Arduino state updated to 0;0;3;0;9;read: 10-10-0 s=1,c=1,t=16,pt=0,l=1:0
                            10;1;1;0;16;0

                            My confusion is how this software all works to get just the information from the gateway to the screen.
                            I know you have to declare an item in the demo.items file, and that item needs to be in the sitemap to display. but I do not understand how you get the status from the gateway? Can someone point me to some simple examples that include the mysensor.org PIR sensor? How does the item declaration get the knowledge of the change that the gateway is receiving from the sensor? I have read through several documents and tutorials, but I am missing this bit of information.

                            1 Reply Last reply
                            0
                            • L Offline
                              L Offline
                              lundebc
                              wrote on last edited by
                              #70

                              Ah, I finally see it, it was staring me in the face in the rules section. You identify via the msgType then assign in the rule. Doh!

                              1 Reply Last reply
                              0
                              • P poeml

                                @poeml more precisely, the Nano's FTDI chip connects to the booting Raspberry, but instead of registering a single device there are 4 (!) log lines claiming registering 4 devices (very funny), and none of the devices are bound.

                                May 23 23:16:21 bramble kernel: [    3.738087] usb 1-1.5: new full-speed USB device number 5 using dwc_otg
                                May 23 23:16:21 bramble kernel: [    4.283520] usb 1-1.5: new full-speed USB device number 6 using dwc_otg
                                May 23 23:16:21 bramble kernel: [    4.768136] usb 1-1.5: new full-speed USB device number 7 using dwc_otg
                                May 23 23:16:21 bramble kernel: [    5.268161] usb 1-1.5: new full-speed USB device number 8 using dwc_otg
                                
                                

                                I don't find a way to trigger re-registering the device, or power-cycle the USB port, via software. I can only power-cycle the whole USB bridge, which means that the LED goes out (the Ethernet chip is switched off as well...) and LED goes on again, but with the same faulty registering as when booting.

                                 # cat reset-usb
                                #!/bin/bash
                                echo 0 > /sys/bus/usb/devices/1-1/authorized
                                sleep 1
                                echo 1 > /sys/bus/usb/devices/1-1/authorized
                                

                                Unplugging and replugging always works.

                                For the record: Raspberry Pi version 2 with the 4 USB ports, just updated to Debian 8.0 (Jessie). I didn't check with Debian Wheezy if it worked then. The Nano was linked from MySensors store I believe and works great otherwise. I have two of them and both have the same problem (or the Raspi's USB stack has the problem, who knows).

                                P Offline
                                P Offline
                                poeml
                                wrote on last edited by
                                #71

                                @poeml following up myself, using an external, powered USB hub indeed fixed the problem. The USB adapter is now correctly usable after system bootup. (I use the official Raspberry Foundation hub, which promises to avoid issues with backpowering.)

                                1 Reply Last reply
                                0
                                • HenryWhiteH Offline
                                  HenryWhiteH Offline
                                  HenryWhite
                                  wrote on last edited by HenryWhite
                                  #72

                                  It just took me 2 hours to realize that you should not use

                                  import java.util.*
                                  

                                  when you want to use timer operations like

                                  if (timer=! null) {
                                  ...
                                  }
                                  

                                  Without importing java.util.* , everything works as expected. Someone has an idea why this is the case? Can you reproduce my problem?

                                  1 Reply Last reply
                                  0
                                  • mark_vennM Offline
                                    mark_vennM Offline
                                    mark_venn
                                    wrote on last edited by
                                    #73

                                    Thanks for this great post. Just what I need to get a handle on using openHAB with MySensors!

                                    1 Reply Last reply
                                    0
                                    • NickBuilderN Offline
                                      NickBuilderN Offline
                                      NickBuilder
                                      wrote on last edited by NickBuilder
                                      #74

                                      Can someone please assist me regarding this serial connection setup.
                                      I can see in my event log that I receive updates of the Arduino state as below:

                                      Arduino state updated to 99;1;1;0;0;23.7
                                      99;0;1;0;1;37.2
                                      
                                      

                                      And also in the openhab.log file I get the following types of messages:

                                      [DEBUG] [b.serial.internal.SerialDevice:225  ] - Received message '99;0;1;0;1;37.6
                                      ' on serial port /dev/ttyUSB99
                                      

                                      But the rule is for some reason not initiated I guess as the println and logInfo i I've added to the top of the rule is absent from the logs. I can see from the tutorial and your posts that you get log information like below but these I cant find in any log.

                                      [INFO ] [runtime.busevents             ]
                                      

                                      Possibly I'm missing something in my logback.xml settings or perhaps there is some other reason to this which also might explain why my rule is not started. Perhaps its because I'm using a newer binding for the serial connection? (org.openhab.binding.serial-1.8.3.jar)

                                      Any help would be much appreciated!

                                      Update 1: Perhaps I'll try the mysensors binding and if I'm more successful with that approach I'll skip this serial binding altogether.

                                      Update 2: Ok, I will be using the mysensors binding for the serial connection. I tried it last night and it just worked! And this serial binding approach also demands some quite extensive rule handling of the incoming messages which is not the case with mysensors binding. I think I read somewhere that the mysensors binding will also be available for Openhab 2.0 so hopefully I can continue using it also in the future.

                                      My recommendation for new users of the serial gateway (who also uses openhap as a controller) is to go for the mysensors binding!

                                      1 Reply Last reply
                                      0
                                      • NickBuilderN Offline
                                        NickBuilderN Offline
                                        NickBuilder
                                        wrote on last edited by
                                        #75
                                        This post is deleted!
                                        1 Reply Last reply
                                        0
                                        • HenryWhiteH Offline
                                          HenryWhiteH Offline
                                          HenryWhite
                                          wrote on last edited by
                                          #76

                                          @TimO is it possible to send commands to actuators with this method? I have a LED Dimmer Actuator and don't know what I have to do in OpenHAB to send commands to this actuator over the serial gateway..

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          14

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular