I’ve been a hardware hacker mostly, and when I write software it is usually low-level code used to control microcontrollers.  But lately I’ve been dabbling in the much more sexy world of web app design.  I’ve been learning (slowly) all the various tools out there including Google’s new Dart language along with the tried and true Javascript, PHP, HTML, CSS, mySQL, JSON, etc.  I have been able to create some very powerful web only apps using Dart.  But I am still drawn back to my hardware roots and haven’t gotten to the point of being able to interface Dart with hardware like the Arduino … yet.  For that I am relying on the seemingly ancient and highly insecure (yes I know) hodge podge of some PHP and text files to make some remote, publicly accessible dataloggers.  My next step will be to add some security by utilizing a mySQL database with access control vice a flat text file.  But this project is about learning baby steps first.

The project I’ve been tinkering with involves sending light data from a voltage divider/photoresistor circuit and broadcasting that light intensity data to the web.  Here is a video to explain:


My github repository is here.  Functionality is achieved using 6 files (who could use a much betternaming convention but I am all about speed!):

  1. LightSensor.php – The public facing webpage is generated with the PHP script.
  2. LightSensorWriteToFile.php – PHP script the Arduino sketch calls upon using HTTP GET request to send sensor data to server for storage.
  3. sensor.css – Used by LightSensor.php to make the format look really pretty like!
  4. sensorLog.txt – The archive log of sensor readings sent to the server.
  5. WebPHPLightSensor.ino – The firmware sketch that runs on the Arduino to handle sensor interfacing and communication to the web.
  6. ProcessingPHP.pde – Processing sketch that help visualize the sensor log data by generating a graph from the sensorLog.txt file.  Can be refreshed as desired by clicking in the window and pressing ‘R’ on the keyboard.
Please not that in the Arduino sketch file you will need to edit the MAC address, IP address, server address, and the filepath to make this work for you.  FYI all my file sit off my root directory in a folder called /php.  Here is a quick webpage to display that data graphically via php.