{"id":130,"date":"2008-05-21T00:23:25","date_gmt":"2008-05-20T22:23:25","guid":{"rendered":"http:\/\/www.doenges.com\/blog\/?p=130"},"modified":"2009-01-21T18:07:37","modified_gmt":"2009-01-21T17:07:37","slug":"voltcraft-k204-datalogger-on-mac-os-x","status":"publish","type":"post","link":"https:\/\/doenges.com\/blog\/2008\/05\/21\/voltcraft-k204-datalogger-on-mac-os-x","title":{"rendered":"Voltcraft K204 Datalogger on Mac OS X"},"content":{"rendered":"<p>Conrad Electronic sell the <a href=\"http:\/\/www.conrad.de\/goto.php?artikel=100567\">Voltcraft K204<\/a> datalogger, which is a 4 channel temperature logger. [Note that the above link is to the German Conrad website. The links to other sites are, unfortunately, not the same, so you will have to perform a search on each national site.]<\/p>\n<p>The logger allows you to capture up to 16,000 samples from up to four different K-Type temperature probes. Depending on the probes, a temperature range of -200\u00b0C (-328\u00b0F) to 1370\u00b0C (2498\u00b0F) may be covered with a 0.1\u00b0C resolution.<\/p>\n<p>The K204 sports a serial port and comes with a RS232 cable. No Macintosh computer has come with a RS232 port for the last &#8230; what &#8230; decade or so?<\/p>\n<p><!--more--> Fortunately for me, Conrad also sell a <a href=\"http:\/\/www.conrad.de\/goto.php?artikel=100796\">USB adapter<\/a> for the device. Unfortunately, but predictably, only Microsoft Windows compatible software is included on the CD.<\/p>\n<p>I plugged the USB adapter in and checked the device ID. It turns out that the adapter is basically a <a href=\"http:\/\/www.silabs.com\/\">Silicon Labs<\/a> CP2102 <a href=\"https:\/\/www.silabs.com\/products\/interface\/usbtouart\/Pages\/default.aspx\">USB to UART bridge<\/a> .\u00a0Silicon Labs provide a number of <a href=\"https:\/\/www.silabs.com\/products\/mcu\/Pages\/USBtoUARTBridgeVCPDrivers.aspx\">drivers<\/a> , including a Linux and a Mac OS X driver for the device. Conrad provide a <a href=\"http:\/\/www.produktinfo.conrad.com\/datenblaetter\/100000-124999\/100567-da-01-en-Schnittstelle_4-K_DATA-LOGGER_309_K204.pdf\">brief description of the communications protocol<\/a> used by the K204. That is what I call useful customer support!<\/p>\n<p>After a couple of hours of work, most of which where spent figuring out the differences between the protocol description and the real protocol, I had a working application to read all data samples from the device on Mac OS X.<\/p>\n<p>It is very simple to use:<\/p>\n<p>1. Open a Terminal.app.<\/p>\n<p>2. Type:<\/p>\n<p><code>&gt; k204\u00a0\/dev\/tty.SLAB_USBtoUART dumpfile.txt<\/code><\/p>\n<p>where <code>\/dev\/tty.SLAB_USBtoUART<\/code> is the serial device created by the driver and <code>dumpfile.txt<\/code> is the file you want to create.<\/p>\n<p>This will create a file\u00a0with content similar to this sample:<br \/>\n<code>Data Set:\t1<br \/>\nSample start:\t2008-05-02 17:56:18<br \/>\nSample interval in seconds:\t60<br \/>\nSensor type:\tK-Type<br \/>\nTemperature unit:\tCelsius<br \/>\nNumber of sample sets:\t16000<br \/>\nData Set\tCH1\tCH2\tCH3\tCH4<br \/>\n2008-05-02 18:56:18\t25.2\t26.5\t46.5\t17.1<br \/>\n2008-05-02 18:57:18\t25.1\t26.5\t46.5\t17.1<br \/>\n2008-05-02 18:58:18\t25.1\t26.6\t46.5\t17.1<br \/>\n2008-05-02 18:59:18\t25.2\t26.6\t46.5\t17.0<br \/>\n2008-05-02 19:00:18\t25.1\t26.6\t46.5\t17.0<br \/>\n2008-05-02 19:01:18\t25.2\t26.5\t46.5\t17.0<br \/>\n2008-05-02 19:02:18\t25.2\t26.6\t46.5\t17.0<br \/>\n2008-05-02 19:03:18\t25.2\t26.4\t46.5\t17.0<\/code><\/p>\n<p>Note that you may have multiple data sets, depending on how and what you captured. In this case, you will have multiple <code>Data Set:<\/code> headers.<br \/>\nThe fields are TAB (&#8216;\\t&#8217;) separated.<\/p>\n<p>3. You can remove the header from the file using a text editor or by using the shell command<\/p>\n<p><code>tail -n +7 dumpfile.txt &gt;dumpfile.tsv<\/code><\/p>\n<p>4. Your favorite data display tool will now render the file. You can use OpenOffice\/NeoOffice or Excel or whatever. I like using <a href=\"http:\/\/www.gnuplot.info\/\">gnuplot<\/a> :<\/p>\n<p><code># Plot data downloaded from K204 Thermologger<br \/>\n# These settings are optimized for use with the PostScript driver.<br \/>\n<\/code><\/p>\n<p><code># define line styles<br \/>\nset style line 1 linetype 1 linecolor rgb &quot;red&quot; linewidth 1<br \/>\nset style line 2 linetype 2 linecolor rgb &quot;dark-red&quot; linewidth 1<br \/>\nset style line 3 linetype 3 linecolor rgb &quot;orange&quot; linewidth 2<br \/>\nset style line 4 linetype 4 linecolor rgb &quot;blue&quot; linewidth 1<br \/>\nset style data fsteps<br \/>\n<\/code><\/p>\n<p><code>set xlabel &quot;Date\\Time&quot;<br \/>\nset timefmt &quot;%Y-%m-%d %H:%M:%S&quot;\t#2008-03-21 13:20:00<br \/>\nset yrange [ 0 : 80 ]<br \/>\nset xdata time<br \/>\n#set xrange [ &quot;2008-03-25 15:28:19&quot;:&quot;2008-03-26 20:52:54&quot; ]<br \/>\nset ylabel &quot;Temperature\\n\u00b0 C&quot;<br \/>\nset format x &quot;%d.%m.%y\\n%H:%M:%S&quot;<br \/>\nset key inside left top vertical Right noreverse enhanced autotitles nobox<br \/>\nset style data fsteps<br \/>\n<\/code><\/p>\n<p><code>set grid nopolar<br \/>\nset grid xtics nomxtics ytics nomytics noztics nomztics \\<br \/>\nnox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics<br \/>\nset grid layerdefault   linetype 0 linewidth 1.000,  linetype 0 linewidth 1.000<br \/>\n<\/code><\/p>\n<p><code>set title &quot;02-MAY-2008 18:56 - 02-MAY-2008 21:35&quot;<br \/>\nplot &quot;dumpfile.tsv&quot; using 1:3 title &quot;T_{1}&quot; linestyle 1, \\<br \/>\n&quot;dumpfile.tsv&quot; using 1:4 title &quot;T_{2}&quot; linestyle 2, \\<br \/>\n&quot;dumpfile.tsv&quot; using 1:5 title &quot;T_{3}&quot; linestyle 3, \\<br \/>\n&quot;dumpfile.tsv&quot; using 1:6 title &quot;T_{4}&quot; linestyle 4<\/code><\/p>\n<p>Which gives you this &#8211; admittedly somewhat boring, but rather good-looking &#8211; plot:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.doenges.com\/blog\/wp-content\/uploads\/dumpfile.png\" alt=\"gnuplot rendering of the sample data above\" \/><\/p>\n<p>Congratulations, you have made it this far, so here is your reward: I am releasing the <a href=\"http:\/\/www.doenges.com\/blog\/wp-content\/uploads\/k204.c\">sources<\/a> under a <a href=\"http:\/\/opensource.org\/licenses\/bsd-license.php\">BSD-style license<\/a> .<\/p>\n<p>The sources compile and run under Mac OS X 10.4.9 and later. I have not tried 10.5 yet, but I see no reason why there should be a problem.<\/p>\n<p><strong>Update:<\/strong> It works just fine under 10.5. \ud83d\ude42<\/p>\n<p>Similarly, I fully expect the program to compile and run under most BSD or Unix variants (including Linux), providing they support the <tt>tcgetattr()<\/tt> \/<tt>tcsetattr()<\/tt> options used.<\/p>\n<p>I am very interested in hearing from you if you deployed the program on other platforms. Drop me a line or submit a comment and, most importantly, share your modifications so that everyone can profit. Have fun!<\/p>\n<p><strong>Update 21-JAN-2009:<\/strong> Silicon Labs have changed the links on their website, so I changed mine. Come on guys, how long have you been at this web game?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Conrad Electronic sell the Voltcraft K204 datalogger, which is a 4 channel temperature logger. [Note that the above link is to the German Conrad website. The links to other sites are, unfortunately, not the same, so you will have to perform a search on each national site.] The logger allows you to capture up to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[670,666,667,715,104,669,577,668,665,671],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-software","tag-bsd","tag-datalogger","tag-driver","tag-gnuplot","tag-mac-os-x","tag-open-source","tag-software","tag-source-code","tag-temperature","tag-unix"],"_links":{"self":[{"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/posts\/130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/comments?post=130"}],"version-history":[{"count":4,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":335,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/posts\/130\/revisions\/335"}],"wp:attachment":[{"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/media?parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/categories?post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doenges.com\/blog\/wp-json\/wp\/v2\/tags?post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}