Part 2. Building Home Weather Station with .NET 6 and Raspberry Pi 4. Taking Measurements

12/25/2021
  • .Net
  • C#
  • dotnet
  • Pi
  • Raspberry Pi
  • sensors
  • SunFunder
  • IoT

I was looking for a fun project to do this holiday season and decided that it’s about time to put my Raspberry Pi to good use. The idea is to build a device that will measure temperature, humidity, and barometric pressure in an apartment. Then, send this data to Azure and have an app written in .NET MAUI to view this data. These will be a series of articles on how to do all that with Raspberry Pi 4 and .NET 6.

In this part, I’ll go over writing a program to take measurements of temperature, humidity, and barometric pressure using Raspberry Pi. Let’s get started!

Part 1. Building Home Weather Station with .NET 6 and Raspberry Pi 4. The Setup

12/25/2021
  • .Net
  • C#
  • dotnet
  • Pi
  • Raspberry Pi
  • sensors
  • SunFunder
  • IoT

I was looking for a fun project to do this holiday season and thought that it’s about time to put my Raspberry Pi to good use. I’ve decided to build a device that will measure temperature, humidity, and barometric pressure in an apartment. Then, send this data to Azure and have an app written in .NET MAUI to view this data. I’ll split this in the series of articles on how to do it with .NET 6 and Raspberry Pi 4. In this part, I’ll describe the setup of Raspberry Pi for .NET 6 development and write a basic “Hello World” app. Let’s get started!

Detecting that NamedPipe exists

05/03/2020
  • .Net
  • C#
  • NamedPipe
  • Exists
  • Check
  • Pipe
  • File.Exists
  • Directory.GetFiles

In my project at work we use NamedPipe as one of the telemetry transports when running the app locally. All seemed to work fine, until I decided to write a BenchmarkDotNet diagnoser for the application that was supposed to use NamedPipe telemetry transport to collect certain metrics.

How to rethrow exception correctly in .Net

08/19/2018
  • .Net
  • C#
  • exception
  • exceptions
  • rethrow
  • throw
  • catch
  • stacktrace
  • ExceptionDispatchInfo

A few days ago I stumbled across a C# code that was rethrowing the exception by means of passing captured exception object as an argument of the throw keyword (throw ex;). Such a pattern of rethrowing the exception can turn an exercise of troubleshooting a production issue into a game of “Find where the exception happened.”. I had to play this game a few times in my life and it is not the most fun game to play, especially if your codebase is quite large. So, here I want to take a minute and discuss what is the correct way to rethrow the exception in .Net.

Script Capture Tag Helper

03/24/2018
  • AspNet
  • AspNet Core
  • Tag Helper
  • TagHelper
  • tag
  • helper
  • razor
  • sections
  • MVC

Razor sections allows us to write a block of code in one view and render it later in another. The typical example would be the scripts section that takes a script block from the page and renders it in the layout after all common scripts. This works fine until you try to use sections from the partial view or from the display template.

Notes from changing AspNet Core 2.1-preview1 app to IIS In-Process hosting

03/03/2018
  • AspNet
  • AspNet Core
  • 2.1-preview1
  • IIS
  • In-Process
  • hosting

The AspNet Core 2.1-preview1 is out and it brings a ton of interesting improvements. One of which is that now you are able to host your AspNet app inside the IIS process. This, according to AspNet team will increase the request throughput by around 4.4 times. I did it for my app and faced a few issues that I though is worth describing here along with a process that I followed.

Finding Visual Studio Tools

02/16/2018
  • visual studio
  • visual studio tools
  • visual studio 2017
  • vswhere
  • scripts
  • CI
  • build
  • build script
  • MSBuild
  • VSTest

Recently I was migrating a CI script from VS 2015 tools to VS 2017 tools. The script was calling to vstest.console.exe to run integration tests, somewhat like this:

      $vsTest = "$env:VS140COMNTOOLS\..\IDE\CommonExtensions\Microsoft\TestWindow\VSTest.console.exe"
      & $vsTest "Tests.dll" "/Parallel" "/Settings:$runconfig" "/Logger:trx" 2>&1 | Write-Host
    

I’ve omitted the error handling code here for simplicity. The call itself is quite simple, it relies on the fact that when you install Visual Studio build tools on the CI machine it adds an environment variable VS140COMNTOOLS that points to the Visual Studio tools folder, usually it is C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\.

UWP RadDataGrid with dynamically generated columns

08/07/2017
  • Telerik
  • DataGrid
  • RadDataGrid
  • Columns
  • Dynamic
  • C#
  • UWP
  • VSTS API
  • MVVM
  • attached property

Recently I got a task to create a reporting tool that will aggregate data from VSTS and provide reports on the team performance in terms of finished work items and pull requests. I was excited about this, because I saw this as an opportunity to use Telerik’s data grid in the real world scenario.

Adding references to Visual Studio extension project

04/16/2017
  • Visual Studio extension
  • FileNotFoundException
  • Visual Studio
  • references
  • assembly
  • WPF
  • ProvideBindingPath

This might sound like a very simple thing to do, just right click -> “Add References” -> Select an assembly and done. Even easier, just add a NuGet package. Well, not quite. When I added a NuGet package to one of my extension projects I got a runtime error that took me some time to figure out. So I though it might be a good idea to write about it.

Multiple datasource templates for Associated Content dialog

08/26/2015
  • template
  • sitecore
  • sitecore 8
  • associated content
  • datasource

Generally it’s a good idea to specify a “Datasource template” for sitecore rendering. It gives your users a great benefit of creating datasource items right from the “Associate content” dialog and also it will allow them to select items of this template only. This works just fine, until you get to a point when your rendering has to accept items of different types (templates) or even better, you want to be able to create items of different types right from the “Associated content” dialog.