First of all: of course there are commercial products for this task and I don’t want to concur with those. But often I see that colleagues can’t afford the professinal solutions and therefore buy cheaper loggers that are not suitable for the task. Here, building it yourself can be an interesting alternative. Because it’s you who decides on which components to use you are the one who decides on the quality. And because you built it yourself you can maintain and repair it yourself.
Another remark: Wiring and code worked well in our setup but I can’t take responsibility for any damage that is done because you built your logger according to this guide.
What the device does:
This logger logs the current temperature in degrees Celsius and the relative humidity in percentage, then writes this data along with the date and the time as comma separated values to the file MyLogger.csv. This file can be imported into a spreadsheet software for further processing.
Needed Components:
- 1 Arduino Uno
- 1 Logging Recorder Shield with SD-Card reader and clock
- 1 Temperature and humidity sensor (used here DHT 22 / AM 2302)
- 1 Minibreadboard
- 1 LED red
- 1 LED green
- 1 resistor 200 ohm
- 1 resistor 100 ohm
- 1 resistor 10 kiloohm
- Breadboard cables
- 1 SD-Card (because only small data is stored this is quite deliberate, I used a 2 GB card)
- 1 power adapter (230 V AC to 9 V DC)
- Case according to personal preferences
Wiring scheme:
Arduino Code:
The code is based mainly on examples provided with the libraries used. It might be that I have drawn certain solutions from the web and haven’t noted the source. Should someone discover his/her code used here, please drop me a line so I can give propper credit.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
/* ################################################## The Q-Tip-Logger by Registrar Trek / Angela Kipp It is mainly based on the examples that come with the included libraries. However, if anyone realizes that there is a piece of code that was developed by him / her please contact me at world.museumsprojekte.de so I can add the due attribution. ################################################## */ #include <stdlib.h> #include <Time.h> #include <DS1307RTC.h> #include <Wire.h> #include <DHT.h> #include <SPI.h> #include <SD.h> #define DHTPIN 9 // what pin we're connected to #define DHTTYPE DHT22 // DHT 22 (AM2302) DHT dht(DHTPIN, DHTTYPE); const int chipSelect = 10; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); pinMode(7, OUTPUT); pinMode(8, OUTPUT); Serial.print("Initializing SD card..."); // make sure that the default chip select pin is set to // output, even if you don't use it: pinMode(10, OUTPUT); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); digitalWrite(7, HIGH); delay(5000); digitalWrite(7, LOW); // don't do anything more: return; } Serial.println("card initialized."); Serial.println("DHTxx test!"); digitalWrite(8, HIGH); delay(5000); digitalWrite(8, LOW); dht.begin(); } void loop() { // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) float h = dht.readHumidity(); // Read temperature as Celsius float t = dht.readTemperature(); // Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t)) { Serial.println("Failed to read from DHT sensor!"); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); delay(1000); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); delay(1000); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); delay(1000); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); delay(1000); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); delay(1000); digitalWrite(7, HIGH); delay(1000); digitalWrite(7, LOW); return; } Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C\t"); // Add time tmElements_t tm; RTC.read(tm); // make a string for assembling the data to log: String dataString = ""; char buffer[10]; String stringH = dtostrf(h,6,2,buffer); dataString = stringH; dataString += ","; String stringT = dtostrf(t,6,2,buffer); dataString += stringT; dataString += ","; String stringA = dtostrf(tm.Day,6,0,buffer); dataString += stringA; dataString += ","; String stringB = dtostrf(tm.Month,6,0,buffer); dataString += stringB; dataString += ","; String stringC = dtostrf(tmYearToCalendar(tm.Year),6,0,buffer); dataString += stringC; dataString += ","; String stringD = dtostrf(tm.Hour,6,0,buffer); dataString += stringD; dataString += ","; String stringE = dtostrf(tm.Minute,6,0,buffer); dataString += stringE; dataString += ","; String stringF = dtostrf(tm.Second,6,0,buffer); dataString += stringF; dataString += ","; // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. File dataFile = SD.open("MyLogger.csv", FILE_WRITE); // if the file is available, write to it: if (dataFile) { dataFile.println(dataString); dataFile.close(); // print to the serial port too: Serial.println(dataString); } // if the file isn't open, pop up an error: else { Serial.println("error opening MyLogger.csv"); digitalWrite(7, HIGH); } // Wait 5 minutes between measurements. delay(300000); } |
The Casing:
Unleash your creativity here. I used a cardboard box that was roughly the right size and cut openings for the cables and the SD Card into it with a cutter. The only really important thing is that you can operate the reset button on the shield. You can spare it in the casing, we used a q-tip with a broad plastic peg on one end so the reset button is pressed reliably.
Improvements:
By looking close you realize that this project was an emergency response, designed to be quickly available. So, there is room for a couple of improvements.
Instead of the mini breadboard it is logical to solder the components to the logger shield wihich has already a built in prototype board. The only thing to think about is that the sensor has to be outside of the casing because the outside climate should be monitored.
Then, the logger remains comparably numb. To know about your climate, you have to read the SD card or plug in your laptop ans see what the serial monitor tells you. A LCD shield would be a comfortable solution to this issue – and you could skip the LEDs and print the error messages on that LCD monitor.
Last but not least a LAN or WiFi shield could send the data to the web.
Have fun experimenting!
Angela Kipp
Read the other posts for this project:
- Build Your Own Data Logger – Investigating Your Climate Graphs
- Build Your Own Data Logger – We Want Fahrenheit!
- Build Your Own Data Logger – Processing Data With Microsoft Excel
- Build Your Own Data Logger – Processing Data with OpenOffice Calc
- Build Your Own Data Logger – The Software, Telling the Logger to Log
- Build Your Own Data Logger – Arduino, the Datalogger-Shield and the Wiring
- Build Your Own Data Logger – The Sensor, Heart of the Logger
- Build Your Own Data Logger – Quick Start Guide
This post is also available in Russian translated by Helena Tomashevskaya.








