Alcohol sensor for raspberry pi


#1

Hi,

I have alcohol sensor of Grove pi. I didn’t find python sample program in grove pi libraries in Raspberry pi. will you provide sample code for it?

Thanking you,
Amol Desai


#2

if you look here the code is pretty basic and should be easy to convert.

I don’t have the sensor, but it would be something like

from time import sleep
import grovepi

analogInDatPin = 0
heaterSelPin = 15
sensorValue = 0
grovepi.pinMode(heaterSelPin,"OUTPUT")
grovepi.digitalWrite(heaterSelPin, 1)

while True:
    grovepi.DigitalWrite(heaterSelPin,0)
    sensorValue = grovepi.AnalogRead(analogInDatPin)
    result = 1023 - sensorValue
    sleep(0.1) # Time in seconds.

Note: I have not tested this as I don’t have the sensor and currently working with Microsoft IoT with c#.

Let me know if this works for you


#3

Hey Exadon,
Thanks for hopping in, the code indeed look right and should work for the Alcohol sensor.

@amol: do let us know if this works, and if it does work well we’ll be glad to merge it in the GrovePi repo.

-Karan