Datalogger that reads temperature, humidity and light level every 10 seconds, and store the data in a microSD card (.CSV file).

Dependencies:   DS1302 SDFileSystem mbed

This is a weather station/datalogger using a Freescale FRDM-K64F dev board, a LM35 (temperature sensor), a DHT11 (temperature and humidity sensor), a DS1302 (timekeeper module) and a LDR (light level sensor). All the data is periodically stored on a microSDHC card; The acquisition period is adjustable via software (by setting the value of a counter).

There is also (commented) code for sending all these information via serial to a terminal on PC.

Full explanation, details and schematics can be found here: http://embedded-clovis.blogspot.ca/2014/07/temperature-datalogger-with-arm-cortex.html

Committer:
Clovis
Date:
Fri Jul 04 08:08:38 2014 +0000
Revision:
0:8f0934e41a57
Datalogger for temperature, humidity and light level, using a FRDM-K64F development board by Freescale and storing data on a microSD card. It keeps track of the time by means of a DS1302 timekeeping chip.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Clovis 0:8f0934e41a57 1 /*
Clovis 0:8f0934e41a57 2 * DHT Library for Digital-output Humidity and Temperature sensors
Clovis 0:8f0934e41a57 3 *
Clovis 0:8f0934e41a57 4 * Works with DHT11, DHT21, DHT22
Clovis 0:8f0934e41a57 5 * SEN11301P, Grove - Temperature&Humidity Sensor (Seeed Studio)
Clovis 0:8f0934e41a57 6 * SEN51035P, Grove - Temperature&Humidity Sensor Pro (Seeed Studio)
Clovis 0:8f0934e41a57 7 * AM2302 , temperature-humidity sensor
Clovis 0:8f0934e41a57 8 * RHT01,RHT02, RHT03 , Humidity and Temperature Sensor (Sparkfun)
Clovis 0:8f0934e41a57 9 *
Clovis 0:8f0934e41a57 10 * Copyright (C) Wim De Roeve
Clovis 0:8f0934e41a57 11 * based on DHT22 sensor library by HO WING KIT
Clovis 0:8f0934e41a57 12 * Arduino DHT11 library
Clovis 0:8f0934e41a57 13 *
Clovis 0:8f0934e41a57 14 * Permission is hereby granted, free of charge, to any person obtaining a copy
Clovis 0:8f0934e41a57 15 * of this software and associated documnetation files (the "Software"), to deal
Clovis 0:8f0934e41a57 16 * in the Software without restriction, including without limitation the rights
Clovis 0:8f0934e41a57 17 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Clovis 0:8f0934e41a57 18 * copies of the Software, and to permit persons to whom the Software is
Clovis 0:8f0934e41a57 19 * furished to do so, subject to the following conditions:
Clovis 0:8f0934e41a57 20 *
Clovis 0:8f0934e41a57 21 * The above copyright notice and this permission notice shall be included in
Clovis 0:8f0934e41a57 22 * all copies or substantial portions of the Software.
Clovis 0:8f0934e41a57 23 *
Clovis 0:8f0934e41a57 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Clovis 0:8f0934e41a57 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Clovis 0:8f0934e41a57 26 * FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Clovis 0:8f0934e41a57 27 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Clovis 0:8f0934e41a57 28 * LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Clovis 0:8f0934e41a57 29 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Clovis 0:8f0934e41a57 30 * THE SOFTWARE.
Clovis 0:8f0934e41a57 31 */
Clovis 0:8f0934e41a57 32
Clovis 0:8f0934e41a57 33 #ifndef MBED_DHT_H
Clovis 0:8f0934e41a57 34 #define MBED_DHT_H
Clovis 0:8f0934e41a57 35
Clovis 0:8f0934e41a57 36 #include "mbed.h"
Clovis 0:8f0934e41a57 37
Clovis 0:8f0934e41a57 38 enum eType{
Clovis 0:8f0934e41a57 39 DHT11 = 11,
Clovis 0:8f0934e41a57 40 SEN11301P = 11,
Clovis 0:8f0934e41a57 41 RHT01 = 11,
Clovis 0:8f0934e41a57 42 DHT22 = 22,
Clovis 0:8f0934e41a57 43 AM2302 = 22,
Clovis 0:8f0934e41a57 44 SEN51035P = 22,
Clovis 0:8f0934e41a57 45 RHT02 = 22,
Clovis 0:8f0934e41a57 46 RHT03 = 22
Clovis 0:8f0934e41a57 47 } ;
Clovis 0:8f0934e41a57 48
Clovis 0:8f0934e41a57 49 enum eError {
Clovis 0:8f0934e41a57 50 ERROR_NONE = 0,
Clovis 0:8f0934e41a57 51 BUS_BUSY =1,
Clovis 0:8f0934e41a57 52 ERROR_NOT_PRESENT =2 ,
Clovis 0:8f0934e41a57 53 ERROR_ACK_TOO_LONG =3 ,
Clovis 0:8f0934e41a57 54 ERROR_SYNC_TIMEOUT = 4,
Clovis 0:8f0934e41a57 55 ERROR_DATA_TIMEOUT =5 ,
Clovis 0:8f0934e41a57 56 ERROR_CHECKSUM = 6,
Clovis 0:8f0934e41a57 57 ERROR_NO_PATIENCE =7
Clovis 0:8f0934e41a57 58 } ;
Clovis 0:8f0934e41a57 59
Clovis 0:8f0934e41a57 60 typedef enum {
Clovis 0:8f0934e41a57 61 CELCIUS =0 ,
Clovis 0:8f0934e41a57 62 FARENHEIT =1,
Clovis 0:8f0934e41a57 63 KELVIN=2
Clovis 0:8f0934e41a57 64 } eScale;
Clovis 0:8f0934e41a57 65
Clovis 0:8f0934e41a57 66
Clovis 0:8f0934e41a57 67 class DHT {
Clovis 0:8f0934e41a57 68
Clovis 0:8f0934e41a57 69 public:
Clovis 0:8f0934e41a57 70
Clovis 0:8f0934e41a57 71 DHT(PinName pin,int DHTtype);
Clovis 0:8f0934e41a57 72 ~DHT();
Clovis 0:8f0934e41a57 73 int readData(void);
Clovis 0:8f0934e41a57 74 float ReadHumidity(void);
Clovis 0:8f0934e41a57 75 float ReadTemperature(eScale Scale);
Clovis 0:8f0934e41a57 76 float CalcdewPoint(float celsius, float humidity);
Clovis 0:8f0934e41a57 77 float CalcdewPointFast(float celsius, float humidity);
Clovis 0:8f0934e41a57 78
Clovis 0:8f0934e41a57 79 private:
Clovis 0:8f0934e41a57 80 time_t _lastReadTime;
Clovis 0:8f0934e41a57 81 float _lastTemperature;
Clovis 0:8f0934e41a57 82 float _lastHumidity;
Clovis 0:8f0934e41a57 83 PinName _pin;
Clovis 0:8f0934e41a57 84 bool _firsttime;
Clovis 0:8f0934e41a57 85 int _DHTtype;
Clovis 0:8f0934e41a57 86 int DHT_data[6];
Clovis 0:8f0934e41a57 87 float CalcTemperature();
Clovis 0:8f0934e41a57 88 float CalcHumidity();
Clovis 0:8f0934e41a57 89 float ConvertCelciustoFarenheit(float);
Clovis 0:8f0934e41a57 90 float ConvertCelciustoKelvin(float);
Clovis 0:8f0934e41a57 91
Clovis 0:8f0934e41a57 92 };
Clovis 0:8f0934e41a57 93
Clovis 0:8f0934e41a57 94 #endif