This post is also available in: German
Hello,
I built this datalogger some time ago. It is now in a box, all disconnected, would you have the schematics so I can rewire it properly without plunging back into electronics books (the logger link is dead)?
BTW, I really appreciated this article.
Thank you,
Pascale
Hi Pascale,
thanks for bringing the broken link to my attention. I fixed it in the original post.
Here you go:
Mind sharing a picture of your logger when you reassembled it? π
Cheers,
Angela
More a question
Met data loggers yonks ago, about the same time that I met lock in amplifiers.
Thinking of revisiting them.Is it possible to start with discrete transistors and a sensor to build a simple, very simple data logger ?
Hi John,
full disclosure: I never built something from gound up with discrete transistors, so take everything I write with a grain of salt.
Short answer: It’s probably possible, however you will sure need a bunch of other parts to make it work, especially if you want to make use of it in a real-world setting, so the question will arise if it makes sense to built it this way.
Long answer: For someone who understands lock-in amplifiers the electronics behind arduino and friends are probably not much of a secret and it won’t take long to find out that there are a bunch of unnecessary parts for your project on the board. The original idea of an arduino was to have an easy development/prototyping tool where you can experiment and once you are satisfied with the prototype results you build the final device with only the necessary parts.
So, back to your original question: theoretically you can built a very simple datalogger with transistors and a sensor, but I’m rather sure you also want it to either display or store the data somewhere. So you need an LCD, or control a pen on a paper strip, or need an internet connection to a server, or an SD-Card, or whatever suits your needs and fits your energy requirements. You will also want to log the correct time, so you need to include a quartz or something that serves as a clock, or you need an internet connection to sync with a time server. A lot of tasks to achieve if you want to built it from ground up. They nearly shout for a microcontroler to help you. You can buy a development board like the arduino, experiment with different setups, displays, realtime clocks, whatever tickles your developer’s nerves and once you are satisfied you buy the parts you need and an additional ATMEGA328, flash the software, solder it together and that’s that.
As prices for those boards are rather low (at least in Germany) it might even not be worth to invest time in building your own thing and just use the prototyping board in the final application. I did this especially with the ESP8266 on a NodeMCU board where I have all the neccessary things like WiFi and USB on board but which is still rather small.
Hope that helps.
Best,
Angela
The crucial point with any datalogger, commercial or home-made, is the quality of the sensors – particularly the RH sensor. Cheap sensors may be unreliable, especially at high or low RH, and they may lose their calibration quite rapidly. We all know there is a temptation to skimp on calibration, or to rely on the data uncritically, so my advice is to buy the best sensors or loggers you can afford and to calibrate them regularly.
Hi Barry,
you are right, the sensors are key, so is checking and calibrating them regularily. This post is just the Quick Start Guide, the next posts will take a deeper look at the used components and discuss the options. So, next up will be:
1. Arduino and shields
2. Sensors
3. Coding
Maybe some additional considerations, let’s see.
Of course interchanging with other posts, so the readers not interested won’t get bored π
Best wishes
Angela
Checking RH calibration beyond the effective use of an aspirating psychrometer is rarely done. However, with several loggers, typically $120USD each, you can gather them once or twice a year and compare readings. Replace any loggers that are out of acceptable range (though you can continue to use them for temperature logging). This is the most prudent and cost-effective data logger approach.
Actually, just to compare readings can lead to mistakes, as their sensors might have the same drift, especially when purchased around the same time. Your loggers might all show 10% off but you don’t realize because they all show aroud 35% instead of 45%, which seems reasonable. What proves quite effective is comparing their readings in a container with NaCl athmosphere (75%) and MgCl athmosphere (33%). You get an idea if they drift, in which direction they drift, if the drift is linear and if their reaction time is still okay.
[…] Source: Build Your Own Data Logger β Quick Start Guide | Registrar Trek: The Next Generation […]
Since you point out that commercial loggers are available to do this same task, can you cite reasons or link us to a discussion to the problems a DIY logger solves? Maybe a case study would help, including a cost comparison of commercial vs DIY.
Hi William,
thanks for the input. Unfortunately, I haven’t taken a note everytime I saw someone asking for recommendations for affordable dataloggers on the MUSEUM-L or RC-AAM listserv but I’ve seen quite a few and some of them asking if some cheap gadgets for about 50 β¬ can do the job just as well. Well, for the same price you can build your own, of course if you don’t count the costs of your own working hours. I see the following advantages:
– For the same price a comparably cheap off-the-shelf solution costs you get a logger you know what it is capable of because you know the components you used.
– If the sensor loses reliability (of course you have to check and calibrate it on a regular basis, like every logger), it is easy to replace at a reasonable price (the comparably expensive one I used here is at around 8 Euros (9 USD)). I will discuss this in the part about chosing the sensor which is coming up, this is just the quick start guide.
– As grants for preventive conservation are few but there is a high interest in supporting STEM education, it’s a win-win if you do this as a project together with your local highschool. The kids learning about coding and microcontrollers and at the same time about the importance of preventive conservation and how climate data is used at their local history museum.
– If you build it yourself, you learn a lot about coding and microcontrollers, which opens up new possibilities both for your institution as well as you personally.
Again, if you do have the money to buy a commercial logger and the money to have it calibrated regularily, go for it. There are pretty good ones on the market, of course not mentioning names here. But I know that especially small museums struggle with getting money for such devices and for them it might be easier to find technically interested volunteers to help them with building such a thing.
Of curse, if anyone is aware of a case study, I would be interested in sharing it here.
Best wishes
Angela