Hi. I have built the following project. Its to test my wifes garden bed to see if it needs watering during our Cali restricted water consumption period.
Everything works, thats the good news. The bad news is the display. It’s just butt ugly. The new data is at the bottom of the growing stack of data.
I have an Arduino testing the soil. It reports its result to its serial port. I have a RasPi connected via USB and it is reading its serial port connection with the Arduino. The RasPi records what it gets on its port, and saves the info to a CSV file.
I have a piece of code in PHP that displays the CSV file. The issue is that as it grows, the new info is at the bottom of a long list of results. How do i invert the CSV display, so its latest info is at the top of the page, and not at the bottom.
info is live displayed at www.bammo.info (spare url of mine) be kind to the poor raspi server.
The php code parsing the CSV file and serving the page is as follows.
[php]<?PHP
$file_handle = fopen(“widgets.csv”, “r”);
while (!feof($file_handle) ) {
$line_of_text = fgetcsv($file_handle, 1024);
print $line_of_text[0] . $line_of_text[1]. $line_of_text[2] . “
”;
}
fclose($file_handle);
?>[/php]
Disclosure, I am a noob at PHP and have no clue how I got all of this to work. The code is found off the net, and only changed to fix my default settings. Otherwise its as the write posted it.
I know its easy for real nerds to get an arduino posting to the net live data, for me it was exciting until I realized just how fugly it was being displayed. Any help would be appreciated on improving the display of the data would be appreciated.
Thank you to anyone who ponders how to invert a CSV file for display.