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. My Project
  3. A little help with my first ever MySensors (and Arduido) sketch: Rotary Angle Sensor (knob) + Nano + esp8266 gateway

A little help with my first ever MySensors (and Arduido) sketch: Rotary Angle Sensor (knob) + Nano + esp8266 gateway

Scheduled Pinned Locked Moved My Project
14 Posts 2 Posters 2.8k 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.
  • vadimbzV vadimbz

    New error. Also is it normal that IDE recognizes nano board, but not its port?

    WARNING: library GroveEncoder claims to run on [arc32] architecture(s) and may be incompatible with your current board which runs on [avr] architecture(s).
    encoderTest:22: error: 'Rotary' does not name a type
    
     Rotary Angle Sensor;
    
     ^
    
    encoderTest:24: error: expected primary-expression before ',' token
    
     MyMessage msg(CHILD_ID, V_VAR1);
    
                           ^
    
    C:\Users\Vadim\Documents\Arduino\encoderTest\encoderTest.ino: In function 'void setup()':
    
    encoderTest:32: error: expected primary-expression before ',' token
    
         present(CHILD_ID, S_CUSTOM);
    
                         ^
    
    exit status 1
    'Rotary' does not name a type
    
    
    mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by
    #4

    @vadimbz seems like the GroveEncoder library doesn't support avr (which is what Arduino Nano and Pro Mini uses). You'll need to find another library.

    1 Reply Last reply
    0
    • vadimbzV Offline
      vadimbzV Offline
      vadimbz
      wrote on last edited by
      #5

      It was never used in fact, and it wasn't used in a reference sketch either. removing it killed only the top error message.

      mfalkviddM 1 Reply Last reply
      0
      • vadimbzV vadimbz

        It was never used in fact, and it wasn't used in a reference sketch either. removing it killed only the top error message.

        mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #6

        @vadimbz could you post your current sketch?

        1 Reply Last reply
        0
        • vadimbzV Offline
          vadimbzV Offline
          vadimbz
          wrote on last edited by
          #7

          Rotary... line before mymessage is causing problems. I think I misunderstood its meaning

          #include <SPI.h>
          #define ROTARY_ANGLE_SENSOR A0
          
          #define ADC_REF 5//reference voltage of ADC is 5v.If the Vcc switch on the seeeduino
                           //board switches to 3V3, the ADC_REF should be 3.3
          #define VCC 5//VCC of the grove interface is normally 5v
          #define FULL_ANGLE 300//full value of the rotary angle is 300 degrees
          // Enable debug prints to serial monitor
          #define MY_DEBUG 
          
          // Enable and select radio type attached
          #define MY_RADIO_NRF24
          #define SN "RotaryAngleSensor"
          #define SV "1.0"
          #define CHILD_ID
          
          #include <MySensors.h>
          
          unsigned long SLEEP_TIME = 100;
          
          Rotary Angle Sensor;
          
          MyMessage msg(CHILD_ID, V_VAR1);
          int lastDegrees;
          
          void setup() 
          {
              Serial.begin(9600);
              pinsInit();
              sendSketchInfo(SN, SV);
              present(CHILD_ID, S_CUSTOM);
          }
          
          void loop() 
          {
              int degrees;
              degrees = getDegree();
              Serial.println(degrees);
              if (degrees != lastDegrees) {
                  send(msg.set(degrees));
                  lastDegrees = degrees;
              }
              
              sleep(SLEEP_TIME);
          }
          
          void pinsInit()
          {
              pinMode(ROTARY_ANGLE_SENSOR, INPUT);
          }
          
          /************************************************************************/
          /*Function: Get the angle between the mark and the starting position    */
          /*Parameter:-void                                                       */
          /*Return:   -int,the range of degrees is 0~300                          */
          int getDegree()
          {
              int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
              float voltage;
              voltage = (float)sensor_value*ADC_REF/1023;
              float degrees = (voltage*FULL_ANGLE)/VCC;
              return degrees;
          }```
          mfalkviddM 1 Reply Last reply
          0
          • vadimbzV vadimbz

            Rotary... line before mymessage is causing problems. I think I misunderstood its meaning

            #include <SPI.h>
            #define ROTARY_ANGLE_SENSOR A0
            
            #define ADC_REF 5//reference voltage of ADC is 5v.If the Vcc switch on the seeeduino
                             //board switches to 3V3, the ADC_REF should be 3.3
            #define VCC 5//VCC of the grove interface is normally 5v
            #define FULL_ANGLE 300//full value of the rotary angle is 300 degrees
            // Enable debug prints to serial monitor
            #define MY_DEBUG 
            
            // Enable and select radio type attached
            #define MY_RADIO_NRF24
            #define SN "RotaryAngleSensor"
            #define SV "1.0"
            #define CHILD_ID
            
            #include <MySensors.h>
            
            unsigned long SLEEP_TIME = 100;
            
            Rotary Angle Sensor;
            
            MyMessage msg(CHILD_ID, V_VAR1);
            int lastDegrees;
            
            void setup() 
            {
                Serial.begin(9600);
                pinsInit();
                sendSketchInfo(SN, SV);
                present(CHILD_ID, S_CUSTOM);
            }
            
            void loop() 
            {
                int degrees;
                degrees = getDegree();
                Serial.println(degrees);
                if (degrees != lastDegrees) {
                    send(msg.set(degrees));
                    lastDegrees = degrees;
                }
                
                sleep(SLEEP_TIME);
            }
            
            void pinsInit()
            {
                pinMode(ROTARY_ANGLE_SENSOR, INPUT);
            }
            
            /************************************************************************/
            /*Function: Get the angle between the mark and the starting position    */
            /*Parameter:-void                                                       */
            /*Return:   -int,the range of degrees is 0~300                          */
            int getDegree()
            {
                int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
                float voltage;
                voltage = (float)sensor_value*ADC_REF/1023;
                float degrees = (voltage*FULL_ANGLE)/VCC;
                return degrees;
            }```
            mfalkviddM Offline
            mfalkviddM Offline
            mfalkvidd
            Mod
            wrote on last edited by
            #8

            @vadimbz just remove it?

            1 Reply Last reply
            0
            • vadimbzV Offline
              vadimbzV Offline
              vadimbz
              wrote on last edited by
              #9

              Cascading errors (

              It seems that I needencoderTest:21: error: expected primary-expression before ',' token
              
               MyMessage msg(CHILD_ID, V_VAR1);
              
                                     ^
              
              C:\Users\Vadim\Documents\Arduino\encoderTest\encoderTest.ino: In function 'void setup()':
              
              encoderTest:29: error: expected primary-expression before ',' token
              
                   present(CHILD_ID, S_CUSTOM);
              
                                   ^
              
              exit status 1
              expected primary-expression before ',' token
              
              
              
              mfalkviddM 1 Reply Last reply
              0
              • vadimbzV Offline
                vadimbzV Offline
                vadimbz
                wrote on last edited by
                #10

                Sketch notations were updated between 2.0 and 2.1.1, weren't they?

                1 Reply Last reply
                0
                • vadimbzV vadimbz

                  Cascading errors (

                  It seems that I needencoderTest:21: error: expected primary-expression before ',' token
                  
                   MyMessage msg(CHILD_ID, V_VAR1);
                  
                                         ^
                  
                  C:\Users\Vadim\Documents\Arduino\encoderTest\encoderTest.ino: In function 'void setup()':
                  
                  encoderTest:29: error: expected primary-expression before ',' token
                  
                       present(CHILD_ID, S_CUSTOM);
                  
                                       ^
                  
                  exit status 1
                  expected primary-expression before ',' token
                  
                  
                  
                  mfalkviddM Offline
                  mfalkviddM Offline
                  mfalkvidd
                  Mod
                  wrote on last edited by
                  #11

                  @vadimbz change

                  #define CHILD_ID
                  

                  to something like

                  #define CHILD_ID 1
                  
                  1 Reply Last reply
                  0
                  • vadimbzV Offline
                    vadimbzV Offline
                    vadimbz
                    wrote on last edited by
                    #12

                    YES, that's it, compiled and flashed... at which point the board started acting out, but I can bounce from here J
                    Thanks!
                    While we're still here, is there a way to connect 3-pin sensors (with one signal pin) to digisparks along with radio? 3-pin radio connection scheme is not an option at the moment unfortunately...
                    ...and I feel like an idiot with a handful of those -)

                    mfalkviddM 1 Reply Last reply
                    0
                    • vadimbzV vadimbz

                      YES, that's it, compiled and flashed... at which point the board started acting out, but I can bounce from here J
                      Thanks!
                      While we're still here, is there a way to connect 3-pin sensors (with one signal pin) to digisparks along with radio? 3-pin radio connection scheme is not an option at the moment unfortunately...
                      ...and I feel like an idiot with a handful of those -)

                      mfalkviddM Offline
                      mfalkviddM Offline
                      mfalkvidd
                      Mod
                      wrote on last edited by mfalkvidd
                      #13

                      @vadimbz could you explain what a 3-pin sensor is? Many of the MySensors examples use sensors with multiple pins so that shouldn't be a problem.

                      1 Reply Last reply
                      0
                      • vadimbzV Offline
                        vadimbzV Offline
                        vadimbz
                        wrote on last edited by vadimbz
                        #14

                        I nwas about talking about digispark (attiny85) board that would be a good match for rolling out mysensors if only had a couple more pins:

                        0_1498271387766_s-l300.jpg

                        I was asking if it's possible to use them after all one way or another, at least for basic sensors with 3 pins (GND, Vcc, Signal) from which we need only Signal.
                        I also mentioned this as known, but unwated solution:
                        https://www.hackster.io/arjun/nrf24l01-with-attiny85-3-pins-74a1f2

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


                        20

                        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