Serial Port Data Logger Timestamp
Hi friends, aim of this project is to present a way to store a large quantity of data into microSD card in files with FAT32 format. Here, ATmega32 is used for data collection and microSD interface. The data is received from in-build 8-channel ADC of ATmega32. One channel is used for reading temperature from LM35 sensor and remaining channels are used for simply reading voltages and storing them. This project can be used to interface 8 different sensors with ADC of ATmega32, similar to the LM35 used here. The data is stored in CSV (comma separated values) format, which can be read using a PC/Laptop with Microsoft Excel or other compatible software.
A snapshot of the excel file is given later in this post. This project is an example of how to use the microSD FAT32 library presented in my. In that post, the files were created using hyper-terminal and entering data with the PC keyboard, since that demonstrates the file creation and it's easy to debug.
But many users have requested to make the file creation independent of the terminal, done inside the microcontroller, so I'm showing here how to use those functions independent of terminal. If you have directly landed on this page, it would be more helpful if you visit the first as it would be a better starting place for learning SD or FAT32 functions. Here is the schematic (click on the images for larger view or ): The project contains RTC interface (for date and time storage), RS232 (for connection with PC) and a microSD module.
Advanced Serial Port Monitor - Hex data, Date/time stamps - Lesson 3. For Windows 2000 - Windows 10 (2016) (incl. Server, x86 and x64). Latest version: 4.4.11 build 707. July 7, 2017.
Here, the hyper-terminal connection is required only for setting RTC date and time. Once the date/time are set, the RS232 connection is not required anymore for normal data-logging operation (It can be used for debugging purpose if there is a problem). The microSD module used here is from. The module is shown in the figure here. Other than the microSD socket, this low-cost module also contains on-board 3.3v regulator for the microSD card, a 5v-3.3v level converter and other safety features required for the card.
This module is used here as it provides a stable interface and makes the the card compatible with 5v supply and 5v signals of microcontroller. The module is available at: The schematic also shows two LEDs and a push-button. The LEDs are used for indications of power and recording and the push-button is used to start-stop recording. Operation of the circuit: ----------------------------------------------- For setting RTC date/time (or for debugging mode): • Connect the microSD module, insert the microSD card • Connect the RS232 cable with the circuit. Set-up hyper terminal with 19200 baud, no parity, 8-bit data, 1 stop-bit and flow-control as 'None' • Connect the power cable and power on the circuit while keeping the push-button pressed • Green LED will glow in the circuit board • A menu will be displayed on the Hyper terminal as shown in the figure below. I think this will be easily portable to other AVRs, like ATmega128.
Are the other files the same as in the earlier project? For example I2C? I have added other I2C peripherals and would like to reatin their functionality while implementing the datalogging features to the device. Perhaps a little 'feature request': Would it be possible to keep datalogging running while temporarily ejecting the card (for the purposes to download the data to PC)? The data would be temporarily going to AVR internal EEPROM (or maybe even flash?) and after inserting the card back in, the data would be flushed. This way, no data would be lost in the process.? @Santosh: During the first start-up, as mentioned in the operation of the circuit, connect the RS232 cable, open hyper terminal (19200 baud, no parity, flow control-none) and power on the circuit while keeping the pushbutton pressed.
You'll see the options on the terminal for setting date/time etc. @Venice: Yes, the controller is working at 8MHz internal. The external crystal is optional. For setting the internal clock, you need to change the fuse values. You can use following values: Low fuse: 0xE4 High fuse: 0xD9 For more details of fuse values, refer to 'memory programming' section of the avr datasheet. I re-checked and yes, I have previously set the fuse bit correctly.
However, I still cant see anything in hyper terminal although I pressed the button once the circuit is powered. Baud rate 19200 and COM port are all correct. Well, I will continue to try and to figure out which part is wrong. By the way, 1) the button is active low right? 2) in the schematic diagram, the microSD module, pin 6 connecting to PB3, from the extremeelectronics module, I saw pin 6 is CD. What is this pin?
Since on MicroSD, there are only pins such as GND, VDD, CS, MOSI, MISO, SCK. So where comes the CD in normal MicroSD adapter. Please advice and thank you. Hi Venice, if you want to see the full menu, you need to keep the button pressed while powering on, that means you press the button first and keep it pressed when you power the circuit on.
But anyways, even if you don't press the button, you'd atleast get the first three lines on the terminal, mentioning the project title. May be you can recheck the RS232 connections, because the terminal would show atleast some garbage, if only the baudrate is not matching.
Yes, the button is active low. The CD pin is actually 'Card Detect' pin which is a switch mechanically connected with card insert mechanism. I've shown it in the schematic, but not used it in the program, just to make the code compatible with previous versions. But it can be used to detect whether the card is really inserted or not. @Paresh: No, it's not compulsory to use external module for the microSD card, it's used here to make job simpler. But if you don't have access to such a module, you can use method suggested in schematics of my previous post: @Anonymous: Yes, you can. Once the data is written and file is created or updated, you can stop the logging and go to debug mode as mentioned in the operational procedure, to read the file using hyper-terminal.
Hi, I have managed to log the values into SD card. However, for the 3v lithium battery, should the '-' of the 3v batt common ground with the entire circuit? Because if I common ground the 3v batt with the entire circuit, the LED indicating error kept blinking once I press the button to start the data log. If without the 3v Li Batt, the data can be logged, but the time cannot keep counting once the circuit is power off. So what's the problem that causing the LED to keep blinking everytime when I common ground the '-' of 3v natt? Hi, I,ve downloaded your code, put it to my new atxmega256a3b and nothing worked.Initialization passed(returned 0, card type-standart capacity), but when I'm trying to get boot sector data, function returns 1.I was debugging code for whole day, piece by piece and find out, that uC doesn't get start block token (0xfe).
I've formatted my SD card (2GB) as FAT32, with 512 b. MAby something wrong with initialization, that card doesn;t understand next commands or card formatted wrong. Please help:). @Anonymous: Do it this way for proper display of string: volt = (float)(value * 5.0)/ 1024.0; value = (unsigned int)(volt * 100)*4; voltage[6] = 'V'; //V for voltage voltage[5] = ' '; voltage[4] = (value% 10) 0x30; value = value / 10; voltage[3] = (value% 10) 0x30; voltage[2] = '.' ; value = value / 10; voltage[1] = (value% 10) 0x30; value = value / 10; voltage[0] = value 0x30; This will display two digits before decimal point and two digits after decimal point ('xx.xx V' format). Hi first excuse me because my english grammar is not good enough.
I see your nice project on and now I'm very glad too find you. I need a project like this for my school with avr codevision and 2 diferrences: 1 - I want to use an srf02 sonar module and log the distance + 2 ADC ports for voltage logging. 2 - I want the datasheet of microSD module to make the that in my home for my project.because in my country this module was not available.or if there is a way to connect the micro SD or SD directly to atmega32 can you tell me that? @Majid Hi Majid, the project you mentioned needs some hardware at my side to experiment. I can't write code and give it to you without having hardware. For the SD card module, you can use the method of using microSD card adapters which are available easily everywhere.
Check out my previous post: @Satti You can first try to use 16MHz instead of 8 MHz. The SD protocol is not available free of cost.
So, you need to use SPI protocol if you don't wanna buy the license for using SD protocol. @Robotronics for 16 MHz, no need to change anything in the code.
Just double the baudrate in the HyperTerminal which you are using to communicate. Boro Boro Shidi Jambo Mp3 Song Download there. It's 19200 with 8 MHz, make it 38400 when you use 16 MHz. Rest of the things will fit in automatically. Shaktiman Torrents on this page. @Anonymous: The storage in the FAT follows little endian format i.e.
The least significant byte is stored first. The AVR also follows little endian format. Here, in mbr structure, 'signature' is declared as an integer, a two byte variable. Hence, when you read this two bytes from memory as an integer, the compiler automatically rearranges the number and puts the first byte as least significant byte and second byte as most significant. So, 0x55 and 0xaa become 0xaa55 as an integer (a single number).
That's why while comparing also we need to compare mbr->signature with 0xaa55 and not with 0x55aa, even though in memory, 0x55 is stored first, followed by 0xaa. You can get more insight by searching on net about 'little endian' and 'big endian' difference. @Eugen: The RTC control registers are written by the functions RTC_writeTime() and RTC_writeDate() in the RTC_routines.c file. The sequence for writing these registers is as follows: - user enters the date and time using the terminal of PC - these date and time are stored in the strings date[ ] and time[ ] in the main function - from these strings, the array rtc_register[ ] is updated. These array registers are also individually defined as macros SECONDS, MINUTES etc. In the RTC_routines.h, for easier understanding - values from the array registers are written to RTC registers by calling functions RTC_writeDate and RTC_writeTime in RTC_routines.c.
Ashoka Banhatti said. The Interval defined is 1000 which means 1 sec. I am getting the records every 1 sec. The file 01042013.csv is created and appended. The only problem is when it exceeds 400k or so. ( i have correct file upto 386k and the file when it is 410k it is nonreadable.) In the PC through Card Reader when I try to open the file ( 416K) then it says ' Cannot open g: 01042013 file.
Make sure a disk is in the drive you specified.' 'the file or the directory 01042013 is corruptand unreadable. Please run the chkdsk utility.' I tried to run the chkdsk but still I cannot read the file. Thanks for this post, it is very helpfull. I have some questions: 1.
I am using an mmc module for arduino. It only 6 pins: Vcc, Gnd, Miso, Mosi, sck, and without cs or cd (i forget). How can i use this module to work for this project? I used micro sd + adapter to connect it to the module. Beside sandisk what is another type of micro sd can used in this project?
And as in the picture above, you used sandisk, what class is it? Can i use sandisk with 8Gb of size and class 10? Sir, I am using ur FAT32 library. My program works fine. In my project I doesn't have RTC. So I define fixed time and date array as and time as 05:05:05 day Monday. Now as per your program the 05052009.csv file has to be created.
The file is also created. But when I connect the SD card in PC, I couldn't see the file. I am using 2GB microSD card. My card is detected by program as 'Standard (Ver 2.x).' When I see the file via hyperterminal as per option 5, I could see that the file is present. So Kindly provide me where I am making mistake?
Waiting for your reply. Sir, i am doing project 'attendance data logger with atmega 2560', for this my application is using 4x4 matrix keypad, 16x2 lcd, sd card and rtc, first we will create all the students numbers as a folders in sd card, while student entering in to class they will enter their number on keypad that time the 'in time&date' will save on their particular folder in sd card, while they exiting from class they will enter their number on keypad again this time'out time' will save on their folder in sd card, how to do this please give me a suggestions jayachandra1043@gmail.com.
Sir, I made the circuit and burnt the HEX file. I also attached microSD card via the module you showed from eXtremeElectronuics. In putty (baud=19200,bit=8,parity=None,flow=none), it is showing garbage values once I power On the circuit. Hyperterminal not showing anything with same speed setting. The red LED is constantly blinking. Green LED not glowing. Please help me.
For my programmer, as I mentioned in the previous mail, it is showing the attached setting. There is no such option for Low fuse = 0xE4 & High fuse = 0xD9. I do not understand where lies the problem.
It will be of immense help if you please help me. Or atlest tell me which programmer to use for burning the HEX file. Hi Sir, Thanks a lot for your reply. Now I could get the message on my hyperterminal.
But the problem is it is showing 'SD card not detected' about 3 to 4 seconds after showing the first message. I am using 8GB class 10 SDHC 1, San Disk micro SD card. I have formatted it in Windows 8, FAT32, default allocation size. I am using the micro sd cared adapter from extreme electronics that you have shown in your blog. Please tell me what may be the problem. Is there any specific setting for formatting the SD card.
Is there any debug mode that I might try? Waiting very eagerly for your valuable response. Hi, I could log data into SD card after much trying and of course your help. But there are little issues that I found: 1.
The red LED starts blinking(as in card is not initialized error) after 60 seconds or 90 seconds(this time is random) after start of data logging and nothing gets logged in the card. The green LED never glows.
Can you please say anything about this? If I want to log voltage from a step down transformer(basically I want to log the AC mains voltage by a 230-0-5 Transformer).
Is that possible? Where should the two leads from the transformer secondary should go to the circuit? One more thing is the message on the hyperterminal does not always come at once every time. I have to switch off the circuit, remove the sd card module and sometimes remove the microcontroller and place them back again after some time, then the message comes properly. What might be the possible cause of this? Is the sd card module from extreme electronics necessary, or can I directly connect the micro sd card to the pins. If so what will bw the connections?
Can I use Atmega8 instead of AtMega32? Please suggest Sir.
Sells Retail Cards which is available in many retail stores. Norton Retail Cards allow you to download your security product from the internet rather than installing from a CD.
Downloading security product from the internet ensures you, your setup is the most recent version. Due to viruses and other malicious software it is very tough to install Norton product for normal computer users.
Sells Retail Cards which is available in many retail stores. Norton Retail Cards allow you to download your security product from the internet rather than installing from a CD. Downloading security product from the internet ensures you, your setup is the most recent version.
Due to viruses and other malicious software it is very tough to install Norton product for normal computer users. Have the complete set of features which can protect your digital online and offline life of the computing devices, and it not only help you to protect it but also it can maintain the stability of your computer. Help – Step-by-Step guide for Microsoft Office – Activate, Donwload & complete installation from office.com/setup online. We are providing independent support service if in case you face problem to activate or install Microsoft office product.