Rebecca Bray : ITP : Spring 2006 : Sensor Workshop Class

March 03 , 2006
Datalogging

I wanted to log the data from an analog sensor over time, using processing and PHP to create a dynamically updated html file.

For the first pass, I used Tom’s code - http://www.tigoe.net/pcomp/code/archives/php/000713.shtml - for the PIC, Processing and PHP. I used a potentiometer on the board.

Issue: datalog.txt was not write-enabled.
Solution: change to write-enabled by telnet on SSH with chmod 666

[rb1551@itp ~]$ telnet itp.nyu.edu 80
[rb1551@itp ~]$ ls\

public_html
[rb1551@itp ~]$ cd public_html
[rb1551@itp public_html]$ ls
flash2 index.html logger.php datalog.txt
[rb1551@itp public_html]$ chmod 666 datalog.txt

Now it works!
http://itp.nyu.edu/~rb1551/datalog.txt

Issue: time stamp wrong.
Is this an issue on the server? Is it possible to fix with php code?

Datalog.txt log:
2006-02-25 05:02:57 1021
2006-02-25 05:02:01 598
2006-02-25 06:02:51 0
2006-02-25 06:02:55 0

This data came up between 6:07 and 6:09. Processing output looks like this:

Wrote 2006-02-25 06:02:43 0
to file datalog.txt

However, it does say
HTTP/1.1 200 OK
Date: Sat, 25 Feb 2006 23:09:34 GMT – which is the correct time in Greenwich, but translated incorrectly here

Looking at php.net, I got it to display military time, but it’s still incorrect. It does show the 4 to 5 second intervals, but the incorrect minutes.

Adding ,$timestamp to the php, excitingly enough, makes it 9pm on December 31st, 1969.
I removed that, and tried writing date_default_timezone_set('GMT');, but that stopped the writing altogether. As did trying to include a time() function.

Kate and Zach are having the same problem. Kate has emailed Tom…

Oh wait – it seems to be working now!

Now what I’d like to do is use a flex sensor as my analog sensor and record the data on that while simultaneously video taping the flex action with a clock in the background of the video that matches exactly the timestamp on the data. It seems like a good way to compare data with a visual reference.

Links:

my data logger - http://itp.nyu.edu/~rb1551/datalog.txt

php code - php text file code

telnet code - code used in telnet session to make connection

php time - http://us3.php.net/manual/en/function.time.php

dynamic web development class site for more sql, php info - http://itp.nyu.edu/~cs220/dwd/

 


My Links

Sensor Workshop

PComp

Main RBray:ITP

 

Resources

Class site

Physcomp main

Tom's site and resources

John Babcock - good documentation

Educypedia - sensors

 

Inspiration

Tom's inspiration list

Jen Lewin - Laser Harps, Butterfly, etc.

Jim Campbell LED movies

Jeff han

Solarbotics

 

 

Back to Top