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

  • 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?


  • Mod

    @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.

  • 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 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
    // Enable inclusion mode
    // Enable Inclusion mode button on gateway
    // Inverses behavior of inclusion button (if using external pullup)
    // Set inclusion mode duration (in seconds)
    // Digital pin used for inclusion mode button
    // Set blinking period
    // Inverses the behavior of leds
    // 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
    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(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");
    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": []

  • Mod

    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).

  • 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.

Log in to reply

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.