I have sensor like this: https://easyelectronyx.com/wp-content/uploads/2017/03/flame.jpg?i=1
Please can anyone help me ? I need to find code to read from it , in C#. I have Raspberry Pi 2 Model B , Windows 10 IoT Core and programming in C#. I cant find documentation on the Internet. Is it needed to wire Analog output ?
Thanks
Asked
Active
Viewed 420 times
-1
-
What's your sensor device? From the picture you attached I can't get any useful information. – Rita Han May 22 '17 at 05:47
-
Raspberry Pi 2 Model B – Ivan Čík May 22 '17 at 21:54
-
I asked for **sensor** not Raspberry Pi. – Rita Han May 23 '17 at 01:38
-
https://easyelectronyx.com/product/flame-sensor-module-for-arduinorpi/ – Ivan Čík May 23 '17 at 07:14
1 Answers
2
This Frame sensor device can provide digital or analog output based on its datasheet.
If you don't like to use analog output you can get output from digital pin DO.
First, connect the Frame sensor and Raspberry Pi. Connect VCC, GND and DO like the following picture show. For digital pin, I choose GPIO27 here, you can choose other pin you like.
Second, write the code. Create the UWP app(Start here).
MainPage.xaml
<StackPanel VerticalAlignment="Center" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBlock Name="SensorOuputValue" />
</StackPanel>
MainPage.xaml.cs
public sealed partial class MainPage : Page
{
private const int SENSOR_PIN = 27;
private GpioPin pin;
private GpioPinValue pinValue;
private DispatcherTimer timer;
public MainPage()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromMilliseconds(1000);
timer.Tick += ReadSensor;
InitGPIO();
if (pin != null)
{
timer.Start();
}
}
private void InitGPIO()
{
var gpio = GpioController.GetDefault();
// Show an error if there is no GPIO controller
if (gpio == null)
{
pin = null;
System.Diagnostics.Debug.WriteLine("There is no GPIO controller on this device.");
return;
}
pin = gpio.OpenPin(SENSOR_PIN);
pin.SetDriveMode(GpioPinDriveMode.Input);
System.Diagnostics.Debug.WriteLine("GPIO pin initialized correctly.");
}
private void ReadSensor(object sender, object e)
{
SensorOuputValue.Text = pin.Read().ToString();
}
}

Rita Han
- 9,574
- 1
- 11
- 24