Cloud cover detector with an IR thermometer
Build it step by step
0 of 7 doneTest the sensor
Print object and ambient temperature.
Point it at a wall
Both numbers are close.
Point it at the sky
The sky reading drops.
Add the difference
Air minus sky.
Add the words
Clear, Partly cloudy, Overcast.
Fit a tube
Block side views with a short black tube.
Compare
Look at the real sky and adjust.
How do you build a cloud cover detector with an IR thermometer?
An MLX90614 pointed at the sky compares sky temperature with air temperature: a very cold sky means clear, a warm sky means cloud. You need Arduino Nano, MLX90614 infrared thermometer and SSD1306 OLED Display. It takes 7 steps and about 75 minutes.
- Level
- Intermediate
- Time
- About 75 min
- Parts
- 3
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- DisplaysBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| MLX90614 VCC and GND | Nano 5V and GND | Power (use the 5 V version of the module, or 3V3 for a 3.3 V one) |
| MLX90614 SDA | Nano A4 | I2C data |
| MLX90614 SCL | Nano A5 | I2C clock |
| OLED VCC, GND, SDA, SCL | Nano 5V, GND, A4, A5 | Shares the I2C bus |
| USB or adapter | Nano | Power |
Code
The infrared sensor measures the temperature of whatever it points at. A clear sky is very cold in the infrared, often 20 °C or more below the air temperature, while cloud bases radiate heat back and read close to the air. Point the sensor straight up through a small tube so that it sees only the sky and not roofs or trees. Thresholds depend on humidity, altitude and the sensor's field of view, so treat the words as a guide and adjust the two numbers after comparing with what you see overhead. Keep the sensor out of rain and direct sun, which can damage it, and cover the end with a thin infrared-transparent window (such as a sliver of polyethylene film) in a weatherproof box. It is a hobby indicator that is useful for choosing a night for stargazing or checking the night radiation that causes frost, not a replacement for a forecast. Arduino IDE, board "Arduino Nano" (try the Old Bootloader option if the upload fails).
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Cloud cover detector. Libraries: Adafruit MLX90614, Adafruit SSD1306, Adafruit GFX. Board: Arduino Nano.
#include <Wire.h>
#include <Adafruit_MLX90614.h>
#include <Adafruit_SSD1306.h>
Adafruit_MLX90614 mlx; Adafruit_SSD1306 oled(128, 64, &Wire, -1);
void setup() {
mlx.begin();
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(SSD1306_WHITE);
}
void loop() {
float sky = 0, air = 0;
for (int i = 0; i < 20; i++) { sky += mlx.readObjectTempC(); air += mlx.readAmbientTempC(); delay(50); }
sky /= 20; air /= 20;
float diff = air - sky; // a clear sky is much colder than the air near the ground
const char* sky_text = "Overcast";
if (diff > 25) sky_text = "Clear";
else if (diff > 12) sky_text = "Partly cloudy";
oled.clearDisplay();
oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Sky "); oled.print(sky, 1); oled.print(" Air "); oled.print(air, 1);
oled.setCursor(0, 14); oled.print("Difference "); oled.print(diff, 1); oled.print(" C");
oled.setTextSize(2); oled.setCursor(0, 36); oled.print(sky_text);
oled.display();
delay(2000);
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Clear night | Difference above 25 and Clear |
| Thick cloud | Difference under 12 and Overcast |
| Pointed at a wall | Difference near zero |
| Rain on the window | Keep it dry |
If it does not work
Always reads Overcast
Check the sensor sees the sky, not a roof.
Reads strange values
Check the I2C address and the module voltage.
Noisy
Average more readings.
Window blocks the view
Use thin polyethylene film.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the cloud cover detector with an IR thermometer?
Arduino Nano, MLX90614 infrared thermometer and SSD1306 OLED Display.
How long does the cloud cover detector with an IR thermometer take to build?
About 75 minutes for a intermediate maker, in 7 steps.
How do I know the cloud cover detector with an IR thermometer works?
Clear night: Difference above 25 and Clear. Thick cloud: Difference under 12 and Overcast. Pointed at a wall: Difference near zero.
Always reads Overcast: what should I check?
Check the sensor sees the sky, not a roof.
Reads strange values: what should I check?
Check the I2C address and the module voltage.
Noisy: what should I check?
Average more readings.
Window blocks the view: what should I check?
Use thin polyethylene film.
