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. Troubleshooting
  3. serial reading

serial reading

Scheduled Pinned Locked Moved Troubleshooting
34 Posts 5 Posters 16.7k Views 2 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.
  • W wannabee

    You perl program needs to tell the arudion Gateway if it Imperial or Metric it should you for it's number. The gateway will forward that information to the node

    Here is post where I explain how it works.
    http://forum.mysensors.org/topic/62/#315

    Basicly the arduion gatweway don't controll high level stuff. It only controlls the low level stuff. the raido communication.

    Your perl program needs to do all the higlevel stuff like responed to request from the network about raido_id, metric system, storing the data,etc. This is what the vera does. you are replacing the vera with your program so now you have to do all the stuff. a quick way forward is to translate https://github.com/mysensors/Vera/blob/master/L_Arduino.lua to perl. You have to build some more function since the Vera is doing stuff like storing data and configuration hat is not in the lua-file.

    This is what I have done in python see https://github.com/wbcode/ham and it transform the mysensor api to/from openhab api.

    /WB

    epierreE Offline
    epierreE Offline
    epierre
    Hero Member
    wrote on last edited by
    #14

    @wannabee I'm desesperatly (as a newbee ) trying to send the message back, but it doesn't seem to work with

    echo -en '1;255;4;13;M' > /dev/ttyUSB0

    any idea ? my script doesn't seem to write too, strange...

    hekH 1 Reply Last reply
    0
    • epierreE epierre

      @wannabee I'm desesperatly (as a newbee ) trying to send the message back, but it doesn't seem to work with

      echo -en '1;255;4;13;M' > /dev/ttyUSB0

      any idea ? my script doesn't seem to write too, strange...

      hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #15

      @epierre

      Don't forget the newline character.

      epierreE 1 Reply Last reply
      0
      • hekH hek

        @epierre

        Don't forget the newline character.

        epierreE Offline
        epierreE Offline
        epierre
        Hero Member
        wrote on last edited by
        #16

        @hek right the -n option removed newline, but I have still the same behavior. Can both gateway and sensors on the same machine usb port make a difference in this ?

        So this one should be good, but no behavior change (same when writing from perl to the port):

        echo -e '1;255;4;13;M' > /dev/ttyUSB0

        does reading through perl locks it ? well I'm new on this ...

        1 Reply Last reply
        0
        • epierreE Offline
          epierreE Offline
          epierre
          Hero Member
          wrote on last edited by
          #17

          Looks like one got to the sensor:

          Sent ack msg to 0 0 0 0 0
          Rx: fr=0,to=1,la=0,ci=255,mt=4,t=13,cr=57(ok): M 0 0 0 0
          Message addressed for this node. 0 0 0 0
          675 Relaying message back to gateway.
          Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=216: 20.0

          Relaying message back to gateway. 0 0 0 0
          Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=216: 20.0 0 0 0 0
          676 Ack: received OK
          T: 20.00
          Relaying message back to gateway.
          Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=162: 56.0
          Ack: received OK
          H: 56.00

          Relaying message back to gateway. 0 0 0 0
          Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=216: 20.0 0 0 0 0
          676 Ack: received OK
          T: 20.00

          Relaying message back to gateway.
          Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=162: 56.0
          Ack: received OK
          H: 56.00

          707 Relaying message back to gateway.
          Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=84: 55.0
          Ack: receive timeout
          H: 55.00

          Relaying message back to gateway. 0 0 0 0
          Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=84: 55.0 0 0 0 0
          Ack: receive timeout 0 0 0 0
          H: 55.00 0 0 0 0

          then nothing...

          I unplugged the node, plugged it back and it is asking again the metric...

          1 Reply Last reply
          0
          • epierreE Offline
            epierreE Offline
            epierre
            Hero Member
            wrote on last edited by
            #18
            This post is deleted!
            1 Reply Last reply
            0
            • epierreE Offline
              epierreE Offline
              epierre
              Hero Member
              wrote on last edited by epierre
              #19

              I'm getting closer, since I launched the arduino console log my scripts works, and is able so write back the answer...

              Starting
              1 255 0 17 1.3b3 (67f4ca1)
              1 255 4 7 0
              1 255 4 14 Humidity
              1 255 4 15 1.0
              1 255 4 13 0
              W : 1;255;4;13;M
              1 1 1 0 21.0
              1 0 1 1 52.0

              looks like it is sleeping forever ?

              1 Reply Last reply
              0
              • epierreE Offline
                epierreE Offline
                epierre
                Hero Member
                wrote on last edited by epierre
                #20

                Hello,

                Looks like it's good, in one hour I've had 12 metering values, given I modified the timer in the sensor to 10 instead of 30. It is reporting only changed values which is smart (should be documented, extra value !)

                1 1 1 0 21.0
                1 0 1 1 52.0
                1 0 1 1 53.0
                1 0 1 1 54.0
                1 1 1 0 20.0
                1 1 1 0 21.0
                1 1 1 0 20.0
                1 0 1 1 55.0
                1 0 1 1 54.0
                1 0 1 1 55.0
                1 0 1 1 54.0
                1 0 1 1 55.0
                1 1 1 0 21.0

                1 Reply Last reply
                0
                • epierreE Offline
                  epierreE Offline
                  epierre
                  Hero Member
                  wrote on last edited by
                  #21

                  well... I tried to replicate this on a cubitruck2 (IBOX), does not work...

                  I did on the i5 a test to see conf of usb port that works with:

                  stty -F /dev/ttyUSB1
                  speed 115200 baud; line = 0;
                  kill = ^H; min = 0; time = 0;
                  ignbrk -brkint -icrnl -imaxbel
                  -opost -onlcr
                  -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

                  I tried to replicate it to the cubie:
                  stty -F /dev/ttyUSB1 cs8 115200 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -ixon -crtscts kill ^H min 0

                  but still nothing... any idea ?

                  1 Reply Last reply
                  0
                  • epierreE Offline
                    epierreE Offline
                    epierre
                    Hero Member
                    wrote on last edited by
                    #22

                    my bad, wrong reading script... works straight with the above parameters, should check if it works without... well no arduino ide run before it works for me now, I'm a bit farther than the arduino.cc forum ;-)

                    1 Reply Last reply
                    0
                    • epierreE Offline
                      epierreE Offline
                      epierre
                      Hero Member
                      wrote on last edited by
                      #23

                      Hello,

                      Works like a charm, I now receive the DHT11 values and I am able to post it to a (now) static node in domoticz (could be used for every system with a json posting interface).

                      This is where it can be tricky, you need both Temp and Humidity to report, so I have to wait to have them both in memory to push a report.

                      I expect to use a sqlite3 database locally to handle the last known value and the status/association of a node and its device. Doing so requires that either I handle all in a conf file, or that creation of device are driven by the script which I can handle too (maybe specific to domoticz).

                      1 Reply Last reply
                      0
                      • jendrushJ Offline
                        jendrushJ Offline
                        jendrush
                        wrote on last edited by
                        #24

                        I have little success too. I modified some code from other project, and now i can report temperatures(DS18B20), temperatures + humidity(DHT22), motion sensor to Domoticz. Today i will try to handle turning on, and off a switch, and also i am planning to modify relay code to handle my wireless 433MHz wall plugs to work as normal relay. Next time maybe reading status of power meter? But in this case i see a problem - how to read last value of acumulated energy from Domoticz? Now some information about solution. Serial gateway is connected to Raspberry Pi(Domoticz), and there is Node.js script. Script can read, and send messages through serial, and post links to Domoticz by JSON.

                        epierreE 1 Reply Last reply
                        2
                        • jendrushJ Offline
                          jendrushJ Offline
                          jendrush
                          wrote on last edited by
                          #25

                          And screenshoot http://screenshooter.net/1288732/gimyqda

                          BulldogLowellB 1 Reply Last reply
                          0
                          • jendrushJ jendrush

                            And screenshoot http://screenshooter.net/1288732/gimyqda

                            BulldogLowellB Offline
                            BulldogLowellB Offline
                            BulldogLowell
                            Contest Winner
                            wrote on last edited by
                            #26

                            @jendrush

                            very nice!

                            1 Reply Last reply
                            0
                            • jendrushJ Offline
                              jendrushJ Offline
                              jendrush
                              wrote on last edited by jendrush
                              #27

                              Now i am lack of arduinos, DHT22 is connected directly to atmega on breadboard:) Maybe i recieve this week few of 4 i've ordered lately.

                              I have one Stellaris launchpad, someone tried to make it work with mysensors? :)

                              1 Reply Last reply
                              0
                              • hekH Offline
                                hekH Offline
                                hek
                                Admin
                                wrote on last edited by
                                #28

                                :thumbsup:

                                1 Reply Last reply
                                0
                                • jendrushJ jendrush

                                  I have little success too. I modified some code from other project, and now i can report temperatures(DS18B20), temperatures + humidity(DHT22), motion sensor to Domoticz. Today i will try to handle turning on, and off a switch, and also i am planning to modify relay code to handle my wireless 433MHz wall plugs to work as normal relay. Next time maybe reading status of power meter? But in this case i see a problem - how to read last value of acumulated energy from Domoticz? Now some information about solution. Serial gateway is connected to Raspberry Pi(Domoticz), and there is Node.js script. Script can read, and send messages through serial, and post links to Domoticz by JSON.

                                  epierreE Offline
                                  epierreE Offline
                                  epierre
                                  Hero Member
                                  wrote on last edited by epierre
                                  #29

                                  @jendrush you can see from my Xively script how to do it: http://www.domoticz.com/wiki/Perl_for_Domoticz#Pachube_.2F_Cosm_.2F_Xively, in short you get all the nodes, you aprse the one you need, and you get the data field, first one is instant, second cumulated separated by a semicolon (";").

                                  To push data, please see http://www.domoticz.com/wiki/Domoticz_API/JSON_URL's#Electric.28Instant_and_Counter.29, I updated it recently.

                                  BTW, as you can see in the first script, I post all my values to Xyvely/COSM/Pachube... but this is another story for I made modification yesterday and I've not reported them to the wiki yet.

                                  1 Reply Last reply
                                  0
                                  • epierreE Offline
                                    epierreE Offline
                                    epierre
                                    Hero Member
                                    wrote on last edited by
                                    #30

                                    Ok so today I've added a conf file reading, and started to work on the database model (hardware-device-sensor) in sqlite3 to keep track of last known value and last affected sensor id. This speeds up the whole thing at startup.

                                    Next step is to store all devices data in the table, and update them whenever they are received.

                                    Afterward, I'll try creating a new sensor automatically, and then try to extend it to other sensors type.

                                    If anyone is interrested in trying it (very beta yet...)...

                                    jendrushJ 1 Reply Last reply
                                    1
                                    • epierreE epierre

                                      Ok so today I've added a conf file reading, and started to work on the database model (hardware-device-sensor) in sqlite3 to keep track of last known value and last affected sensor id. This speeds up the whole thing at startup.

                                      Next step is to store all devices data in the table, and update them whenever they are received.

                                      Afterward, I'll try creating a new sensor automatically, and then try to extend it to other sensors type.

                                      If anyone is interrested in trying it (very beta yet...)...

                                      jendrushJ Offline
                                      jendrushJ Offline
                                      jendrush
                                      wrote on last edited by
                                      #31

                                      @epierre I wish to see the code:)

                                      1 Reply Last reply
                                      0
                                      • epierreE Offline
                                        epierreE Offline
                                        epierre
                                        Hero Member
                                        wrote on last edited by epierre
                                        #32

                                        Hello,

                                        This is very alpha, it handles only one node with id=1 till I manage the sqlite3 database fully (data model is not right yet...).
                                        mysensors-gw.pl : main file, reader, tested only with DHT11 Temp+Humidity
                                        .conf-mysensors : conf file to set serial port, domoticz IP/PORT, hardware device (for future virtual sensors creation, I prefer to leave it configurable by now)

                                        github repository

                                        You will need those packages:
                                        sudo apt-get install libdevice-serialport-perl libdatetime-perl libdbd-sqlite3-perl libdbi-perl sqlite3 libjson-perl libfile-slurp-unicode-perl libwww-perl libconfig-simple-perl

                                        Discussion:

                                        • What I need to see is how to handle existing nodes that wouldn't be in the database, I thought of a config file ? In RFX433 devices, when you change the battery, it resets all ... painfull... here I would like to avoid this situation but this will be complicated without a GUI.
                                        • Other point, to send orders, I would need to have some JSON API, or a script that is called from the DZ to interract with the sensors. the Gateway.py from @wannabee does it.
                                        • I will try maybe to implement the same conf file than @wanabee link text for he has identified the same issues as me, meaning all mapping of a sensor will be done in the conf file (see wiki)
                                        jendrushJ 1 Reply Last reply
                                        0
                                        • epierreE epierre

                                          Hello,

                                          This is very alpha, it handles only one node with id=1 till I manage the sqlite3 database fully (data model is not right yet...).
                                          mysensors-gw.pl : main file, reader, tested only with DHT11 Temp+Humidity
                                          .conf-mysensors : conf file to set serial port, domoticz IP/PORT, hardware device (for future virtual sensors creation, I prefer to leave it configurable by now)

                                          github repository

                                          You will need those packages:
                                          sudo apt-get install libdevice-serialport-perl libdatetime-perl libdbd-sqlite3-perl libdbi-perl sqlite3 libjson-perl libfile-slurp-unicode-perl libwww-perl libconfig-simple-perl

                                          Discussion:

                                          • What I need to see is how to handle existing nodes that wouldn't be in the database, I thought of a config file ? In RFX433 devices, when you change the battery, it resets all ... painfull... here I would like to avoid this situation but this will be complicated without a GUI.
                                          • Other point, to send orders, I would need to have some JSON API, or a script that is called from the DZ to interract with the sensors. the Gateway.py from @wannabee does it.
                                          • I will try maybe to implement the same conf file than @wanabee link text for he has identified the same issues as me, meaning all mapping of a sensor will be done in the conf file (see wiki)
                                          jendrushJ Offline
                                          jendrushJ Offline
                                          jendrush
                                          wrote on last edited by
                                          #33

                                          @epierre I will try to use MySQL with my project.

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


                                          11

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.1k

                                          Posts


                                          Copyright 2025 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