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. Is it possible to add a Sensor to a Gateway directly?

Is it possible to add a Sensor to a Gateway directly?

Scheduled Pinned Locked Moved Troubleshooting
5 Posts 2 Posters 2.0k 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.
  • F Offline
    F Offline
    free118
    wrote on last edited by
    #1

    Hello all,
    just a question.
    Is it possible to add a Sensor (Analog In) directly to a Gateway (arduino) and comunicate this value over USB?

    What I want to do is the following:
    I've one Sensor which communicate over the Gateway to my Pimatic (over serial USB)
    Now I want to add a second Sensor, which is physicaly very close to the Gateway.
    So i want to add it there, and it should communicate to Pimatic as well.
    Kind of an internal "Sensor" device.

    So is this possible? If yes how?

    Thanks
    Free

    mfalkviddM 1 Reply Last reply
    0
    • F free118

      Hello all,
      just a question.
      Is it possible to add a Sensor (Analog In) directly to a Gateway (arduino) and comunicate this value over USB?

      What I want to do is the following:
      I've one Sensor which communicate over the Gateway to my Pimatic (over serial USB)
      Now I want to add a second Sensor, which is physicaly very close to the Gateway.
      So i want to add it there, and it should communicate to Pimatic as well.
      Kind of an internal "Sensor" device.

      So is this possible? If yes how?

      Thanks
      Free

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      @free118 Welcome to the MySensors community!

      Yes it is possible. Just add it to the gateway sketch, just as if you were adding it to a normal sensor node sketch.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        free118
        wrote on last edited by free118
        #3

        Ok great,
        that's what I've done.
        But which Node and Child ID is needed for this. So that the Input will communicate as a "Sensor" to the gateway.

        Because the Pimatic plugin need to know where to look.

        
        // Enable debug prints to serial monitor
        #define MY_DEBUG
        // Enable and select radio type attached
        #define MY_RADIO_NRF24
        //#define MY_RADIO_RFM69
        // Set LOW transmit power level as default, if you have an amplified NRF-module and
        // power your radio separately with a good regulator you can turn up PA level.
        #define MY_RF24_PA_LEVEL RF24_PA_LOW
        
        // Enable serial gateway
        #define MY_GATEWAY_SERIAL
        
        // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
        #if F_CPU == 8000000L
        #define MY_BAUD_RATE 115200
        #endif
        
        // Enable inclusion mode
        #define MY_INCLUSION_MODE_FEATURE
        // Enable Inclusion mode button on gateway
        //#define MY_INCLUSION_BUTTON_FEATURE
        
        // Inverses behavior of inclusion button (if using external pullup)
        //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
        
        // Set inclusion mode duration (in seconds)
        #define MY_INCLUSION_MODE_DURATION 60
        // Digital pin used for inclusion mode button
        //#define MY_INCLUSION_MODE_BUTTON_PIN  3
        
        // Set blinking period
        #define MY_DEFAULT_LED_BLINK_PERIOD 300
        
        // Inverses the behavior of leds
        //#define MY_WITH_LEDS_BLINKING_INVERSE
        
        // Flash leds on rx/tx/err
        // Uncomment to override default HW configurations
        //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
        //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
        //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
        
        #include <MySensors.h>
        #define ArrayLenth 10
        #define PH_SENSOR_ANALOG_PIN A0
        unsigned long lastSend = 0;
        static const unsigned long SEND_FREQUENCY = 5000;
        
        float lastPhValue;
        static const float deltaPhValue = 0.5;
        
        #define MY_NODE_ID 10
        #define CHILD_ID_PH_LOCAL 1
        
        MyMessage msg(0, V_PH);
        void setup()
        {
        	// Setup locally attached sensors
        }
        
        double analogReadAverage(uint8_t pin, unsigned long ms)
        {
            ...
        	
            return average;
        }
        
        float getPH()
        {
        		...
                
            if (sendTime || abs(PhValue - lastPhValue) > deltaPhValue)
            {
                Serial.print("pH:");
                Serial.print(PhValue, 2);
               // Serial.println(" ");
                       
                lastPhValue = PhValue;
                
                //send(msg.set(PhValue, 1));
                send(msg.set(PhValue, 51));
               
            }
          return lastPhValue;
        }
        
        
        void presentation()
        {
        	sendSketchInfo("PH Local","1.1");
          present(CHILD_ID_PH_LOCAL,S_WATER_QUALITY); 
        }
        
        void loop()
        {
        
          float ph = getPH();
          
        	// Send locally attached sensor data here
        }
        

        Here the working Pimatic config for a Sensor through a gateway.

              "plugin": "mysensors",
              "driver": "serialport",
              "protocols": "1.5.1",
              "startingNodeId": 1,
              "driverOptions": {
                "//": "'/dev/ttyUSB0' if using serial Gateway",
                "serialDevice": "/dev/ttyUSB1",
                "baudrate": 115200
              }```
        
        ```{
              "id": "phmeter",
              "name": "pHmeter",
              "class": "MySensorsPH",
              "nodeid": 9,
              "sensorid": 0,
              "xAttributeOptions": []
            }```
        
        
         Thanks
        mfalkviddM 1 Reply Last reply
        0
        • F free118

          Ok great,
          that's what I've done.
          But which Node and Child ID is needed for this. So that the Input will communicate as a "Sensor" to the gateway.

          Because the Pimatic plugin need to know where to look.

          
          // Enable debug prints to serial monitor
          #define MY_DEBUG
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          //#define MY_RADIO_RFM69
          // Set LOW transmit power level as default, if you have an amplified NRF-module and
          // power your radio separately with a good regulator you can turn up PA level.
          #define MY_RF24_PA_LEVEL RF24_PA_LOW
          
          // Enable serial gateway
          #define MY_GATEWAY_SERIAL
          
          // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
          #if F_CPU == 8000000L
          #define MY_BAUD_RATE 115200
          #endif
          
          // Enable inclusion mode
          #define MY_INCLUSION_MODE_FEATURE
          // Enable Inclusion mode button on gateway
          //#define MY_INCLUSION_BUTTON_FEATURE
          
          // Inverses behavior of inclusion button (if using external pullup)
          //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
          
          // Set inclusion mode duration (in seconds)
          #define MY_INCLUSION_MODE_DURATION 60
          // Digital pin used for inclusion mode button
          //#define MY_INCLUSION_MODE_BUTTON_PIN  3
          
          // Set blinking period
          #define MY_DEFAULT_LED_BLINK_PERIOD 300
          
          // Inverses the behavior of leds
          //#define MY_WITH_LEDS_BLINKING_INVERSE
          
          // Flash leds on rx/tx/err
          // Uncomment to override default HW configurations
          //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
          //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
          //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
          
          #include <MySensors.h>
          #define ArrayLenth 10
          #define PH_SENSOR_ANALOG_PIN A0
          unsigned long lastSend = 0;
          static const unsigned long SEND_FREQUENCY = 5000;
          
          float lastPhValue;
          static const float deltaPhValue = 0.5;
          
          #define MY_NODE_ID 10
          #define CHILD_ID_PH_LOCAL 1
          
          MyMessage msg(0, V_PH);
          void setup()
          {
          	// Setup locally attached sensors
          }
          
          double analogReadAverage(uint8_t pin, unsigned long ms)
          {
              ...
          	
              return average;
          }
          
          float getPH()
          {
          		...
                  
              if (sendTime || abs(PhValue - lastPhValue) > deltaPhValue)
              {
                  Serial.print("pH:");
                  Serial.print(PhValue, 2);
                 // Serial.println(" ");
                         
                  lastPhValue = PhValue;
                  
                  //send(msg.set(PhValue, 1));
                  send(msg.set(PhValue, 51));
                 
              }
            return lastPhValue;
          }
          
          
          void presentation()
          {
          	sendSketchInfo("PH Local","1.1");
            present(CHILD_ID_PH_LOCAL,S_WATER_QUALITY); 
          }
          
          void loop()
          {
          
            float ph = getPH();
            
          	// Send locally attached sensor data here
          }
          

          Here the working Pimatic config for a Sensor through a gateway.

                "plugin": "mysensors",
                "driver": "serialport",
                "protocols": "1.5.1",
                "startingNodeId": 1,
                "driverOptions": {
                  "//": "'/dev/ttyUSB0' if using serial Gateway",
                  "serialDevice": "/dev/ttyUSB1",
                  "baudrate": 115200
                }```
          
          ```{
                "id": "phmeter",
                "name": "pHmeter",
                "class": "MySensorsPH",
                "nodeid": 9,
                "sensorid": 0,
                "xAttributeOptions": []
              }```
          
          
           Thanks
          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          I have no experience with Pimatic, but the child ID will be CHILD_ID_PH_LOCAL and the node ID will be 0 (gateways always have node ID=0).

          1 Reply Last reply
          0
          • F Offline
            F Offline
            free118
            wrote on last edited by
            #5

            Thanks for the answer. I tried this and it didn't work. I've started a thread in pimatic forum as well. Maybe they know how to do this.
            Thanks

            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