🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    How to get grove pin input?

    Cores
    2
    13
    23.8k
    Loading More Posts
    • 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.
    • R
      rmarinchev
      last edited by

      Hello,

      I am using m5stack basic and I have connected a GSR sensor to it with the grove connector. What I cannot seem to figure out is how to get the reading from the sensor. I tried analogRead(20), analogRead(21), analogRead(22) and many others that I found in suggestions on other threads in this forum. No luck however...

      This is my code:

      #include "M5Stack.h"
      
      #define INPUT_PIN 21
      #define READ_RATE 400  // How often the serial link is read, in milliseconds
      // The setup() function runs once each time the micro-controller starts
      void setup()
      {
         // init lcd, serial, not init sd card
         M5.begin(true, false, true);
         pinMode(INPUT_PIN, INPUT);
         M5.Lcd.setTextSize(5);
      }
      
      // Add the main program code into the continuous loop() function
      void loop()
      {
         int reading = analogRead(INPUT_PIN);
         M5.Lcd.println(reading);
         Serial.println(reading);
      
         M5.update();
         delay(READ_RATE);
      }
      

      I apologize for the noob question. I'm new to this. Thank you in advance for even taking the time to read this thread.

      ajb2k3A 1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3 @rmarinchev
        last edited by

        @rmarinchev said in How to get grove pin input?:

        Hello,

        I am using m5stack basic and I have connected a GSR sensor to it with the grove connector. What I cannot seem to figure out is how to get the reading from the sensor. I tried analogRead(20), analogRead(21), analogRead(22) and many others that I found in suggestions on other threads in this forum. No luck however...

        This is my code:

        #include "M5Stack.h"
        
        #define INPUT_PIN 21
        #define READ_RATE 400  // How often the serial link is read, in milliseconds
        // The setup() function runs once each time the micro-controller starts
        void setup()
        {
           // init lcd, serial, not init sd card
           M5.begin(true, false, true);
           pinMode(INPUT_PIN, INPUT);
           M5.Lcd.setTextSize(5);
        }
        
        // Add the main program code into the continuous loop() function
        void loop()
        {
           int reading = analogRead(INPUT_PIN);
           M5.Lcd.println(reading);
           Serial.println(reading);
        
           M5.update();
           delay(READ_RATE);
        }
        

        I apologize for the noob question. I'm new to this. Thank you in advance for even taking the time to read this thread.

        What is the GSR sensor?
        The Grove port on the M5Stack Core is only a digital (i2c) port and doesn't work with analogue input. To use analogue sensors you need to use the analog pins on the baseplate.

        Its still "Work In Progress" but this may help you.
        UIFlow Handbook

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • R
          rmarinchev
          last edited by

          Hello,

          Thank you for your reply. The GSR sensor is "Grove GSR Seeeduino Sensor" and in the documentation it says the output is analog. I will try connecting it to the analog pins.

          ajb2k3A 1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3 @rmarinchev
            last edited by ajb2k3

            @rmarinchev Thanks, it was hard to help without know what sensor you were using.
            connect the yellow wire (pin1) to pins 35 or 36 (AD) on the base of the core.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • R
              rmarinchev
              last edited by

              Thank you, that worked. However the sensor values are completely through the rought and I cannot modify it with the resistor as described in the GSR documentation. I think its because of the digital to analog convertion or its just an incompatibility. Anyway, this is outside the scope of this forum. Thank you for your help.

              ajb2k3A 3 Replies Last reply Reply Quote 1
              • ajb2k3A
                ajb2k3 @rmarinchev
                last edited by

                @rmarinchev Glad I could help.
                If you fix the issue, please come back here and let us know!

                UIFlow, so easy an adult can learn it!
                If I don't know it, be patient!
                I've ether not learned it or am too drunk to remember it!
                Author of the WIP UIFlow Handbook!
                M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                1 Reply Last reply Reply Quote 0
                • ajb2k3A
                  ajb2k3 @rmarinchev
                  last edited by

                  @rmarinchev said in How to get grove pin input?:

                  Thank you, that worked. However the sensor values are completely through the rought and I cannot modify it with the resistor as described in the GSR documentation. I think its because of the digital to analog convertion or its just an incompatibility. Anyway, this is outside the scope of this forum. Thank you for your help.

                  Have you read this?
                  https://community.seeedstudio.com/Arduino+and+Galvanic+Skin+Response+(GSR)+Sensor-p-306.html

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  1 Reply Last reply Reply Quote 0
                  • ajb2k3A
                    ajb2k3 @rmarinchev
                    last edited by

                    @rmarinchev said in How to get grove pin input?:

                    Thank you, that worked. However the sensor values are completely through the rought and I cannot modify it with the resistor as described in the GSR documentation. I think its because of the digital to analog convertion or its just an incompatibility. Anyway, this is outside the scope of this forum. Thank you for your help.

                    based on the code on the seedstudio site, this UIFlow code may work.
                    alt text

                    but this is guesswork as I dont have the sensor.

                    UIFlow, so easy an adult can learn it!
                    If I don't know it, be patient!
                    I've ether not learned it or am too drunk to remember it!
                    Author of the WIP UIFlow Handbook!
                    M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                    1 Reply Last reply Reply Quote 0
                    • R
                      rmarinchev
                      last edited by

                      Yes, I tried this a few weeks ago with another esp32 board. I tried it also with arduino uno and seeeduino v4.2 boards. They work fine, however the esp32 was also giving wrong readings. To be honest, I bought the m5stack because I saw it had groove port, but I am new to this and I didn't know it can only get digital readings. I tried dividing by 4 since the esp32 gets a reading of 0-4092 and the other boards give a value of 0-1023. However the esp32 is still wrong. I also tried changing the

                          analogReadResolution(10)
                          analogSetWidth(10)
                      

                      But still the esp32 was giving false readings and I couldn't calibrate it as shown in the tutorials for gsr sensor (by turning the resistance until I get a reading of 512 without using the sensor)

                      1 Reply Last reply Reply Quote 0
                      • ajb2k3A
                        ajb2k3
                        last edited by

                        Can you post photos of your setup please?
                        I curious to how its connected.

                        UIFlow, so easy an adult can learn it!
                        If I don't know it, be patient!
                        I've ether not learned it or am too drunk to remember it!
                        Author of the WIP UIFlow Handbook!
                        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                        1 Reply Last reply Reply Quote 0
                        • R
                          rmarinchev
                          last edited by rmarinchev

                          The setup with the m5stack and the esp32 is as you said, just connect to 35 or 36 and read the analog input.

                          0_1550782876454_20190221_180129.jpg

                          0_1550782885866_20190221_180209.jpg

                          1 Reply Last reply Reply Quote 0
                          • R
                            rmarinchev
                            last edited by

                            And the seeedino is pretty straight forward. Here I have also a bluetooth module, since the seeeduino values are accurate, so I am using it as part of my prototype. The GSR sensor has a groove connector that plugs straight in the seeeduino port.

                            0_1550782964075_20190221_175604.jpg

                            0_1550782968750_20190221_175453.jpg

                            1 Reply Last reply Reply Quote 0
                            • ajb2k3A
                              ajb2k3
                              last edited by

                              Thanks for the photos and nice work there.
                              Glad its all working for you now.

                              UIFlow, so easy an adult can learn it!
                              If I don't know it, be patient!
                              I've ether not learned it or am too drunk to remember it!
                              Author of the WIP UIFlow Handbook!
                              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post