analog sensors give the same value

I have the grovepi light sensor on A0 and the sound sensor on A2. When I read the sensors and print I get the same value for both.



this seems … odd…

Hi there, please provide the code and we can talk a look. thanks.



Seeed techsupport team

Bill

it turns out I was reading the analog sensors after reading a temperature/humidity sensor on D4. putting the codeto read the analog sensors BEFORE the temp/humidity sensor solved the problem.



this specific order for accessing analog/digital sensors should possibly be mentioned somewhere in the documentation.



The complete code can be found here: <LINK_TEXT text=“https://github.com/nosarious/curiousity … sensors.py”>https://github.com/nosarious/curiousity-exploration/blob/master/file-save-sensors.py</LINK_TEXT>



The specific code for the sensor values is here:



this code works, giving distinct values for analog sensors:
[code]
sensor_value0 = grovepi.analogRead(sensor0)
sensor_value1 = grovepi.analogRead(sensor1)
sensor_value2 = grovepi.analogRead(sensor2)
#these analog sensor values will be distinct

        #temperature sensor data
        temperatureV = 0
        humidityV = 0            

        [temp,humidity] = grovepi.dht(temp_hum_sensor,0)
        if math.isnan(temp) == False and math.isnan(humidity) == False:
            #print("temp = %.02f C humidity = %.02f%%" %(temp, humidity))
            temperatureV = temp
            humidityV = humidity<e>[/code]</e></CODE>

what doesn’t work:
[code]
#temperature sensor data
temperatureV = 0
humidityV = 0

        [temp,humidity] = grovepi.dht(temp_hum_sensor,blue)

        if math.isnan(temp) == False and math.isnan(humidity) == False:
            #print("temp = %.02f C humidity = %.02f%%" %(temp, humidity))
            temperatureV = temp
            humidityV = humidity
                          
        sensor_value0 = grovepi.analogRead(sensor0)
        sensor_value1 = grovepi.analogRead(sensor1)
        sensor_value2 = grovepi.analogRead(sensor2)
        
        #these analog sensor values will be the same
        <e>[/code]</e></CODE>

I am still having trouble getting information from the GPS, but I shall post that problem in a different post.

Hi, thanks for the sharing. please post GPS as another issue. thanks.

Bill

Hu, You are Using the Analog sensor directly with Raspberry Pi…?

Hi there,



it uses the Grovepi+, it includes the atmel chip to turn the analog signal to I2C signal. thanks.