Data logging weather station.

Thread Starter

A Homeschoolers Workbench

Joined Jul 26, 2016
142
I had some fun making this cheap (under $15) weather station.
Parts
1 Arduino board, I used the pro mini you can use any - arduino.org
1 dht sensor I used the dht 22 - ebay
1 10k resistor - ebay
1 SD card or micro SD card with matching board - ebay
3 feet on wire - salvaged
3 wire cable (you will use this to connect your dht sensor to the arduino) - ebay

Here is the source code
Code:
// Created by A Homeschoolers Workbench
// 12/1/2016
#include "DHT.h"
#include <sd.h>
File myFile;
int pinCS = 10; // Pin 53 on Arduino mega   10 on pro mini and uno, this is the SS pin
// For the uno and pro mini connect sck-13 miso-12 mosi-11 cs/ss-10
// For mega connect sck-52 miso-50 mosi-51 cs/ss-53
#define DHTPIN 2     // what digital pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321  I am using the 22
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10k resistor from vcc to data pin
// Initialize DHT sensor.
DHT dht(DHTPIN, DHTTYPE);
void setup() {
  Serial.begin(9600);     // Start the serial
  pinMode(pinCS, OUTPUT);
// SD Card Initialization
if (SD.begin())
  {
    Serial.println("SD card is ready to use.");
  } else
  {
    Serial.println("SD card initialization failed");
    return;
}
  dht.begin();
}
void loop() {
  // Wait a 60 seconds between measurements.
  delay(2000);
  // Reading temperature or humidity takes about 250 milliseconds!
  float h = dht.readHumidity();
    // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

//   Check if any reads failed and exit early (to try again).
  if (isnan(h)||isnan(f)) {
    return;
  }
    // Create/Open file
  myFile = SD.open("TH.txt", FILE_WRITE);
//   if the file opened okay, write to it
if (myFile) {
    Serial.println("Writing to file...");
    // Write to file
  myFile.print(h);    // print Humidity
  myFile.print(",");  // place a divider
  myFile.println(f);  // print the temp and start a new line
    myFile.close(); // close the file
    Serial.println("Done.");
}               //if the file didn't open, print an error:
else {
    Serial.println("error opening TH.txt");
}
}
Wiring diagrams.

dht sensor Pro mini, Uno & mega.
Connect pin 1 (on the left) of the sensor to +5V
NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 to 3.3V instead of 5V
Connect pin 2 of the sensor to whatever your DHTPIN is
Connect pin 4 (on the right) of the sensor to GROUND
Connect a 10k resistor from vcc to data pin


For the mega
MISO-50 MOSI-51 SCK-52 SS/CS 53

For the uno & pro mini
MISO-50 MOSI-51 SCK-52 SS/CS-53.
Solder or breadboard them together then mount the sensor when you want to measure the temperature humidity, make sure the arduino stays dry.

I had a lot of fun building this here is a days worth of dataView attachment 120140

A Homeschoolers Workbench.
 
Last edited:

bertus

Joined Apr 5, 2008
22,277
Hello,

I found this in the completed projects forum.
Did you read the requirements?

When posting a project please include the following information:

  1. A clear title that describes the project appended by the word 'Project:', for example "Project: 555 Audio Oscillator".
  2. A list of parts, equipment, software used.
  3. Details of any theory, references or information that may be applicable.
  4. Any schematics, source code, etc.
  5. A short description of what to do.
  6. In the interests of manageability and security, project files/code/schematics must be locally stored on All About Circuits. This is not optional. Links such as You Tube may be used to provide supplementary information, however they must not provide the substance of the project.
  7. A picture displaying the finished project is preferred. It should be the first illustration displayed.
All Files must be stored localy and not on instructables.

Bertus
 

ScottWang

Joined Aug 23, 2012
7,400
Is this not a completed project?
Here is the projects forum now, The completed projects forum is the forum for the members who want to duplicate the project, so every unit of the project should be very clearly, then our member could copy all the project easily, as you can also copy other projects to use, when you completed all the requested then we will move back to the completed projects forum, and we may delete some of the contents that we discussing here.

Your project is a good project, thanks for sharing it here, you are a really good young boy, if you continuing to do that, I think you will be a great projects maker in the near future.

Because the completed board didn't made by yourself, so you can make the link to board and sensor then it will be more easy to find the board and its function, specially the board has the version of function compatible then some pins could be different, as my pinout of mini pro was different from yours.
 
Top