Projects / Solar dryer logger

Solar dryer logger

Two DHT22 sensors, one at the air inlet and one at the outlet of a solar dryer for fruit or grain, are logged with the time to a card, so you can see how hot and dry the air is and when the produce is ready.

Intermediate2.8 hGuided buildReviewed

Build it step by step

0 of 7 done
  1. NANO

    Wire the sensors

    Both to 5V and GND, data to D2 and D3, 10 kilo-ohms from each data pin to 5V.

  2. NANO

    Wire the clock

    SDA to A4, SCL to A5, power and ground.

  3. NANOMICROS

    Wire the card module

    CS D10, MOSI D11, MISO D12, SCK D13, 5V and GND.

  4. NANO

    Wire the lights

    Green to D5, red to D6, each through 220 ohms.

  5. NANODS323114:52

    Install the libraries

    DHT sensor library, Adafruit Unified Sensor and RTClib.

  6. NANO

    Upload the sketch

    The green light comes on after the first line is saved.

  7. NANO

    Wait ten minutes and open DRYER.CSV

    On a computer.

In short

How do you build a solar dryer logger?

Two DHT22 sensors, one at the air inlet and one at the outlet of a solar dryer for fruit or grain, are logged with the time to a card, so you can see how hot and dry the air is and when the produce is ready. You need Arduino Nano, DHT22 Sensor × 2, Resistor 10 kΩ × 2, DS3231 RTC module, MicroSD Card Module, LED 5 mm red, LED 5 mm green, Resistor 220 Ω × 2, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 7 steps and about 170 minutes.

Level
Intermediate
Time
About 170 min
Parts
10

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Inlet DHT22 pin 1 and outlet DHT22 pin 1Nano 5VPower at 5 V
Inlet DHT22 pin 2 (data)Nano D2Inlet air readings
Outlet DHT22 pin 2 (data)Nano D3Outlet air readings
Inlet and outlet DHT22 pin 4Nano GNDCommon ground
10 kilo-ohm resistorsOne between each data pin and 5VPull-ups for the data lines
DS3231 SDA and SCLNano A4 and A5I2C, address 0x68 (VCC to 5V, GND to GND)
SD module CSNano D10Chip select
SD module MOSI, MISO, SCKNano D11, D12, D13SPI (VCC to 5V, GND to GND, use a 5 V module)
Green LED long leg220 ohm resistor to Nano D5Logging works
Red LED long leg220 ohm resistor to Nano D6Card or sensor problem

Code

A solar dryer heats air in a collector and passes it over fruit, vegetables or grain, and the produce dries best when the air is warm and the humidity is low. Two DHT22 sensors, one where the air enters and one where it leaves, show what the dryer is doing. If the outlet air is as dry as the inlet air, it is picking up no more water and the produce is nearly dry. The Nano reads both once a minute and writes a line of text with the time to a memory card, which you can open in a spreadsheet to draw a graph. The clock chip keeps the time when the Nano loses power, and the sketch sets it to the time you uploaded it the first time. A green light shows that logging works and a red light shows a problem with the card or a sensor. The DHT22 works up to 80 degrees, so keep it away from the hottest part of the collector, and put the sensors and all the electronics outside the food chamber, shaded, dry and out of the sun. This logger is for learning how your dryer behaves. It does not tell you that food is safe to store, so follow proper guidance on drying and storage.

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).

#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <RTClib.h>
#include <DHT.h>

const int CS_PIN = 10, GREEN = 5, RED = 6;
DHT inlet(2, DHT22);
DHT outlet(3, DHT22);
RTC_DS3231 rtc;

void setup() {
  pinMode(GREEN, OUTPUT);
  pinMode(RED, OUTPUT);
  Serial.begin(9600);
  inlet.begin();
  outlet.begin();
  if (!rtc.begin()) { digitalWrite(RED, HIGH); while (true) {} }
  if (rtc.lostPower()) rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));   // sets the clock to the upload time
  if (!SD.begin(CS_PIN)) { digitalWrite(RED, HIGH); while (true) {} }
  File f = SD.open("DRYER.CSV", FILE_WRITE);
  if (f) {
    if (f.size() == 0) f.println(F("date,time,inlet_C,inlet_RH,outlet_C,outlet_RH"));
    f.close();
  }
}

void loop() {
  float ti = inlet.readTemperature(), hi = inlet.readHumidity();
  float to = outlet.readTemperature(), ho = outlet.readHumidity();
  DateTime now = rtc.now();

  if (isnan(ti) || isnan(hi) || isnan(to) || isnan(ho)) {
    digitalWrite(RED, HIGH);                        // a sensor did not answer: try again
    digitalWrite(GREEN, LOW);
    delay(5000);
    return;
  }

  File f = SD.open("DRYER.CSV", FILE_WRITE);
  if (f) {
    f.print(now.year()); f.print('-'); f.print(now.month()); f.print('-'); f.print(now.day()); f.print(',');
    f.print(now.hour()); f.print(':'); if (now.minute() < 10) f.print('0'); f.print(now.minute()); f.print(',');
    f.print(ti, 1); f.print(','); f.print(hi, 0); f.print(',');
    f.print(to, 1); f.print(','); f.println(ho, 0);
    f.close();                                     // closing saves the line, so a power cut loses little
    digitalWrite(RED, LOW);
    digitalWrite(GREEN, HIGH);
  } else {
    digitalWrite(RED, HIGH);
    digitalWrite(GREEN, LOW);
  }
  Serial.print(ti, 1); Serial.print(" / "); Serial.print(to, 1); Serial.println(" C");
  delay(60000);                                    // one line a minute
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
StartGreen light on
Wait a minuteA new line on the card
Warm the inlet sensor with a handIts column rises
Breathe on the outlet sensorIts humidity rises
Remove the cardRed light

If it does not work

Red light at start

Check the card is FAT32 and the module is wired to D10 to D13.

Red light after a while

A sensor did not answer, check its data wire and pull-up.

Wrong time

Re-upload after removing the clock's cell for a moment, or set the clock.

Empty file

Wait a minute for the first line, and close the file before removing the card.

Readings stuck

Check the sensors are not swapped and have 5 V.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the solar dryer logger?

Arduino Nano, DHT22 Sensor × 2, Resistor 10 kΩ × 2, DS3231 RTC module, MicroSD Card Module, LED 5 mm red, LED 5 mm green, Resistor 220 Ω × 2, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.

How long does the solar dryer logger take to build?

About 170 minutes for a intermediate maker, in 7 steps.

How do I know the solar dryer logger works?

Start: Green light on. Wait a minute: A new line on the card. Warm the inlet sensor with a hand: Its column rises.

Red light at start: what should I check?

Check the card is FAT32 and the module is wired to D10 to D13.

Red light after a while: what should I check?

A sensor did not answer, check its data wire and pull-up.

Wrong time: what should I check?

Re-upload after removing the clock's cell for a moment, or set the clock.

Empty file: what should I check?

Wait a minute for the first line, and close the file before removing the card.