I'm working on a project that will use a Raspberry pi pico w to display the minutes per day -- and per month -- that a furnace has run. Though it's not finished yet, I have it working pretty well at displaying the data on an LCD display and also on a web page that can be viewed on a browser. The next step I'd like to do is log the data, daily, and download it to a PC through the wifi.
The web page looks something like this (crude, but it works for now):And I'm saving the data every night (or every minute as a test) by writing a log file:which looks like this:
The web page looks something like this (crude, but it works for now):
Code:
def webpage(tempF, state): #Template HTML # f''' fills in fields {...} html = f""" <!DOCTYPE html> <html><title>Furnace (development)</title> <p>{time_string}</p> <form action="./reset"> <input type="submit" value="Reset" /> </form> <form action="./lighton"> <input type="submit" value="Light on" /> </form> <form action="./lightoff"> <input type="submit" value="Light off" /> </form> <form action="./setclock"> <input type="submit" value="Toggle DST" /> </form> <p>LED: {state}</p> <p>Furnace: {fan_state}</p> <table width="20%"> <tr> <td>30 day: </td><td>{month_minutes_s}<td/><td>{month_pct_s}%</td> </tr> <tr> <td>24 hour: </td><td>{day_minutes_s}<td/><td>{day_pct_s}%</td> </tr> </table> <p>Temp: {tempF}</p> </body> </html> """ return str(html)
Code:
log_file = open("logfile.csv","a") log_file.write(str("{:02}/{:02}/{}, {:0.0f}\n".format(now[1], now[2], now[0], month_minutes))) print("Logging...") #Debug log_file.close()
Code:
time, minutes 11/19/2024, 011/19/2024, 011/19/2024, 011/19/2024, 111/19/2024, 211/19/2024, 311/19/2024, 411/19/2024, 011/19/2024, 1/code]I'd like to be able to display the log file by calling it up from a browser on a desktop PC, but I'm running into a couple of obstacles.1. How to get the log file out of the pico? I can read the file line by line and output it through the terminal shell in Thonny while it's connected, but when the pico is running on its own I don't see a way to access the log file.2. How to download the log file, using HTML (or is there a better way?) Any suggestions on how to do this, or better ways, are appreciated. Thanks.
Statistics: Posted by JKJ — Sat Nov 23, 2024 3:53 pm — Replies 0 — Views 15