Raspberry Pi Server improvements

First of all, I invested £7 in a micro wi-fi dongle for the RaspberryPi, which you can just about see in the photo above plugged into the upper USB port.  It is low-power and very low-profile and makes the RaspberryPi server very neat.  For basic temperature sensing, all that would be needed would be a 4-core cable from the LM75 sensor to the RaspberryPi and 5-volt power and that would be it, a device that can log and send data from anywhere within range of a wi-fi access point.

Now, it dawned on me last week (luckily after only 3 hours) that I was writing a small file out to the SD card every 5 seconds from my Python program which might be hard on the SD card with all those writes.  SD cards and Linux file systems provide some sort of wear levelling, but any application which writes intensively to the card is going to wear it out fairly quickly.  Writing to the card every 5 seconds might wear it out in a few weeks at best.

There are 2 possible solutions, which seem suited to different applications.  The one I immediately thought of was to set up a small RAM disk, point the web server's WWW directory at it and then run a start-up script to copy the fixed files (HTML, PHP, JavaScript, CSS) into the RAM disk and work from there.  Once an hour or whatever, the data could be copied to the SD card for persistence.

The other one was to use PHP to send data directly to the client browser using AJAX without an intermediate Pyhon script and file writes.  I got this working this afternoon, but without proper data as I need to research using I2C on the RaspberryPi with PHP, if this is even possible.  Using dummy data provided by PHP random number statements the results are good and over the local wireless lan refreshes of at least 4 per second (delay of 250 ms) are possible.  The photo below shows the graph displayed on a basic Android 2.3 tablet I have which is in need of a purpose.  I could see this mounted on the dashboard of the MR2 with the Raspberry Pi in AP (access point) mode, serving data via wireless from the engine.
On the other hand, I think that the RAM disk solution would be much more suitable for the home heating control system I have in mind as a summer project (when the heating is off and I won't get killed/divorced for breaking it!).  I'm not putting the Raspberry Pi in charge of the heating, that will go to a PIC16F877, but the Pi could act as the interface to the outside world via the Internet allowing data-logging and remote control and programming of the heating system.

Comments

Popular posts from this blog

Apple iPad SSH Connection to Linux Laptop

Update on the touch monitor

Skoda Rapid Heater Re-circulation Motor Repair