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. Template sketch for flexible use with many different sensor types

Template sketch for flexible use with many different sensor types

Scheduled Pinned Locked Moved Development
7 Posts 4 Posters 1.9k 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.
  • Dave MyersD Offline
    Dave MyersD Offline
    Dave Myers
    wrote on last edited by
    #1

    I've created a companion Arduino sketch / library to go along with the MySensors library. The companion library is designed with flexibility and inheritance to allow easy configuration of attached sensors and actuators. I.e. just tell the library you want to add a gpio output, an analog input, a PWM output, ... and the library handles all the necessary code. This makes the base Arduino sketch much simpler and allows for easier configuration and programming of modules with different and varying features.

    I'm midway through development and have some more features to add, but I wanted to solicit some feedback to see if there were general ideas or concepts that I am missing. Note: I'm not a professional programmer and am learning some of this as I go!

    The software is specifically designed for (and only tested with) the Home Assistant controller - though I hope other controller software is compatible.

    Github here: https://github.com/brahmafear/MySensors_Node. Best starting point is the Arduino sketch listed in the examples folder.

    Cheers.

    Dave MyersD 2 Replies Last reply
    2
    • Dave MyersD Dave Myers

      I've created a companion Arduino sketch / library to go along with the MySensors library. The companion library is designed with flexibility and inheritance to allow easy configuration of attached sensors and actuators. I.e. just tell the library you want to add a gpio output, an analog input, a PWM output, ... and the library handles all the necessary code. This makes the base Arduino sketch much simpler and allows for easier configuration and programming of modules with different and varying features.

      I'm midway through development and have some more features to add, but I wanted to solicit some feedback to see if there were general ideas or concepts that I am missing. Note: I'm not a professional programmer and am learning some of this as I go!

      The software is specifically designed for (and only tested with) the Home Assistant controller - though I hope other controller software is compatible.

      Github here: https://github.com/brahmafear/MySensors_Node. Best starting point is the Arduino sketch listed in the examples folder.

      Cheers.

      Dave MyersD Offline
      Dave MyersD Offline
      Dave Myers
      wrote on last edited by
      #2

      @Dave-Myers said:

      Oops - forgot to add: for MySensors 2.x only.

      1 Reply Last reply
      0
      • Dave MyersD Dave Myers

        I've created a companion Arduino sketch / library to go along with the MySensors library. The companion library is designed with flexibility and inheritance to allow easy configuration of attached sensors and actuators. I.e. just tell the library you want to add a gpio output, an analog input, a PWM output, ... and the library handles all the necessary code. This makes the base Arduino sketch much simpler and allows for easier configuration and programming of modules with different and varying features.

        I'm midway through development and have some more features to add, but I wanted to solicit some feedback to see if there were general ideas or concepts that I am missing. Note: I'm not a professional programmer and am learning some of this as I go!

        The software is specifically designed for (and only tested with) the Home Assistant controller - though I hope other controller software is compatible.

        Github here: https://github.com/brahmafear/MySensors_Node. Best starting point is the Arduino sketch listed in the examples folder.

        Cheers.

        Dave MyersD Offline
        Dave MyersD Offline
        Dave Myers
        wrote on last edited by
        #3

        @Dave-Myers

        Example of a full Arduino sketch with 4 sensors/actuators using this library:

        #define MY_RADIO_NRF24
        
        #include <SPI.h>
        #include <MySensors.h>
        #include "MySensors_Node.h"
          
        MySensors_Node node("Sample", "0.01");
        
        void presentation() {
        
          MySensors_Node_Sensor_Gpio_Out nsgo( 11, "Simple LED 1", 5, true );
          node.add_sensor( &nsgo );
        
          node.add_sensor(  new MySensors_Node_Sensor_Gpio_In( 13, "Simple Motion", 2, true, INPUT_PULLUP, 500 ) );
          node.add_sensor(  new MySensors_Node_Sensor_Analog_In( 14, "Analog In", A0, true, 1024, 10000 ) );
          node.add_sensor(  new MySensors_Node_Sensor_Pwm( 15, "PWM LED", 6, true, true, 255 ) );
        
          node.present();
        }
        
        void receive( const MyMessage &msg ) {
          node.receive( msg );
        }
        
        
        void setup() {
          node.setup();
        }
        
        void loop() {
          node.loop();
        }
        
        fernando alvarez buyllaF 1 Reply Last reply
        0
        • Dave MyersD Dave Myers

          @Dave-Myers

          Example of a full Arduino sketch with 4 sensors/actuators using this library:

          #define MY_RADIO_NRF24
          
          #include <SPI.h>
          #include <MySensors.h>
          #include "MySensors_Node.h"
            
          MySensors_Node node("Sample", "0.01");
          
          void presentation() {
          
            MySensors_Node_Sensor_Gpio_Out nsgo( 11, "Simple LED 1", 5, true );
            node.add_sensor( &nsgo );
          
            node.add_sensor(  new MySensors_Node_Sensor_Gpio_In( 13, "Simple Motion", 2, true, INPUT_PULLUP, 500 ) );
            node.add_sensor(  new MySensors_Node_Sensor_Analog_In( 14, "Analog In", A0, true, 1024, 10000 ) );
            node.add_sensor(  new MySensors_Node_Sensor_Pwm( 15, "PWM LED", 6, true, true, 255 ) );
          
            node.present();
          }
          
          void receive( const MyMessage &msg ) {
            node.receive( msg );
          }
          
          
          void setup() {
            node.setup();
          }
          
          void loop() {
            node.loop();
          }
          
          fernando alvarez buyllaF Offline
          fernando alvarez buyllaF Offline
          fernando alvarez buylla
          wrote on last edited by
          #4

          @Dave-Myers this is asoweme will try in this days but sound amazing thanks for sharing.

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

            Looks great @Dave-Myers!

            This is an very nice start of the "Helper Classes" I was thinking of back in the old architecture document.

            Dave MyersD 1 Reply Last reply
            0
            • hekH hek

              Looks great @Dave-Myers!

              This is an very nice start of the "Helper Classes" I was thinking of back in the old architecture document.

              Dave MyersD Offline
              Dave MyersD Offline
              Dave Myers
              wrote on last edited by
              #6

              @hek

              Nice. Hadn't seen that doc before. Please let me know if there are any changes you suggest.

              1 Reply Last reply
              0
              • wesW Offline
                wesW Offline
                wes
                wrote on last edited by
                #7

                Have a look at https://github.com/mysensors/NodeManager/

                (I think this only became available since the last reply in this thread).

                Blog: https://www.wes.id.au/
                Nodes: Arduino Pro Mini ATMega328P 3.3V 8MHz, RFM69 433MHz, Canton Power CE024 0.8-3.3V regulator & single AA battery
                Gateway & Controller: Raspberry Pi 3 + Home Assistant

                1 Reply Last reply
                1
                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.0k

                Posts


                Copyright 2019 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