Software apps and online services
This project uses a LM35 temperature sensor and a ST7789 SPI display to make a simple room temperature monitor. Everything you need to build this project is included in the Wilderness Labs Meadow F7 w/Hack Kit Pro. We'll see how easy is to program these peripherals using Meadow.Foundation.
Meadow.Foundationa platform for quickly and easily building connected things using.NET on Meadow. Created by Wilderness Labs, it's completely open source and maintained by the Wilderness Labs community.
If you're new working with Meadow, I suggest you go to the Getting Started w/ Meadow by Controlling the Onboard RGB LEDproject to properly set up your development environment.Step 1 - Assemble the circuit
Wire your project like this:
Create a new Meadow Application project in Visual Studio 2019 for Windows or macOS and name it TemperatureMonitor.Step 3 - Add the required NuGet packages
Right-click on your TemperatureMonitor project and click Manage NuGet Packages. In the Browse tab, search for Meadow.Foundation.Displays.Tft and click Install to add it to your project.
Alt-click on your TemperatureMonitor project in the Solution Explorer, and click Add => Add Nuget Package to open the NuGet Package window. Search for Meadow.Foundation.Displays.Tft and click Install to add it to your project.Step 4 - Write the code for TemperatureMonitor
Copy the following code below:
public class MeadowApp : App<F7Micro, MeadowApp>
Color colors = new Color
int displayWidth, displayHeight;
analogTemperature = new AnalogTemperature(
analogTemperature.Updated += AnalogTemperatureUpdated;
var config = new SpiClockConfiguration(
st7789 = new St7789(
Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config),
width: 240, height: 240
displayWidth = Convert.ToInt32(st7789.Width);
displayHeight = Convert.ToInt32(st7789.Height);
graphics = new GraphicsLibrary(st7789);
graphics.Rotation = GraphicsLibrary.RotationType._270Degrees;
int radius = 225;
int originX = displayWidth / 2;
int originY = displayHeight / 2 + 130;
graphics.Stroke = 3;
for (int i = 1; i < 5; i++)
color: colors[i - 1],
radius -= 20;
graphics.DrawLine(0, 220, 240, 220, Color.White);
graphics.DrawLine(0, 230, 240, 230, Color.White);
graphics.CurrentFont = new Font12x20();
graphics.DrawText(54, 130, "TEMPERATURE", Color.White);
void AnalogTemperatureUpdated(object sender, AtmosphericConditionChangeResult e)
float oldTemp = e.Old.Temperature / 1000;
float newTemp = e.New.Temperature / 1000;
x: 48, y: 160,
color: colors[colors.Length - 1],
x: 48, y: 160,
In the MeadowApp's constructor, its all about initializing the peripherals on our project, which in this case is the AnalogTemperature object, in which we make sure we're specifying its a LM35 sensor type. To make the sensor be active to read the temperature, we'll use the events and IObservable pattern found in Meadow.Core to read, poll and filter input from sensors automatically. In this case, we're registering the LM35 to an
Updated event to constantly check the old and new values once we call the StartUpdating method.
We also initialize the ST7789 display, specifying which Pins are we connected and passing a SPI Configuration object to make sure we're connecting to the display in the right SPI mode. We're also using Meadow.Foundation's GraphicsLibrary to easily draw basic shapes and text for our UI.
In the LoadScreen method it will load all the UI to display the temperature, it starts by drawing four concentric circles, and a TEMPERATURE text as a title and two horizontal lines in the bottom of the screen.
Finally, in the
AnalogTemperatureUpdated event handler, we'll simply draw the previous temperature value in the same color of the background to "erase" it, and we draw the new value right after, so we won't need to redraw the entire screen each time the event is raised.
Click the Run button in Visual Studio. It should look like to the following GIF:
This project is only the tip of the iceberg in terms of the extensive exciting things you can do with Meadow.Foundation.
- It comes with a huge peripheral driver library with drivers for the most common sensors and peripherals.
- The peripheral drivers encapsulate the core logic and expose a simple, clean, modern API.
- This project is backed by a growing community that is constantly working on building cool connected things and are always excited to help new-comers and discuss new projects.