Automation Hat C# library for Windows IoT Core

Hi, folks. In case anyone is interested, I wrote a C# library for the Automation Hat for use in a Windows IoT Core project I am working on.

It is available here:

I tried to stay as close as possible to the Python function reference as possible.


Cool. I did a blinkt port last weekend and it is available at

Needs some debugging work though.

This is good stuff, I need to pick Windows IoT up again and see what’s changed. When I first tried it, it was impossible to set pin muxes and change things like i2c and SPI to be regular IO pins, so it made supporting some of our hardware impossible. I guess that’s fixed now?

Incidentally, Android has the same problem, with no forthcoming sane solution as far as I know.

@MarcJennings Very nice!

@gadgetoid Sorry, I can’t speak to pin mux. I don’t personally have a need to change those. In this particular case, for my project, I am using I2C pins for their regular purpose, and I just avoided SPI pins. Which hardware did you run into problems with? I found the Automation Hat to be really awesome, so I was thinking of picking up some of your other pieces to experiment with.

@jcoliz I think I was using a Display-o-Tron 3000, but it was a while ago now.

Looking over the updated pin mappings diagrams for W10 IoT, which now have a documented “Alternate Function” I’m guessing the problem has long been solved: Raspberry Pi 2 & 3 Pin Mappings - Windows IoT | Microsoft Learn

In fact, there’s a whole section specifically about muxing, which has been very sensible implemented and should be pretty much transparent:

Some GPIO pins can perform multiple functions. By default, pins are configured as GPIO inputs. When you open an alternate function by calling I2cDevice.FromIdAsync() or SpiDevice.FromIdAsync() , the pins required by the function are automatically switched (“muxed”) to the correct function. When the device is closed by calling I2cDevice.Dispose() or SpiDevice.Dispose(), the pins revert back to their default function. If you try to use a pin for two different functions at once, an exception will be thrown when you try to open the conflicting function. For example,

Ah yes, it looks like it has all been sorted now, rather nicely.

Hi togehter,
please can you give me an example for create an input event
with the IotFrosting.Pimoroni?

Best Regards


Could you describe a bit more the context around when you would use such an event and what it might do? Is there an analogous sample in the python library that might serve as an example?

No Problem,
i need an Event (Trigger) when a signal change the state from True to False.

for example
I constantly monitor input 1. If Input 1 changes the status from True to False a method is to be called.

br Timo

@Timo, the README and existing Automation Hat Sample both cover that case.

Hat.Input[0].Updated += (s, a) => { if (s.State) Hat.Output[0].Toggle(); };

Hi, thanks it runs very good. Sorry for my short statements, my English is not so good…
I looked at your in your Code… i works very well. because i have Problems with access to a Textbox, for example.

Can you give me a short Example:

When I call the event, I want to increase the text field by 1. However, if I want to access this text field I always get an error.
Do you have an idea here or can tell me what I do wrong?

Hat.Input[0].Updated += (s, a) =>
if (s.State)

test += 1;
TextBox1.Text= test;

The error occurs because I access the control from another task, right?

Can you give me another example how I can make something like that?


br Timo

Any code that changes the UI, you have to run from the UI thread.

Generally speaking, you can take the text of the exception you get and drop that into web search. This almost always leads to the answer.

Hey, it works fine now.

Many thanks

Br Timo

1 Like

Hey jColiz,
i have a new Problem :-P. I use the automation hat to check some inputs from a PLC. My Problem is that the Input toogle the state up to 20hz (20 toggles in 1 second). At the moment it goes very well up to 5 hz.

Do you have any idea how I can react faster to the changing inputs?

Best Regards Timo