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. Hardware
  3. Sensors on Gateway?

Sensors on Gateway?

Scheduled Pinned Locked Moved Hardware
12 Posts 6 Posters 6.0k Views 5 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.
  • hekH Offline
    hekH Offline
    hek
    Admin
    wrote on last edited by
    #2

    Not right now. Working on it.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      joshdinsdale
      wrote on last edited by
      #3

      Wow amazing prompt reply! I thought that might be the case as i could find any documentation. Thanks for the reply though. :)

      1 Reply Last reply
      0
      • pwatt01P Offline
        pwatt01P Offline
        pwatt01
        wrote on last edited by
        #4

        @hek said:

        Not right now. Working on it.

        hello Hek.. any news or timeframe on having a sensor on the gateway?

        Thanks!

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

          You can do it right now using the development branch.

          1 Reply Last reply
          1
          • pwatt01P Offline
            pwatt01P Offline
            pwatt01
            wrote on last edited by
            #6

            haha.. time to give it a shot! thanks

            1 Reply Last reply
            0
            • pwatt01P Offline
              pwatt01P Offline
              pwatt01
              wrote on last edited by pwatt01
              #7

              Hello again Hek,

              Just one more question... how? I have crated a serial gateway following this http://www.mysensors.org/build/serial_gateway#wiring-things-up
              and then added the relavent parts from here http://www.mysensors.org/build/humidity

              but am not getting anything showing up in my controller (MyContoller.org). am I on the right path, or going in the wrong direction?

              here is my code for reference

              #define NO_PORTB_PINCHANGES  
              
              #include <MySigningNone.h>
              #include <MyTransportRFM69.h>
              #include <MyTransportNRF24.h>
              #include <MyHwATMega328.h>
              #include <MySigningAtsha204Soft.h>
              #include <MySigningAtsha204.h>
              
              #include <SPI.h>  
              #include <MyParserSerial.h>  
              #include <MySensor.h>  
              #include <stdarg.h>
              #include <PinChangeInt.h>
              #include "GatewayUtil.h"
              #include <DHT.h> 
              
              #define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
              #define INCLUSION_MODE_PIN  3 // Digital pin used for inclusion mode button
              #define RADIO_ERROR_LED_PIN 4  // Error led pin
              #define RADIO_RX_LED_PIN    6  // Receive led pin
              #define RADIO_TX_LED_PIN    5  // the PCB, on board LED
              
              #define CHILD_ID_HUM 0
              #define CHILD_ID_TEMP 1
              #define HUMIDITY_SENSOR_DIGITAL_PIN 22
              
              // NRFRF24L01 radio driver (set low transmit power by default) 
              MyTransportNRF24 transport(RF24_CE_PIN, RF24_CS_PIN, RF24_PA_LEVEL_GW);
              //MyTransportRFM69 transport;
              
              // Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
              //MySigningNone signer;
              //MySigningAtsha204Soft signer;
              //MySigningAtsha204 signer;
              
              // Hardware profile 
              MyHwATMega328 hw;
              
              // Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
              // To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
              #ifdef WITH_LEDS_BLINKING
              MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
              #else
              MySensor gw(transport, hw /*, signer*/);
              #endif
              
              DHT dht;
              float lastTemp;
              float lastHum;
              boolean metric = true; 
              MyMessage msgHum(CHILD_ID_HUM, V_HUM);
              MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
              
              char inputString[MAX_RECEIVE_LENGTH] = "";    // A string to hold incoming commands from serial/ethernet interface
              int inputPos = 0;
              boolean commandComplete = false;  // whether the string is complete
              
              void parseAndSend(char *commandBuffer);
              
              void output(const char *fmt, ... ) {
                 va_list args;
                 va_start (args, fmt );
                 vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
                 va_end (args);
                 Serial.print(serialBuffer);
              }
              
                
              void setup()  
              { 
                gw.begin(incomingMessage, 0, true, 0);
              
                setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
              
                // Add interrupt for inclusion button to pin
                PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
              
              
                // Send startup log message on serial
                serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"),  C_INTERNAL, I_GATEWAY_READY);
              
                dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
                gw.sendSketchInfo("Humidity", "1.0");
                gw.present(CHILD_ID_HUM, S_HUM);
                gw.present(CHILD_ID_TEMP, S_TEMP);
                metric = gw.getConfig().isMetric;
              }
              
              void loop()  
              { 
                gw.process();
              
                checkButtonTriggeredInclusion();
                checkInclusionFinished();
                
                if (commandComplete) {
                  // A command wass issued from serial interface
                  // We will now try to send it to the actuator
                  parseAndSend(gw, inputString);
                  commandComplete = false;  
                  inputPos = 0;
                }
                delay(dht.getMinimumSamplingPeriod());
              
                float temperature = dht.getTemperature();
                if (isnan(temperature)) {
                    Serial.println("Failed reading temperature from DHT");
                } else if (temperature != lastTemp) {
                  lastTemp = temperature;
                  if (!metric) {
                    temperature = dht.toFahrenheit(temperature);
                  }
                  gw.send(msgTemp.set(temperature, 1));
                  Serial.print("T: ");
                  Serial.println(temperature);
                }
                
                float humidity = dht.getHumidity();
                if (isnan(humidity)) {
                    Serial.println("Failed reading humidity from DHT");
                } else if (humidity != lastHum) {
                    lastHum = humidity;
                    gw.send(msgHum.set(humidity, 1));
                    Serial.print("H: ");
                    Serial.println(humidity);
                }
              }
              
              
              /*
                SerialEvent occurs whenever a new data comes in the
               hardware serial RX.  This routine is run between each
               time loop() runs, so using delay inside loop can delay
               response.  Multiple bytes of data may be available.
               */
              void serialEvent() {
                while (Serial.available()) {
                  // get the new byte:
                  char inChar = (char)Serial.read(); 
                  // if the incoming character is a newline, set a flag
                  // so the main loop can do something about it:
                  if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
                    if (inChar == '\n') {
                      inputString[inputPos] = 0;
                      commandComplete = true;
                    } else {
                      // add it to the inputString:
                      inputString[inputPos] = inChar;
                      inputPos++;
                    }
                  } else {
                     // Incoming message too long. Throw away 
                      inputPos = 0;
                  }
                }
              }
              
              
              
              
              1 Reply Last reply
              0
              • hekH Offline
                hekH Offline
                hek
                Admin
                wrote on last edited by
                #8

                This looks like code from master branch (1.5). Make sure to download and install the development branch. Then Just take the humidity example and add:

                // Enable serial gateway
                #define MY_GATEWAY_SERIAL
                

                And remove the MY_RADIO_NRF24 define if you don't have any radio attached.

                1 Reply Last reply
                0
                • pwatt01P Offline
                  pwatt01P Offline
                  pwatt01
                  wrote on last edited by
                  #9

                  Tanks for that. I have it all working now! And also thanks for the quick reply!

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tibillys
                    wrote on last edited by
                    #10

                    I have also tested this and it is working fine with the humidity sensor code(Both on the serial monitor and with Domoticz) but i have also tried the AirQuality sensor code but i cannot make it work . I can see in Serial monitor the values but when i connect the gateway (with the Attached AirQuality) to Domoticz i cannot see any sensor.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Alex B Goode
                      wrote on last edited by
                      #11

                      I wonder why do we have to use the a development branch instead of master?
                      If I want to disable the radio (because I don't have it yet on my serial gateway connected to the controller via usb) so why it is not possible on the master branch?

                      Maybe it is possible to comment out few definitions in myconfig.h or somewhere else in source cpp code?

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

                        @Alex-B-Goode

                        The code that made it possible to have sensors directly on the GW, is only available in development branch, and haven't been migrated to master branch.

                        You could always emulate the serial protocol on the GW your self, and inject that in the sensor data stream. But depending on the MCU you are using, you might run your head against the flash size wall..

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


                        12

                        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