-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathTemperature_Humidity_Matrix.ino
61 lines (49 loc) · 1.55 KB
/
Temperature_Humidity_Matrix.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Modulino Thermo - Temperature Humidity Matrix
*
* This example code is in the public domain.
* Copyright (c) 2025 Arduino
* SPDX-License-Identifier: MPL-2.0
*/
#include <Arduino_Modulino.h>
#include "ArduinoGraphics.h"
#include "Arduino_LED_Matrix.h"
// Create a ModulinoThermo object
ModulinoThermo thermo;
// Create an object to control the LED matrix on UNO R4 WiFi
ArduinoLEDMatrix matrix;
float temperature = -273.15;
float humidity = 0.0;
void setup() {
Serial.begin(9600);
// Initialize Modulino I2C communication
Modulino.begin();
// Detect and connect to temperature/humidity sensor module
thermo.begin();
// Initialize the LED matrix
matrix.begin();
delay(100);
}
void loop() {
//Acquire temperature and humidity
temperature = thermo.getTemperature();
humidity = thermo.getHumidity();
//Convert the temperature float to a string with 1 decimal point shown
//and add °C at the end
String temperature_text = String(temperature, 1) + "°C";
//Convert the humidity float to a string with no decimal points shown
//and add % at the end
String humidity_text = String(humidity, 0) + "%";
//Print each of the sensor values on serial
Serial.print(temperature_text + " ");
Serial.println(humidity_text);
//Show on the UNO R4 WiFi LED matrix the data
matrix.beginDraw();
matrix.stroke(0xFFFFFFFF);
matrix.textScrollSpeed(75);
matrix.textFont(Font_5x7);
matrix.beginText(0, 1, 0xFFFFFF);
matrix.println(" " + temperature_text + " " + humidity_text + " ");
matrix.endText(SCROLL_LEFT);
matrix.endDraw();
}