My little unpretentious temperature datalogger

Hi-tech electronic and computer equipment and Internet. Better use of electricity, help with the work and specifications, equipment selection. Presentations fixtures and plans. Waves and electromagnetic pollution.
User avatar
Forhorse
Econologue expert
Econologue expert
posts: 2486
Registration: 27/10/09, 08:19
Location: Perche Ornais
x 360




by Forhorse » 04/04/11, 16:21

kumkat wrote:what would be nice is not to empty the memory of the measurements when you remove the sd card, history to access values ​​by month, seasons, years ... minis, maxis, averages
in this case it is necessary to provide a solar power supply which would theoretically allow an infinite use over time ;-)


The measurement memory is not emptied when the card is removed. These remain present as long as the file is not manually removed from the card.
However, it goes without saying that the system cannot record if no card is present.

So if not, here are the latest improvements to my program. I did not do everything I wanted because I have already spent too much time on this project and I must now move on to other things (my wind turbine regulator for example)

Here you will find a zip archive containing two files:
http://www.stable-boy.net/uploads/LOG18B20.zip
the LOG18B20.hex file is the compiled program that can be directly flashed in the PIC
The LOG18B20.bas file is the file containing the program sources, written in BASIC for the Proton + compiler
It is readable with any text editor (notepad for example) just to get an idea of ​​what the program does, but to really use it you will need the Proton + compiler, the Library Manager plug-in and the SD_File_System library (everything is available on the publisher's site: http://www.protonbasic.co.uk/)
The Proton + compiler is generally sold for around € 230, so it goes without saying that it is not software that you only buy to make a temperature recorder! : Cheesy:
On the other hand I highly recommend it to all those who would like to get started "seriously" in the realization of editing and the writing of programs for PIC and who would not have any particular affinity with another language (those who know C will will turn for example to other compilers)

As regards my datalogger more concretely here are some explanations:
The heart of the assembly is therefore a PIC18F258 in which the program given above takes place.
PGD, PGC, GND, VDD and VPP are the "ICSP" interface used to program or reprogram the PIC directly on the circuit, it is not essential but just more practical. To be adapted according to your programmer (I use a PicKit2)
It must be associated with a quartz or a ceramic resonator at 12 MHz

The display (essential to be able to set the time) is of the alphanumeric type with 2 lines of 20 characters with the classic controller HD44780 or equivalent (KS0066 ...)

The DS18B20 is a temperature sensor on a "1 wire" bus, this type of component is factory calibrated and therefore does not require any adjustment to provide a correct temperature.
The measurement range goes from -55 ° C to + 125 ° C (which is fully supported by my assembly)

The DS1307 is a real time clock (RTC) on the I2C bus which is used to count the time and date even when the assembly is not energized.
It must be associated with a 32.768kHz "watchmaker" quartz and a 3V lithium battery (CR2012 type)
This model integrates an NVRAM which is not used in this assembly, one can thus replace it by an equivalent (M41T00 for example)

The LM3480 regulator (VR1 on the diagram) is a 3.3V "low-drop" regulator It transforms the 5V of the rest of the assembly into 3.3V essential to power the SD-card (supplying it directly with 5V would destroy it immediately) Any equivalent is suitable, it is not critical (I propose the TPS73033 but there are many others)
R1, R2, R3, R4, R5, R6 and R7 constitute a "level translator" between the PIC in 5V and the SD-card in 3.3V
There are specific components for this, but a resistive bridge also works very well.
Attention to the wiring of the SD-card, seen on the connection side, connector at the top, the leftmost pin (beveled side) is not the 1 but the 9, the pin 1 is only the second from the left ( a history of backward compatibility with MMC)
The support of SD-card can be bought easily (for example reference 685-0779 at rs-individuals) but can also be recovered on an HS device (the one that I use for my tests comes from a front of auto- roadside radio)

S1 and S2 are two push buttons used to adjust the time and date, or to start / stop recording.
The LED indicates that the recording is in progress and that the SD-card must not be removed.

The assembly is powered by 5V, we can "recycle" a mobile phone charger for example, many chargers are now "USB" standard and therefore provide 5V
Consumption is around 20mA, which is relatively low, but still too large to operate on a battery for more than a few tens of hours.
In stand-alone, a small battery and a solar panel can be considered.
To supply it from another voltage, a simple LM7805 regulator is sufficient.

Regarding the operation of the assembly now:
When the power is turned on, the time is read in the RTC, if it is the first power up or if there was no backup battery, a menu for setting the time and date s poster.
If an SD-card is present, a recording file is created with the name LOGFMMDD.csv (where MM represents the month and DD represents the date) and recording starts immediately without intervention.
Otherwise a message inviting to insert a card is displayed.
The LED lights up; indicating that the card should not be removed.
On the screen the current time and date are displayed on the top line, while on the bottom line is indicated the temperature and an animation indicating the recording.

To end the recording, to remove the card or switch off the edit; you must press the "+" button (S1 on the diagram)
the LED then goes out, and on the second line is displayed "closed file" for a few seconds.
You can resume recording by pressing "+" again
If you remove the card without stopping the recording, the file may be corrupted (especially the last value) and therefore unreadable.
It is not systematic but it is a risk (the vagaries of IT ...)
Stop recording, remove the card, read it with a PC, put it back and start recording again is possible but not supported.
This manipulation risks causing the program to "crash" and if it works, it will sometimes take several minutes for the program to resume writing to the card.
In general, before removing or changing a memory card, it is preferable to turn off the montage in order to restart the initialization sequence each time a card is inserted.

The temperature is acquired at most every 750 ms, i.e. more than a second, but the system only takes one measurement per second into account.
It then averages over 1 minute (i.e. 60 measurements) and saves it on the card with the date and time in the following format
"HH: MM: SS; XX, X"
with 1 record per line
At midnight the file is closed and saved and a new one is automatically created with the new date. Recording continues automatically until the card is full.
The system therefore makes a maximum of 1440 registrations per day, the file is 23Kb per day (or 161Kb per week 713Kb per month and 8.3Mb per year ... a 1GB card therefore allows theoretically to record for 116 years)

The file (.csv) can be opened directly in Excel and you can in a few click make a curve from the data which are directly usable.

To set the time, just press the "set" button. During the entire time setting procedure, data recording does not take place (even if the LED remains on)
The cursor flashes on the value being modified. We start with the year, then the month, then the date, then the hour to end with the minutes. The "+" button is used to increase the value, validate and go to the next one with "Set"
The minutes must be set one minute more than the reference clock. Once the minutes have been validated by Set, the display indicates "'Set' to validate" we wait for the reference clock to be at 59 seconds and we validate, the two clocks are then perfectly synchronized.

In the event of a power failure, recording stops naturally, but resumes automatically when the voltage returns.
it can be useful for example to monitor a freezer. We can for example visualize the temperature at the return of the current and therefore know if it has thawed or not, and know at the same time the duration of the cut by making the difference between the time of the last recording and that during the return current.

The PIC memory is far from being saturated, 32% of the RAM and 66% of the program memory remain available, which leaves plenty of room to improve this recorder: management of several probes or other types of sensors, more complex calculation on measurements, etc.

For my part, I stop there the development of this device (for the moment) but I could possibly add functions requested for someone who would have carried out this assembly.
I can also, on request, compile the file for a PIC of another reference that would be compatible with this project (the 18F258 is not an obligation)

Well, maybe soon for other hacks

: Cheesy:
0 x

 


  • Similar topics
    Replies
    views
    Last message

Back to "Electricity, electronics and computers: Hi-tech, Internet, DIY, lighting, materials, and new"

Who is online ?

Users browsing this forum : Google [Bot] and 258 guests