Portable temperature, humidity and light ambient datalogger. Part 2
The software for the datalogger is download section (PIC_DATALOG_V00d). I use Mikroc Pro PIC compiler from mikroElektronika, the libraries of this compiler are great! Especially the FAT32 library, it allows to manage the micro SD card on a very easy way. Current version is 00D, and I’m still working on it. I know there’re many things that I can optimize, process that could be simpler…..but the board is still on debug!
There’re many considerations on this SW, I’ll try to explain some important points, but if you have any doubt with something, please comment it and I’ll try to answer!
At power-up, system configures and check all the peripherals: configure GPIO’s, UART, I2C, SPI, RTC status and set the time for the files on the SD card. Also reads the device ID, a parameter that identifies the datalogger (value stored in microcontroller EEPROM) (Figure 14).
Files on the SD has the following name format: yyyymmdd.ext . That is, year, month and day. The extension file is initially ‘000’. Every new day, system creates a new file with the same format, so every 24 hours, you’ll have a new file.
System has defined a time to update all the parameters and store it on the SD. This time is configurable by user, and can go between 1s and 999s. When a update event occurs, the system reads all the sensors and parameters and store data on the SD.
With the P1 pushbutton, you can put a mark on the file. That means that in this moment, you force a update event, so sensors are read and store on the SD card (Figure 15). With the P2 pushbutton, you can make a new file. Filename will be the same but extension changes to 001, 002….and so on. Every push on P2 makes a new file (Figure 16).
Data fomat: on the SD card files. you’ll find a new file for every day. This files has plain-text format and separated by ‘;’, for an easy import with excel or similar software (Figure 17). File has the following fields:
For example, Just a fast graphic of the battery level across 4 days (Figure 18).
Every days a new file is created. To merge all the files in only one to easy import into excel and make graphics, you can use the following command: type *.* >> out_file.txt
As you can see, I implement a command-line commands to have info or set parameters of the datalogger. To connect with the board, just plug the USB cable and install the virtual COM port driver of the MCP2221. I use Tera term software for this. Baud rate is 9600 bps, 8, N,1. Important! Set ‘Local Echo’ to see the commands you send to the board. The command list I implement on the board is the following one:
Datalogger source code and .hex-file - download
News on theme: