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. Development
  3. Gateway ethernet Raspberry + sensors

Gateway ethernet Raspberry + sensors

Scheduled Pinned Locked Moved Development
6 Posts 4 Posters 1.6k Views 4 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.
  • mimaretM Offline
    mimaretM Offline
    mimaret
    wrote on last edited by
    #1

    Hello,

    I have developed a sensor based on Arduino pro mini 3.3v with a DHT 22, an 18b20, a door contact and a battery check. Apart from the battery check which is not satisfactory, everything works very well. This sensor communicates (nrf24 ...) with a gateway ethernet (Mysgw) based on a raspberry. The Gateway communicates with the Openhab 2.0 controller (Openhabianpi). I also have an older generation TellStick module on the controller that works well.
    My questions are: Is it possible to add a DHT22 on the gateway? Is it possible to use the Arduino code on mysgw.cpp? How to communicate between the probe part and the gateway part on the gateway?
    Thank you for your answers and especially for your work.

    Home Assistant, Raspi MQTT Gateway , nodes MySensors

    U 1 Reply Last reply
    0
    • gohanG Offline
      gohanG Offline
      gohan
      Mod
      wrote on last edited by
      #2

      I don't know about adding sensors on raspberry gw, but you can for sure use an UNO as serial gateway connected via usb with the sensors on it

      1 Reply Last reply
      0
      • mimaretM mimaret

        Hello,

        I have developed a sensor based on Arduino pro mini 3.3v with a DHT 22, an 18b20, a door contact and a battery check. Apart from the battery check which is not satisfactory, everything works very well. This sensor communicates (nrf24 ...) with a gateway ethernet (Mysgw) based on a raspberry. The Gateway communicates with the Openhab 2.0 controller (Openhabianpi). I also have an older generation TellStick module on the controller that works well.
        My questions are: Is it possible to add a DHT22 on the gateway? Is it possible to use the Arduino code on mysgw.cpp? How to communicate between the probe part and the gateway part on the gateway?
        Thank you for your answers and especially for your work.

        U Offline
        U Offline
        user2684
        Contest Winner
        wrote on last edited by
        #3

        @mimaret never tried by myself but having a quick look to the code this seems to be possible. When compiling under a raspberry all the arduino's GPIO functions are emulated in a transparent way looks like (https://github.com/mysensors/MySensors/blob/development/drivers/RPi/RPi.h)

        1 Reply Last reply
        0
        • mimaretM Offline
          mimaretM Offline
          mimaret
          wrote on last edited by
          #4

          Thank you for your answers. I wanted to avoid an Arduino. I think I will install the gateway on the OpenHabianpi Raspi and use an arduino as a sensor.

          Home Assistant, Raspi MQTT Gateway , nodes MySensors

          1 Reply Last reply
          0
          • mmaura66M Offline
            mmaura66M Offline
            mmaura66
            wrote on last edited by
            #5

            Hi, i have tryed to put some code directly in examples_linux/mysgw.cpp .

            The code run and work:

            ...
            
            #include <MySensors.h>
            
            #define ARDUINO 100
            // This space is intended to be used to include arduino libraries
            
            #include <MySensors.h>
            //#include <DHT.h>
            
            
            //#define DIGITAL_INPUT_SENSOR 7   // GPIO4
            #define CHILD_ID 1   // Id of the sensor child
            #define SLEEP_TIME 5000
            //MyMessage msg(CHILD_ID, V_STATUS);
            #define DEBUG true
            
            //array of pin used for input button
            static const short int digital_input_pin[] = {7,11,13,15};
            
            bool Tripped[sizeof(digital_input_pin)/sizeof(digital_input_pin[0])];
            bool State[sizeof(digital_input_pin)/sizeof(digital_input_pin[0])];
            MyMessage msg[sizeof(digital_input_pin)/sizeof(digital_input_pin[0])];
            
            #undef ARDUINO
            
            void setup()
            {
                    // Setup locally attached sensors
                    for(unsigned int i=0; i < sizeof(digital_input_pin)/sizeof(digital_input_pin[0]); i ++){
                            if (DEBUG == true){
                                    Serial.print("init:");
                                    Serial.print(i);
                                    Serial.println(digital_input_pin[i]);
                            }
                            pinMode(digital_input_pin[i], INPUT);
                            State[i] = loadState(CHILD_ID+i)?true:false;
                            Tripped[i] = false;
                            msg[i].sensor = i;
                            msg[i].type = V_STATUS;
                    }
            }
            
            void presentation()
            {
                    // Present locally attached sensors here
                    sendSketchInfo("Arduino Jarvis", "0.9");
                    for(unsigned int i=0; i < sizeof(digital_input_pin)/sizeof(digital_input_pin[0]); i ++){
                            present (CHILD_ID+i, S_BINARY);
                    }
            }
            
            void loop()
            {
                    for(unsigned int i=0; i < sizeof(digital_input_pin)/sizeof(digital_input_pin[0]); i ++ ){
                            bool tripped = digitalRead(digital_input_pin[i]);
                            if (Tripped[i] != tripped){
                                    Tripped[i] = tripped;
                                    State[i] = ! State[i];
                                    send(msg[i].set(State[i]));
                                    saveState(CHILD_ID+i, State[i]);
                                    if (DEBUG == true){
                                            Serial.print("send to mg: ");
                                            Serial.print(State[i]);
                                            Serial.print(", for pin: ");
                                            Serial.println(digital_input_pin[i]);
                                    }
                            }
                    }
                    // Sleep until interrupt or timeout
                    // TODO: Just one pin interrrupt !
                    sleep(digitalPinToInterrupt(digital_input_pin[0]), CHANGE, SLEEP_TIME);
            }
            

            I don t know at this time how to add Arduino library like DHT.h, but i have not tryed.

            I have a question, someone know how to switch GPIO intput to GPIO.PUD_UP (pullup) ?

            1 Reply Last reply
            0
            • gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #6

              All you are looking for is the examples and in the build page of the main site

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


              15

              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