Category: Websites, web programming

Raspberry Pi: Python live web graphs from sensor data

I have completed the main section of Python code, I need help with building a web interface that displays 2 live updating graphs (from the sensor data my program obtains), and 2 clocks (one is standard time, the other varies according to the sensor data).
THIS CAN BE A LOCALLY RUNNING WEB INTERFACE TO PROVE THE CONCEPT WORKS.

A push button could be used as the circuit will not be available, (as long as it is connected to the same pin as specified it works fine).

Some background on what the code I have already written does:
calculates the mains AC frequency and stores this as a variable.
Reads the time using the time module
Varies a ‘frequency clock’, if the frequency is higher than 50 Hz (I am in the UK), the clock runs fast and if lower than 50 Hz, runs slower.

I would like this to be written in python. Using modules such as matplotlib / plotly / django / flask etc is fine.

If it isn’t possible to update the webpage at 50Hz (I suspect it isn’t), calculating the average frequency for the last second and updating every second (gmtime) is fine.

PROJECT SPEC AND MY CODE IS ATTACHED

coding a 4 page website

For this assignment, create a four page website using flexbox or CSS grid. The layout must adapt to the screen size. Remember design for mobile first.

You must create a responsive navigation. The navigation must adapt to the screen size.

Aim to have at least two media queries. The media queries should be based on the content.

You should have at least one responsive image for your site. The responsive image must be hidden for the smallest display (use display: none;) and resize appropriately for the medium and large displays.

CONTENT

The site should be an informational site. You can use content from wikipedia or from the public domain. If you are unsure, then create the site on Responsive Web Design using the content from wikipedia: https://en.wikipedia.org/wiki/Responsive_web_design

The home page should divide up the material into three classes or sections (article, main, aside…).  You can choose to add headings to these sections and modify the content as necessary to make it mobile first.

Make the site look beautiful using an appropriate colour theme and font(s).

Tunga

I.      Working Application

a.      Source Code

b.      Compiled Code

n      eProject Report should comprise –

q      Acknowledgements

q      eProject Synopsis

q      eProject Analysis

q      eProject Design

n      DFDs

n      FlowCharts

n      Process Diagrams

n      Database Design / Structure

q      Screen Shots

q      Source Code with Comments

q      User Guide

q      Developers Guide

n      Module Descriptions

VBA assignment

The instructions are on the first tab “Instructions”. Utilize the additional tabs, “Data” and “Output”.

When in the “Output” tab, enter Developer, and Visual Basic.

Then follow the below instructions to write out the code beginning with SUB. Within the VBA window, the instructor provided additional instructions;

Hands-On Project

Chapter 2
Project 2-1
In this project,you will create a class and use the variable defined within the class in aWeb Form. 1. Start your Web development editor and open your chapter2 Web site, if it is not already open.
2. Create a new class item in your project and name it ch2_proj1_class.vb. After it is created, your Web development editor will store the class in the App_Code directory.
3. Open the class ch2_proj1_class.vb file. Create a public instance variable named StoreAddress that is a String data type. Assign the value 555 Michigan Avenue, Chicago, IL 60016 to the variable.
4. Click the Save All button to save the class file.
5. In the Solution Explorer window, right-click the ch2_ proj1.aspx page in the ch2_ proj2 folder and click View Code.
6. In the Page_Load procedure add the code that follows to create a new object named ch2_proj1_newclass, based on the ch2_proj1_class. Because the variable contains an object, the keyword New must be used to instantiate the object from a class. As you type each period, notice that the IntelliSense list box appears. Dim ch2_proj1_newclass As New ch2_proj1_class
7. Type the code that follows to retrieve the values from the new class and assign the variable from the class to the text property of the lblContact label control in the Web page. (Note:You need to use the ToString method to retrieve the value from the string stored in the variable.) lblContact.Text = ch2_proj1_newclass.StoreAddress.ToString
8. Click the Save All button. In the Solution Explorer window, right-click the ch2_proj1.aspx page and click View in Browser. Right-click the page and click View Source to view the client-side code sent from the Web server to the browser.

Project 2-2
In this project, you will create a custom error message and enable your Web application configuration file to detect HTTP status errors.
1. Start your Web development editor and open your chapter2 Web site, if it is not already open.
2. Open the code behind the page for the Web.config file. Locate the customErrors node and modify the code (as shown in the code that follows) to redirect the visitor who has been denied access to a Web resource. (Note: Do not create a new customErrors node.) <customErrors defaultRedirect=”~/ch2_home.aspx” mode=”On”> <error statusCode=”404″ redirect=”~/ch2_proj2/ch2_proj2_404.aspx” /> </customErrors>
3. Create a new Web page named ch2_proj2_404.aspx in the ch2_proj2 folder. Add graphics and content to indicate to the visitor that the resource has not been found. Provide the visitor with a link back to the ch2_home.aspx page. (Hint:You can use the NavigateUrl property of the HyperLink control to configure the URL.)
4. Click the Save All button.
5. View the Web page in an external browser. In the URL, change the ch2_proj2.aspx to ch2_proj2_test.aspx and press the Enter key (or click the Go button in some browsers). Since this page does not exist, you should be redirected to the ch2_proj2_ 404.aspx page.
6. Print your source code for the ch2_proj2_404.aspx page and the source code for the Web.config file. 7. Save your Web.config file as ch2_proj2_Web.config in the ch2_proj2 folder. Then open the Web.config file and delete the entire customErrors node. Click the Save All button. This will return the Web configuration file to the default configuration.
8. Close any open pages.