This repository contains a comprehensive C# library for interacting with the Pimoroni Rainbow HAT using .NET IoT. The Rainbow HAT is a beautiful add-on board for Raspberry Pi that includes various sensors and visual elements.
The library provides easy-to-use controllers for all Rainbow HAT components:
- 📊 Alphanumeric Display - Four-digit display with scrolling text support
- 💡 RGB LEDs - Individual control of red, green, and blue status LEDs
- 🎨 APA102 LED Strip - Seven RGB LEDs with brightness control
- 🌡️ BMP280 Sensor - Temperature and pressure readings
- 🔘 Touch Buttons - Three capacitive touch buttons with event handling
- 🔊 Buzzer - PWM-controlled piezo buzzer
- Raspberry Pi (any model)
- Pimoroni Rainbow HAT
- .NET 9.0 SDK
- Basic knowledge of C# and .NET
- Clone this repository:
git clone https://github.com/yourusername/Rainbow.git
cd Rainbow- Build the project:
dotnet build- Run the demo:
dotnet run// Display scrolling text
using var display = new SegmentDisplayController();
await display.DisplayScrollingText("Hello World!");
// Control RGB LEDs
using var lights = new LightController();
lights.Red.TurnToState(Light.Target.On);
// Read temperature
using var sensor = new Bmp280Controller();
Console.WriteLine($"Temperature: {sensor.Temperature?.DegreesCelsius:F1}°C");
// Play a tone
using var buzzer = new BuzzerController();
buzzer.PlayNote(440, 1.0); // Play A4 for 1 secondEach component has its own controller class with comprehensive XML documentation:
SegmentDisplayController- Manages the alphanumeric displayLightController- Controls individual RGB LEDsApa102Controller- Handles the APA102 LED stripBmp280Controller- Interfaces with the temperature/pressure sensorButtonController- Manages touch button eventsBuzzerController- Controls the piezo buzzer
The project includes a comprehensive demo in Samples.cs that showcases all features:
await Samples.FullTourAsync();The Rainbow HAT includes:
- HT16K33 LED Matrix Driver
- BMP280 Temperature/Pressure Sensor
- APA102 LED Strip
- Piezo Buzzer
- Three Capacitive Touch Buttons
- Three RGB Status LEDs
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
I like to tinker around with Raspberry Pis, I created a couple of educational apps and scripts regarding the Pi and sensors - mostly from Pimoroni.
- dotnet-iot-raspberrypi-blinkt A C# .NET implementation for the Pimoroni Blinkt! LED board on a Raspberry Pi.
- dotnet-iot-raspberrypi-enviro A C# .NET implementation for the Pimoroini Enviro HAT with BMP, TCS and more sensors
- dotnet-iot-raspberrypi-rainbow A C# .NET implementation for the Pimoroini Rainbow HAT with Lights, BMP, segment displays and more
- dotnet-iot-homebear-blinkt Windows 10 IoT Core UWP app that works great with the Pimoroni Blinkt! LED Raspberry Pi HAT.
- dotnet-iot-homebear-tilt Windows 10 IoT Core UWP app that works great with the Pimoroni Pan and Tilt HAT (PIC16F1503)
- dotnet-iot-homebear-rainbow Windows 10 IoT Core UWP app that works great with the Pimoroni RainbowHAT
- java-android-things-firebase-pager An Android Things app that displays a Firebase Cloud Messaging notification on a alphanumeric segment control (Rainbow HAT)
- java-android-things-tobot An Android Things an Google Assistant app to controll a Pimoroni STS vehicle by web and voice
- python-enviro-gdocs-logger Logs values like room temperature and more to a Google Docs Sheet with graphs
- python-enviro-excel-online-logger Logs values like room temperature and more to a M365 Excel Sheet with graphs
- python-enviro-azure-logger Logs values like room temperature and more to an Azure IoT Hub instance
- Pimoroni for the excellent Rainbow HAT hardware
- .NET IoT team for the System.Device.Gpio library
- IoT.Device.Bindings project for the BMP280 driver
