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.
-
@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 -
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.
-
@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. -
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.
-
@rmarinchev Glad I could help.
If you fix the issue, please come back here and let us know! -
@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 -
@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.
but this is guesswork as I dont have the sensor.
-
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)
-
Can you post photos of your setup please?
I curious to how its connected. -
The setup with the m5stack and the esp32 is as you said, just connect to 35 or 36 and read the analog input.
-
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.
-
Thanks for the photos and nice work there.
Glad its all working for you now.