Alcohol sensor example with WIZwiki-W7500

Dependencies:   mbed

Fork of Seeed_Grove_Alcohol_Sensor_Example by Seeed

Prerequisite

This Program is an example of how to get analog data with WIZwiki-W7500 board A0 Pin.

To implement this function, you need a Platform board only.


Hardware Configuration

WIZwiki-W7500 Pin map

pin map

Initialize an analog pin
Initialize an A0 pin of WIZwiki-W7500 platform as an analog pin.

Read analog data from analog pin
Connect an analog device, such as an Alcohol sensor, to A0 pin. And read analog data.


Software

main.cpp

#include "mbed.h"

DigitalOut heater(A1);
AnalogIn sensor(A0);
DigitalOut led_r(LEDR);
DigitalOut led_g(LEDG);
DigitalOut led_b(LEDB);


int main(void)
{
    float value = 0.0f;
    
    led_g = 0;
    led_r = 0;
    led_b = 0;
    
    heater = 0;
    
    wait(0.1f);
    
    
    // Waiting for the sensor to warm-up
    while(value > 0.001f) {
        wait(1.0f);
        value = 1.0f - sensor;
        printf("Sensor is warming up : %2.2f\r\n", value);
    }
    led_g = 1;
    led_r = 1;
    led_b = 1;
    
    while(1)
    {
        value = 1- sensor;
        printf("%2.1f\r\n", value);
        if(value < 0.3)
        {
            led_g = 0;
            led_r = 1;
            led_b = 1;
        }
        else if(value < 0.7)
        {
            led_g = 1;
            led_r = 1;
            led_b = 0;
        }
        else
        {
            led_g = 1;
            led_r = 0;
            led_b = 1;
        }
        wait(1);
        
    }
}

Images

/media/uploads/bingdo/seeed_alcohol_sensor_example_with_wizwiki-w7500_3.jpg

Before alcohol test
/media/uploads/bingdo/seeed_alcohol_sensor_example_with_wizwiki-w7500.png

During alcohol test
/media/uploads/bingdo/seeed_alcohol_sensor_example_with_wizwiki-w7500_2.png


no such method: tip