Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Solla committed Dec 15, 2020
0 parents commit 40a0b6d
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Description
Decibel meters are used in several types of measuring instruments.

**WS1361C** is a cheap decibel meter that provides software interfaces to record surrounding noise level automatically.

Meanwhile, it also provides an interface for calibration to make sure the data is meaningful.

The sample rate is 1 per second.

Besides, I found that the data read from software has a one-second latency.

Be aware of the latency when using.

## Usage Scenarios

(Academic Papers) Automatically measure the noise of devices noise if multiple data points are needed.

(Environmental monitoring) Monitoring the surrounding noise level.
25 changes: 25 additions & 0 deletions SoundLevelSoftware_WS1361C.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SoundLevelSoftware_WS1361C", "SoundLevelSoftware_WS1361C\SoundLevelSoftware_WS1361C.csproj", "{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9E514BB3-DB21-4EDB-AA28-50E00BDBB3BF}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions SoundLevelSoftware_WS1361C/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" />
</startup>
</configuration>
35 changes: 35 additions & 0 deletions SoundLevelSoftware_WS1361C/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using LibUsbDotNet;
using LibUsbDotNet.Main;
using System.Threading;

namespace SoundLevelSoftware_WS1361C
{
class Program
{
public static UsbDevice MyUsbDevice;

public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(0x16c0, 0x5dc);
static void Main(string[] args)
{
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
if (MyUsbDevice == null)
throw new Exception("WS1361C Noise Level Meter Not Connected.");

UsbSetupPacket usbSetupPacket = new UsbSetupPacket(0xC0, 4, 0, 10, 200);
byte[] Values = new byte[4];
int Length;
double LastValue = 0;
while (true)
{
Thread.Sleep(10);
MyUsbDevice.ControlTransfer(ref usbSetupPacket, Values, Values.Length, out Length);
double db = (Values[0] + ((Values[1] & 3) * 256)) * 0.1 + 30;
if (LastValue == db)
continue;
LastValue = db;
Console.WriteLine(LastValue);
}
}
}
}
19 changes: 19 additions & 0 deletions SoundLevelSoftware_WS1361C/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("SoundLevelSoftware_WS1361C")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SoundLevelSoftware_WS1361C")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("63f2b3a0-3aa1-47ab-ae64-7d331454ffdc")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
58 changes: 58 additions & 0 deletions SoundLevelSoftware_WS1361C/SoundLevelSoftware_WS1361C.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{63F2B3A0-3AA1-47AB-AE64-7D331454FFDC}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>SoundLevelSoftware_WS1361C</RootNamespace>
<AssemblyName>SoundLevelSoftware_WS1361C</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LibUsbDotNet">
<Version>2.2.29</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 40a0b6d

Please sign in to comment.