I am trying to read the distance from the ultrasonic sensor (HC-SR04), but the only values ββI get are 0 and 265.xx.
I am using Raspberry Pi 2 with IoT Core Windows 10 installed.
I wrote the code in C #.
This is the class of ultrasonic sensor:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using Windows.Devices.Gpio; namespace RaspberryPi { class UcSensor { GpioController gpio = GpioController.GetDefault(); GpioPin TriggerPin; GpioPin EchoPin;
I also wrote a script in python to read values ββfrom an ultrasonic sensor, and then it works, but in C # I can't get it to work.
Below you can find the debug log:
'BACKGROUNDTASKHOST.EXE' (CoreCLR: DefaultDomain): loaded 'C: \ Program Files \ WindowsApps \ Microsoft.NET.CoreRuntime.1.0_1.0.22816.1_arm__8wekyb3d8bbwe \ mscorlib.ni.dll'. Missing download symbols. The module is optimized and the debugger option "Only my code" is enabled. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ RaspiCar.winmd'. Symbols loaded. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ System.Runtime.dll'. Missing download symbols. The module is optimized and the debugger option "Only my code" is enabled. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ WinMetadata \ Windows.winmd'. The module was built without characters. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ System.Runtime.InteropServices.WindowsRuntime.dll'. The module was built without characters. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ System.Threading.dll'. The module was built without characters. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ System.Diagnostics.Debug.dll'. Missing download symbols. The module is optimized and the debugger option "Only my code" is enabled. 'BACKGROUNDTASKHOST.EXE' (CoreCLR: CoreCLR_UAP_Domain): loaded 'C: \ Users \ DefaultAccount \ AppData \ Local \ DevelopmentFiles \ RaspiCarVS.Debug_ARM.chris \ System.Runtime.WindowsRuntime.dll'. Missing download symbols. The module is optimized and the debugger option "Only my code" is enabled. Distance: 265.7457 Distance: 0 Distance: 0 Distance: 0 The program '[2508] BACKGROUNDTASKHOST.EXE' exited with the code 0 (0x0).
c # windows-10 sensor raspberry-pi2 iot
Chris westerhuis
source share