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. Noob--API help?

Noob--API help?

Scheduled Pinned Locked Moved Development
6 Posts 3 Posters 2.2k 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.
  • S Offline
    S Offline
    SteveO1234
    wrote on last edited by
    #1

    Hi,

    Loving this stuff! I'm ready to move on from basics and want to start more original work. Hence the need to dive into the API.

    Is there any guide, beyond the description on the API page as to how it all fits together?

    For example I'm trying to run my loop() code based on the state of the device in Vera. The hardware and program runs OK, and the node is talking to the GW. I'd really benefit from some kind of tutorial. Is there such a thing? I don't seem to grasp it all yet.

    Thanks in advance,
    --Steve

    BulldogLowellB 1 Reply Last reply
    0
    • S Offline
      S Offline
      SteveO1234
      wrote on last edited by
      #2

      I solved my immediate concern by gleening off other sketches. It's another way to learn. Now I can control my loop by checking the state on the controller.

      Learning a little along the way. My question remains--is there a resource available beyond the API page that outlines the steps to embrace this awesome technology?

      Thanks,
      --Steve

      1 Reply Last reply
      0
      • S SteveO1234

        Hi,

        Loving this stuff! I'm ready to move on from basics and want to start more original work. Hence the need to dive into the API.

        Is there any guide, beyond the description on the API page as to how it all fits together?

        For example I'm trying to run my loop() code based on the state of the device in Vera. The hardware and program runs OK, and the node is talking to the GW. I'd really benefit from some kind of tutorial. Is there such a thing? I don't seem to grasp it all yet.

        Thanks in advance,
        --Steve

        BulldogLowellB Offline
        BulldogLowellB Offline
        BulldogLowell
        Contest Winner
        wrote on last edited by
        #3

        @SteveO1234 said:

        I don't seem to grasp it all yet.

        building off of @SteveO1234 's good advice, well you can always ask directed questions here.

        @SteveO1234 said:

        I'm trying to run my loop() code based on the state of the device in Vera.

        try posting your code (between three back-ticks (accent like character below the tilde(~) character on my mac)

        typing this:

        Screen Shot 2015-05-19 at 10.37.34 PM.png

        looks like this:

        myCode
        is 
        here
        in this box
        

        when posted.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SteveO1234
          wrote on last edited by
          #4

          Thanks for the encouragement and help! So it seems as I need to create this message handler function that is referenced in the gw.begin().. And from that point any incoming messages are routed through the function?

          //
          void incomingMessage(const MyMessage &message)
          {
            if (message.isAck())
            {
              Serial.println("This is an ack from gateway");
            }
            if (message.type == V_LIGHT)
            {
              // Change relay state
              state = message.getBool();
              Serial.print ("State = ");
              Serial.print (state);
              // Store state in eeprom
              gw.saveState(ID, state);
              Serial.print("Incoming change for sensor:");
              Serial.print(message.sensor);
              Serial.print(", New status: ");
              Serial.println(message.getBool());
            }
          }
          //
          
          BulldogLowellB 1 Reply Last reply
          1
          • J Offline
            J Offline
            Jan Gatzke
            wrote on last edited by
            #5

            Correct.

            1 Reply Last reply
            0
            • S SteveO1234

              Thanks for the encouragement and help! So it seems as I need to create this message handler function that is referenced in the gw.begin().. And from that point any incoming messages are routed through the function?

              //
              void incomingMessage(const MyMessage &message)
              {
                if (message.isAck())
                {
                  Serial.println("This is an ack from gateway");
                }
                if (message.type == V_LIGHT)
                {
                  // Change relay state
                  state = message.getBool();
                  Serial.print ("State = ");
                  Serial.print (state);
                  // Store state in eeprom
                  gw.saveState(ID, state);
                  Serial.print("Incoming change for sensor:");
                  Serial.print(message.sensor);
                  Serial.print(", New status: ");
                  Serial.println(message.getBool());
                }
              }
              //
              
              BulldogLowellB Offline
              BulldogLowellB Offline
              BulldogLowell
              Contest Winner
              wrote on last edited by
              #6

              @SteveO1234 said:

              Thanks for the encouragement and help! So it seems as I need to create this message handler function that is referenced in the gw.begin().. And from that point any incoming messages are routed through the function?

              yup,

              So, you then have to manage a variable Vera-side that will then get polled from time to time by your Arduino. that request is bounced back as a message, that you handle as you noted above.

              Look at this example to see how you can manage the change of a stored variable in the Vera device... you merely need to update the stored variable in a change of state, and poll as frequently as you want to update.

              You can also send Vera html messages that in-turn would generate a message to a node in MySensors space.

              have fun!

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


              17

              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