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. General Discussion
  3. Serial Gateway

Serial Gateway

Scheduled Pinned Locked Moved General Discussion
9 Posts 3 Posters 2.9k 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.
  • skatunS Offline
    skatunS Offline
    skatun
    wrote on last edited by
    #1

    Hi
    I am struggling to figure out how to use the serial API, the protocol is easy to understand, but how to implement is harder.

    I have an arduino nano that i would like to use as the gateway, to this i have 6 dht11 humidity/temperature sensors attached and 4 led strips. The ledstrips currently uses the neopixel library.

    The nano is attached to a rpi running openhab through usb(maybe i should use the serial on gpio instead?), i have made simple arduino sketch that test the serial protocol Serial.print(13;7;1;0;2;1\n) and the open hab intpretates it nicely. But now I am stuck, how can i modify the humidity code to send it out on serial protocol? And can I somehow make an array of DHT object and loop through them? And how can i combine the neopixel into the serial.api? How should the message look like coming into the serial from openhab?

    Any help is highly appreciated:)

    1 Reply Last reply
    0
    • tbowmoT Offline
      tbowmoT Offline
      tbowmo
      Admin
      wrote on last edited by
      #2

      @skatun

      Is the DHT11 sensors connected directly to the arduino, that is connected to the r-pi?

      In that case, you can use dev branch, as it has support for adding sensors directly to the GW, and run without a radio connected.

      skatunS 1 Reply Last reply
      0
      • D Offline
        D Offline
        drock1985
        wrote on last edited by
        #3

        Hi @skatun

        The Gateway does all the interpreting from the Nodes; so no need to modify the Humidity example sketch to send over serial. When the Humidity Node transmits the data to the Serial Gateway, the gateway will give you the output. See here for the MySensors Serial API (which is what you have, serial gateway. Same goes though for MQTT and Ethernet) for how your message is structured. I can't help on the OpenHAB side of things unfortunately, never had much luck with it. Hoping OpenHAB2 is more friendly.

        Good luck!

        My Projects
        2 Door Chime Sensor
        Washing Machine Monitor

        skatunS 1 Reply Last reply
        0
        • tbowmoT tbowmo

          @skatun

          Is the DHT11 sensors connected directly to the arduino, that is connected to the r-pi?

          In that case, you can use dev branch, as it has support for adding sensors directly to the GW, and run without a radio connected.

          skatunS Offline
          skatunS Offline
          skatun
          wrote on last edited by
          #4

          @tbowmo Yes it is connected directly to nano. When i have 6 nodes, will you collect them in an array or define them 6 objects? Do you have a link to dev branch?

          1 Reply Last reply
          0
          • D drock1985

            Hi @skatun

            The Gateway does all the interpreting from the Nodes; so no need to modify the Humidity example sketch to send over serial. When the Humidity Node transmits the data to the Serial Gateway, the gateway will give you the output. See here for the MySensors Serial API (which is what you have, serial gateway. Same goes though for MQTT and Ethernet) for how your message is structured. I can't help on the OpenHAB side of things unfortunately, never had much luck with it. Hoping OpenHAB2 is more friendly.

            Good luck!

            skatunS Offline
            skatunS Offline
            skatun
            wrote on last edited by
            #5

            @drock1985 I can help you with the openhab binding.. How can i modify this code so that it prints it out on serial instead of transmitting on RF?

            1 Reply Last reply
            0
            • skatunS Offline
              skatunS Offline
              skatun
              wrote on last edited by
              #6

              This is how i have normally done similiar task before i started looking into mysensor.

              #include "DHT.h"
              
              DHT dht;
              
              pinsDHT = (2,4,7,8,10,12)
              childNode = (0,1,2,3,4,5)
              int GatewayID = 1
              
              void setup()
              {
                Serial.begin(9600);
                  for (int i=0 ;i<6:i++) {
                             dht(i).setup(pinsDHT(i)); // data pin 2
                  }
              }
              
              void loop()
              {
                //delay(dht.getMinimumSamplingPeriod());
               for (int i=0 ;i<6:i++) {
                Serial.print(GatewayID);
                Serial.print(",");
                Serial.print(childNode(i));
                Serial.print(",");
                Serial.print(1);
                Serial.print(",");
                Serial.print(S_TEMP);
                Serial.print(",");
                Serial.print(dht(i).getTemperature());
                Serial.print("\n");
              
              //debug
               Serial.println();
              
              
                Serial.print(GatewayID);
                Serial.print(",");
                Serial.print(childNode(i));
                Serial.print(",");
                Serial.print(1);
                Serial.print(",");
                Serial.print(S_HUM);
                Serial.print(",");
                Serial.print(dht(i).getHumidity());
                Serial.print("\n");
              
              //debug
               Serial.println();
              }
                
              }```
              1 Reply Last reply
              0
              • tbowmoT Offline
                tbowmoT Offline
                tbowmo
                Admin
                wrote on last edited by
                #7

                @skatun

                Mysensors is build on a radio network, where you have a gateway connecting the radio network, to a controller of some sort (OpenHAB).

                When people talks about "Nodes" they mean independent arduinos with a radio, each with one (or more) sensor "children". These nodes can then be placed all over the house, or what ever you want to monitor.

                From what I undestand, you have another setup, where you have a number of DHT11 sensors connected to one arduino, which you want to act as a "GW" from the before mentioned DHT11 sensors, to OpenHAB. And you do not want to use the radio links. In that case, you need to use development branch of Mysensors, which is available on github : https://github.com/mysensors/Arduino (Default branch is development)

                skatunS 1 Reply Last reply
                0
                • tbowmoT tbowmo

                  @skatun

                  Mysensors is build on a radio network, where you have a gateway connecting the radio network, to a controller of some sort (OpenHAB).

                  When people talks about "Nodes" they mean independent arduinos with a radio, each with one (or more) sensor "children". These nodes can then be placed all over the house, or what ever you want to monitor.

                  From what I undestand, you have another setup, where you have a number of DHT11 sensors connected to one arduino, which you want to act as a "GW" from the before mentioned DHT11 sensors, to OpenHAB. And you do not want to use the radio links. In that case, you need to use development branch of Mysensors, which is available on github : https://github.com/mysensors/Arduino (Default branch is development)

                  skatunS Offline
                  skatunS Offline
                  skatun
                  wrote on last edited by
                  #8

                  @tbowmo From that developers page i get the libraries, but somehow i can not find the serial tutorial for DHT11. I found this: link

                  Yes and you are completly right ""Nodes" they mean independent arduinos" ,These nodes can then be placed all over the house,. However i had the chance when i rebuilt my flat my flat to run empty pipes all over the place to my fusebox. Since arduino needs power I dont see why i should run 2 wires, when i can run4 wires and skip the hole RF part.

                  When I am finished my system would look like:

                  1 arduino Mega in fusebox with 6 dht22 sensors ,12 motion sensors, 6 light sensor, 6CO sensors, 4 led strips connected to it. USB to RPI(0.3m)
                  1 arduino micro 3.3V under kitchen, with ledstrip , a servo(gate for roomba), 1 IR transmitter RS485 or serial to RPI(8m)
                  1 arduino micro 3.3V in bar with led strip, 4 relays and 4 buttons RS485 or serial to RPI(14m)
                  1 arduino micro 3.3V in tv bench, ledstrip,1 relay for tv lift and 2 butttons RS485 or serial to RPI( 9m)
                  1 arduino micro 3.3V in hallway,ledstrip,1 relay for electric wardrobe and 3 buttons RS485 or serial to RPI(2m)
                  1 arduino micro 3.3V at balcony, ledstrip,7 relays for hetater, rollers,BBQ,hammock etc, 6 buttons RS485 or serial to RPI(17m)

                  But currently i am just installing the the arduino nano in fusebox with a ledstrip and dht11 sensor to it. Start simple...

                  1 Reply Last reply
                  0
                  • tbowmoT Offline
                    tbowmoT Offline
                    tbowmo
                    Admin
                    wrote on last edited by
                    #9

                    @skatun

                    As I said, there are not that much documentation on running without radio :) If I remember right, you could take the basic DHT11 example, remove radio stuff, and add a MY_SERIAL_GATEWAY define (look in the code to see the right names of the defines).

                    However, one thing regarding your setup, what is the distance from the arduino mega, to your DHT11 sensors? I don't think they are meant to be used with long cable runs. Also the LED strips, are they PWM controlled? How about RF noise emiting from those wire runs?

                    You could probably use rs485 as protocol for mysensors (does require arduino at each node).

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


                    9

                    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