Skip to content

A C# .NET implementation for controlling the Pimoroni Rainbow HAT! multi sensor board on a Raspberry Pi.

Notifications You must be signed in to change notification settings

tscholze/dotnet-iot-raspberrypi-rainbow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌈 Rainbow HAT for .NET IoT

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.

Image of the project

🎯 Features

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

🚀 Getting Started

Prerequisites

  • Raspberry Pi (any model)
  • Pimoroni Rainbow HAT
  • .NET 9.0 SDK
  • Basic knowledge of C# and .NET

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/Rainbow.git
cd Rainbow
  1. Build the project:
dotnet build
  1. Run the demo:
dotnet run

Basic Usage

// 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 second

📖 Documentation

Each component has its own controller class with comprehensive XML documentation:

  • SegmentDisplayController - Manages the alphanumeric display
  • LightController - Controls individual RGB LEDs
  • Apa102Controller - Handles the APA102 LED strip
  • Bmp280Controller - Interfaces with the temperature/pressure sensor
  • ButtonController - Manages touch button events
  • BuzzerController - Controls the piezo buzzer

🎮 Demo Application

The project includes a comprehensive demo in Samples.cs that showcases all features:

await Samples.FullTourAsync();

🔧 Hardware Components

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

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

❤️ More IoT projects of mine

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.

.NET on Raspberry Pi

Windows 10 IoT Core apps

Android Things apps

Python scripts

🙏 Acknowledgments

  • Pimoroni for the excellent Rainbow HAT hardware
  • .NET IoT team for the System.Device.Gpio library
  • IoT.Device.Bindings project for the BMP280 driver

About

A C# .NET implementation for controlling the Pimoroni Rainbow HAT! multi sensor board on a Raspberry Pi.

Topics

Resources

Stars

Watchers

Forks

Languages