Using csv file in diddy web scipt
Forums:
Hi, Im currently using a modified Diddyborg web script to control me ROV. I have attached a ms 5837 02B depth sensor that allows me to know what depth my ROV is at. Max 10m. I save the results to data.csv file which I can access through an appache2 webserver. this is fie but It meas I must have a seperate webpage open and flick between pages or link it as a source on the diddy web page which takes up space on the screen.
Is it possible to use the csv file directly in the diddy web page similar to displaying distances from an ultraborg?
Also if it is possible could multiple files be displayed such as compass readings,temp,depth.
I have included my working script (its a bit rough! )
Thanks.
piborg
Thu, 07/13/2023 - 18:47
Permalink
Showing other data on WebUI
Yes, you can read CSV files into the Python script and have values shown on the web page.
We already have an example of adding a value display here. All you will need to do is replace
WiFiSignalStrength()
with the text or HTML you want to show.For reading the CSV files you can use the standard
csv
module. There is a quick explanation of how to use it here.clankerr02
Tue, 07/18/2023 - 19:26
Permalink
Flickering results
Thanks for your help. I followed your advice and used the wifi signal strength example and modified it by putting in a call for my CSV.text file.
This works and I'm able to see the sensor results in my web page. unfortunatly the results flicker between "Not conected" and the result. I suspect this is because the results in the CSV file are constantly being over written and this part of the script is seeing that. :-
# See if we are connected
if len(wifiResult) == 0:
#Not connected
wifiStrength = 'Not connected'
How can I stop this?
Also I'm not sure what parts I can omit regarding the wifi percentage and how I should label things Ive left all the wifi labels which works but would like it to reflect My sensor as it reads the depth of the ROV.
Ive included both scripts.
On a side note could the sensor depth be used with the distance once parts and stop the motors when a certain depth is reached ?
Thanks in advance
piborg
Thu, 07/20/2023 - 12:32
Permalink
Fixing the flicker
I think you are right, the flickering is caused because the script cannot always access the CSV file.
There are two things we need to handle to stop the flickering:
Most of the other file processing in that function was specific to the WiFi use and can be left out.
I think this basically covers what you need to get a clean display from the file: