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. Implementing Controller(arduino yun) In Gateway

Implementing Controller(arduino yun) In Gateway

Scheduled Pinned Locked Moved Development
16 Posts 5 Posters 5.0k Views 3 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.
  • A Offline
    A Offline
    azlan
    wrote on last edited by
    #1

    Because none of controllers fit my needs(which is hydroponic greenhouse automation), I want to code my greenhouse automation in gateway, the reason for that is there is no MySensors code for Raspberry PI, but there is for arduino.
    What I need is some help with;
    " How do I pull data to use in my controller code which is actually the gateway instead of forwarding to Raspberry PI. Can you help me with a sample code showing how it can be done?".

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

      You don't necessarily need to put the code in the actual gateway if you don't want. You can put it on any node your radio network and let the greenhouse and controller communicate by sending messages between each-other.
      Just set static id's like I do below.

      (development branch example code)

      In your controller sketch

      #define MY_NODE_ID 47
      #define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #include <SPI.h>
      #include <MySensor.h>
      
      void receive(const MyMessage &message) {
        // Handle incoming messages from your "greenhouse"
      }
      

      And in your "greenhouse" sketch

      #define MY_NODE_ID 11
      #define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      #include <SPI.h>
      #include <MySensor.h>
      
      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP)
      
      void setup() {
          msgHum.setDestination(47);
          msgTemp.setDestination(47);
      }
      
      void loop() {
          send(msgHum.set(87));
          send(msgTemp.set(32));
          wait(10000); // Wait 10 seconds
      }
      
      void receive(const MyMessage &message) {
        // Handle incoming messages from your controller
      }
      A 2 Replies Last reply
      0
      • A Offline
        A Offline
        akbooer
        wrote on last edited by akbooer
        #3

        You mention an Arduino Yún. I don't know if this thread Ethernet Gateway on Arduino Yún is of any interest or help. It ports the gateway code to the Arduino bit enabling a controller to run under Linux on the same board.

        1 Reply Last reply
        0
        • hekH hek

          You don't necessarily need to put the code in the actual gateway if you don't want. You can put it on any node your radio network and let the greenhouse and controller communicate by sending messages between each-other.
          Just set static id's like I do below.

          (development branch example code)

          In your controller sketch

          #define MY_NODE_ID 47
          #define MY_RADIO_NRF24
          #define MY_RADIO_RFM69
          #include <SPI.h>
          #include <MySensor.h>
          
          void receive(const MyMessage &message) {
            // Handle incoming messages from your "greenhouse"
          }
          

          And in your "greenhouse" sketch

          #define MY_NODE_ID 11
          #define MY_RADIO_NRF24
          #define MY_RADIO_RFM69
          #include <SPI.h>
          #include <MySensor.h>
          
          MyMessage msgHum(CHILD_ID_HUM, V_HUM);
          MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP)
          
          void setup() {
              msgHum.setDestination(47);
              msgTemp.setDestination(47);
          }
          
          void loop() {
              send(msgHum.set(87));
              send(msgTemp.set(32));
              wait(10000); // Wait 10 seconds
          }
          
          void receive(const MyMessage &message) {
            // Handle incoming messages from your controller
          }
          A Offline
          A Offline
          azlan
          wrote on last edited by
          #4

          @hek I am sorry but I am confused; what do you mean by controller and what do you mean by greenhouse, by greenhouse do you mean sensors and actuators???
          And also do you suggest having one gateway acting as gateway and also have another arduino having gateway code but used as controller???

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

            Maybe you could start with explaining exactly what you want to do? :)

            I presumed you wanted to control something in your green house via radio link from some other place... the "green-house-controller" without the need of setting up a gateway to the outside world (I.e full fledged controller software).

            A 1 Reply Last reply
            0
            • hekH hek

              Maybe you could start with explaining exactly what you want to do? :)

              I presumed you wanted to control something in your green house via radio link from some other place... the "green-house-controller" without the need of setting up a gateway to the outside world (I.e full fledged controller software).

              A Offline
              A Offline
              azlan
              wrote on last edited by
              #6

              @hek No, the problem is there is no controller on this site that I can use, so I have to write code for my controller, simple one just to fit my needs, but the problem is "mysensors library is not used on the raspberry pi" so controller code will have to run on arduino.

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

                You mean a standalone arduino sketch running in your greenhouse? No radio communication or anything else MySensors related?

                Hmm.. sorry, can't help you with that one. Guess you need to learn the Arduino basics and start playing around.

                A 1 Reply Last reply
                0
                • hekH hek

                  You mean a standalone arduino sketch running in your greenhouse? No radio communication or anything else MySensors related?

                  Hmm.. sorry, can't help you with that one. Guess you need to learn the Arduino basics and start playing around.

                  A Offline
                  A Offline
                  azlan
                  wrote on last edited by
                  #8

                  @hek You got it wrong, of course I want sensors and actuators to be controlled wirelessly, if not why would I want to use MySensors Library, but to write controller on raspberry pi without having mysensors library for Rasp.Pi is too complicated for me, so I decided to do it on arduino since you have the library for arduino, that is all.

                  J 1 Reply Last reply
                  0
                  • A azlan

                    @hek You got it wrong, of course I want sensors and actuators to be controlled wirelessly, if not why would I want to use MySensors Library, but to write controller on raspberry pi without having mysensors library for Rasp.Pi is too complicated for me, so I decided to do it on arduino since you have the library for arduino, that is all.

                    J Offline
                    J Offline
                    jkandasa
                    Plugin Developer
                    wrote on last edited by
                    #9

                    @azlan said:

                    @hek You got it wrong, of course I want sensors and actuators to be controlled wirelessly, if not why would I want to use MySensors Library, but to write controller on raspberry pi without having mysensors library for Rasp.Pi is too complicated for me, so I decided to do it on arduino since you have the library for arduino, that is all.

                    @azlan If you elaborate what exactly you are going to do with your greenhouse project, many people will help you here to choose controller for you. I hope definitely a controller will fulfill your requirement.

                    1 Reply Last reply
                    0
                    • hekH hek

                      You don't necessarily need to put the code in the actual gateway if you don't want. You can put it on any node your radio network and let the greenhouse and controller communicate by sending messages between each-other.
                      Just set static id's like I do below.

                      (development branch example code)

                      In your controller sketch

                      #define MY_NODE_ID 47
                      #define MY_RADIO_NRF24
                      #define MY_RADIO_RFM69
                      #include <SPI.h>
                      #include <MySensor.h>
                      
                      void receive(const MyMessage &message) {
                        // Handle incoming messages from your "greenhouse"
                      }
                      

                      And in your "greenhouse" sketch

                      #define MY_NODE_ID 11
                      #define MY_RADIO_NRF24
                      #define MY_RADIO_RFM69
                      #include <SPI.h>
                      #include <MySensor.h>
                      
                      MyMessage msgHum(CHILD_ID_HUM, V_HUM);
                      MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP)
                      
                      void setup() {
                          msgHum.setDestination(47);
                          msgTemp.setDestination(47);
                      }
                      
                      void loop() {
                          send(msgHum.set(87));
                          send(msgTemp.set(32));
                          wait(10000); // Wait 10 seconds
                      }
                      
                      void receive(const MyMessage &message) {
                        // Handle incoming messages from your controller
                      }
                      A Offline
                      A Offline
                      azlan
                      wrote on last edited by
                      #10

                      @hek Hi There,
                      Thank you for your help,
                      I am trying to understand this code. On controller side you define the sensor with first line, but there will be multiple sensors so how do you determine on "void receive()" method that from which sensor we receive the data?

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

                        You'll have to inspect the MyMessage. Many of the actuator examples does this.

                        A 1 Reply Last reply
                        0
                        • hekH hek

                          You'll have to inspect the MyMessage. Many of the actuator examples does this.

                          A Offline
                          A Offline
                          azlan
                          wrote on last edited by
                          #12

                          @hek So you do not want to help no more...

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

                            msg.sender contains node id of sender

                            https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyMessage.h#L280-L292

                            A 1 Reply Last reply
                            0
                            • hekH hek

                              msg.sender contains node id of sender

                              https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyMessage.h#L280-L292

                              A Offline
                              A Offline
                              azlan
                              wrote on last edited by
                              #14

                              @hek Hi There,
                              Does MySensors library has any similarities with RF24.h library, for example for receiving data could this"radio.read(&text, sizeof(text));" be used.

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                phill
                                wrote on last edited by
                                #15

                                hey guys, so i want to make a controller for my green house could anyone help me? from what i need to build what platform should i use and a wiring schematic to fit such a design? plz help

                                A 1 Reply Last reply
                                0
                                • P phill

                                  hey guys, so i want to make a controller for my green house could anyone help me? from what i need to build what platform should i use and a wiring schematic to fit such a design? plz help

                                  A Offline
                                  A Offline
                                  azlan
                                  wrote on last edited by
                                  #16

                                  @phill No one is helping here.............

                                  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