From 8d2e2a6931e87f270c6b38a608f314cf610ed19f Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 12:51:53 +0100 Subject: [PATCH 1/8] node design questions. --- docs/brainstorm/Feedback.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/brainstorm/Feedback.md b/docs/brainstorm/Feedback.md index ef24117..2a976f0 100644 --- a/docs/brainstorm/Feedback.md +++ b/docs/brainstorm/Feedback.md @@ -33,4 +33,13 @@ We Wil use this Feedback and see what we can do to change the design in a way th The design will be updated to include: `smaller holes for less distraction. `ventilation at the bottom for better airflow. -`Remove the lamps on top of the node for less distraction. \ No newline at end of file +`Remove the lamps on top of the node for less distraction. + +### Design questions led by bram +We have a wooden and plastic design. We were wondering wich one is more easy to look at, and wich one can be more distracting. + +1. wich design is more likable + +2. wich design is more distracting. + +3. Any further comments about the design? \ No newline at end of file From 9598a64f0e1fcfbcc695286aee4e90de2f1ebc39 Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 13:45:26 +0100 Subject: [PATCH 2/8] Usertest node design --- docs/brainstorm/Feedback.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/brainstorm/Feedback.md b/docs/brainstorm/Feedback.md index 2a976f0..3d05391 100644 --- a/docs/brainstorm/Feedback.md +++ b/docs/brainstorm/Feedback.md @@ -40,6 +40,27 @@ We have a wooden and plastic design. We were wondering wich one is more easy to 1. wich design is more likable + Sebas : plastic looks better and goes straight to the point. + Skip : plastic looks more clean. + Dano : plastic is more smooth. + Sietse : plastic is better. + Ishak : Wood is more ecofriendly. + 2. wich design is more distracting. -3. Any further comments about the design? \ No newline at end of file + Sebas : wood is more distracting and more obvious. + Skip : wood, because the school walls are more darker themed. + Dano : wood looks off. + Sietse : wood would be out of place. + Ishak : Wood, but in a good way. + +3. Any further comments about the design? + + Sebas : Don't do wood, plastic is more sleek. + Skip : plastic looks more professional. + Dano : no. + Sietse: no. + Ishak : in the wood you can burn in your logo. + +In conclusion, Even though the wood would atract more attention, the plastic looks better according to the students. +So from this information we will continue to make plastic cases for the nodes. \ No newline at end of file From 4eeb80cdb23e1e6345680412a60ab2e5148abaf9 Mon Sep 17 00:00:00 2001 From: Sietse Jonker Date: Tue, 26 Mar 2024 13:47:28 +0100 Subject: [PATCH 3/8] Add Brams script for processing and storing data from WebSocket --- server/brams-script.py | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 server/brams-script.py diff --git a/server/brams-script.py b/server/brams-script.py new file mode 100644 index 0000000..acdaf98 --- /dev/null +++ b/server/brams-script.py @@ -0,0 +1,65 @@ +import asyncio +import websockets +import mysql.connector +import json + +async def process_data(data): + try: + mydb = mysql.connector.connect( + host="localhost", + user="root", + password="Dingleberries69!", + database="NodeData" + ) + cursor = mydb.cursor() + + MACDataReading = mydb.cursor() + MACDataReading.execute("SELECT MAC FROM Node") + print('some_response') + query = "INSERT INTO `Measurement` (NodeID, Type, Value) VALUES (%s, %s, %s)" + processedData = json.loads(data) + processedTemp = (processedData['Temp']) + processedHumi = (processedData['Humi']) + processedeCO2 = (processedData['eCO2']) + processedTvoc = (processedData['TVOC']) + processedMAC = (processedData['node']) + MACTuple = (processedMAC,) + + MACDataFetching = MACDataReading.fetchall() + MACArray = list(MACDataFetching) + + + if MACTuple not in MACArray: + addingNode = "INSERT INTO `Node` (MAC) VALUES (%s)" + cursor.execute(addingNode, MACTuple) + mydb.commit() + + pushingDataArray = [(1, "Temp", processedTemp), (1, "Humi", processedHumi), (1, "eCO2", processedeCO2), (1, "TVOC", processedTvoc)] + for i in pushingDataArray: + print(query ,i) + cursor.execute(query, i) + mydb.commit() + + except mysql.connector.Error as err: + print("MySQL Error:", err) + finally: + cursor.close() + mydb.close() + +async def receive_data(): + uri = "ws://145.92.8.114/ws" + + try: + async with websockets.connect(uri) as websocket: + while True: + data = await websocket.recv() + print(f"Received data: {data}") + await process_data(data) + except websockets.ConnectionClosedError as e: + print("WebSocket connection closed:", e) + +async def main(): + await receive_data() + +asyncio.run(main()) + From 9f295d7bb39cec34558e7978c1cb898ad6a99895 Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 14:42:07 +0100 Subject: [PATCH 4/8] Feedback updates --- docs/brainstorm/Feedback.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/brainstorm/Feedback.md b/docs/brainstorm/Feedback.md index 3d05391..a05f548 100644 --- a/docs/brainstorm/Feedback.md +++ b/docs/brainstorm/Feedback.md @@ -38,21 +38,23 @@ The design will be updated to include: ### Design questions led by bram We have a wooden and plastic design. We were wondering wich one is more easy to look at, and wich one can be more distracting. -1. wich design is more likable +1. which design is more likable Sebas : plastic looks better and goes straight to the point. Skip : plastic looks more clean. Dano : plastic is more smooth. Sietse : plastic is better. Ishak : Wood is more ecofriendly. + Nailah : PLastic looks cooler -2. wich design is more distracting. +2. which design is more distracting. Sebas : wood is more distracting and more obvious. Skip : wood, because the school walls are more darker themed. Dano : wood looks off. Sietse : wood would be out of place. Ishak : Wood, but in a good way. + Nailah : plastic looks more interesting. 3. Any further comments about the design? @@ -61,6 +63,7 @@ We have a wooden and plastic design. We were wondering wich one is more easy to Dano : no. Sietse: no. Ishak : in the wood you can burn in your logo. + Nailah : The wood can look better inside the school. In conclusion, Even though the wood would atract more attention, the plastic looks better according to the students. So from this information we will continue to make plastic cases for the nodes. \ No newline at end of file From 2ef003ef3902b1af9886fd20ee26ba93fe3b5c67 Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 15:05:53 +0100 Subject: [PATCH 5/8] Bram documentation. --- .../documentatie/FirstDocumentation.md | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/docs/LearningProcessBram/documentatie/FirstDocumentation.md b/docs/LearningProcessBram/documentatie/FirstDocumentation.md index 4f2778a..4496ae1 100644 --- a/docs/LearningProcessBram/documentatie/FirstDocumentation.md +++ b/docs/LearningProcessBram/documentatie/FirstDocumentation.md @@ -11,34 +11,34 @@ Then I came across a teaching site (https://www.codingkids.nl/arduino-buzzer.htm I watched a video about using Arduino and took a lot of op notes along the way. The link is: (https://www.youtube.com/watch?v=BLrHTHUjPuw). ``` -\/\/Arduino information: +// $Arduino information: -\/pinnumber(locatie, in-/output) +//pinnumber(locatie, in-/output) -\/digitalwrite(locatie, high/low) +//digitalwrite(locatie, high/low) -\/delay(time in millisec) +//delay(time in millisec) -\/int... <- variable +//int... <- variable -\/with a decimal its a double -> 1,2 +//with a decimal its a double -> 1,2 -\/a character is a char -> "a" +//a character is a char -> "a" -\/\/serial communications: +// $serial communications: -\/setup: +setup: Serial.begin(9600) -> the text speed Serial.sprintLn(text) -\/Loop: +Loop: Serial.print("text") Serial.printLn(....) -> variable because no " -\/Ctrl + shift + M = serial monitor. +//Ctrl + shift + M = serial monitor. The text speed needs to be the same as given. -\/\/If Statements: +// $If Statements: if(condition){ @@ -50,9 +50,9 @@ if(condition){ } -\/&& = "and" +// && = "and" -\/|| = "or" +// || = "or" \/\/For loops: @@ -62,11 +62,11 @@ For(int*i; i <= 10 ; i++){ } -\/The fading of led's: +// The fading of led's: examples, basics, fade -\/ servo's +// servo's examples, servo, sweep ``` @@ -176,16 +176,18 @@ The code is short and simple: int button = 20; int buzzerone = 12; int buzzertwo = 11; - +``` +Now we set the pins up to either input or output a signal. +``` void setup() { //put down some pins that will output , and some that input. pinMode(button, INPUT); pinMode(buzzerone, OUTPUT); pinMode(buzzertwo, OUTPUT); } - - - +``` +Here the button pin will seek a signal, when it is given it will send signals to the other given pins in he if-statement. +``` void loop() { //read is there is input on the button pin, if so send output to the other pins, otherwise keep them off. if(digitalRead(button) == HIGH){ From c4c36de0f7329d4689f7fe7d929a7b4186e0b108 Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 15:16:30 +0100 Subject: [PATCH 6/8] Bram documentation updated --- .../documentatie/FirstDocumentation.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/LearningProcessBram/documentatie/FirstDocumentation.md b/docs/LearningProcessBram/documentatie/FirstDocumentation.md index 4496ae1..8cf660c 100644 --- a/docs/LearningProcessBram/documentatie/FirstDocumentation.md +++ b/docs/LearningProcessBram/documentatie/FirstDocumentation.md @@ -101,12 +101,16 @@ I wanted to make my own spin on the original design by including a button to act The rest of the tutorial was clear and worked like a charm. the code used looks like this: +Begin by including a specific library for the DHT11. ``` #include "DHT.h" #define DHTPIN 4 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); - +``` +using This perticulair serial port, means that you do have to switch to it when you want to see results coming in. +The dht.begin command starts the process. +``` void setup() { //the serial port: Serial.begin(9600); @@ -116,7 +120,11 @@ Serial.println(F("DHTxx test!")); //the library start dht.begin(); } +``` +It starts by making float variables, to give over the information. +It also includes a error message in case of no feedback. +``` void loop() { delay(2000); //a float has decimal numbers and the library reads the measurements. @@ -134,7 +142,7 @@ void loop() { float hif = dht.computeHeatIndex(f, h); float hic = dht.computeHeatIndex(t, h, false); - //all serial.ptint's send stuff to the serial board to showcase. + //all serial.print's send stuff to the serial board to showcase. Serial.print(F("Humidity: ")); Serial.print(h); Serial.print(F("% Temperature: ")); @@ -186,7 +194,7 @@ pinMode(buzzerone, OUTPUT); pinMode(buzzertwo, OUTPUT); } ``` -Here the button pin will seek a signal, when it is given it will send signals to the other given pins in he if-statement. +Here the button pin will seek a signal, when it is given it will send signals to the other given pins in the if-statement. ``` void loop() { //read is there is input on the button pin, if so send output to the other pins, otherwise keep them off. From 93bf3aed3786a738960b7f4c8eb7d9f71b8664bc Mon Sep 17 00:00:00 2001 From: Bram Barbieri Date: Tue, 26 Mar 2024 15:20:40 +0100 Subject: [PATCH 7/8] Feedback updated --- docs/brainstorm/Feedback.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/brainstorm/Feedback.md b/docs/brainstorm/Feedback.md index a05f548..6bed684 100644 --- a/docs/brainstorm/Feedback.md +++ b/docs/brainstorm/Feedback.md @@ -40,30 +40,30 @@ We have a wooden and plastic design. We were wondering wich one is more easy to 1. which design is more likable - Sebas : plastic looks better and goes straight to the point. - Skip : plastic looks more clean. - Dano : plastic is more smooth. - Sietse : plastic is better. - Ishak : Wood is more ecofriendly. - Nailah : PLastic looks cooler + /Sebas : plastic looks better and goes straight to the point. + /Skip : plastic looks more clean. + /Dano : plastic is more smooth. + /Sietse : plastic is better. + /Ishak : Wood is more ecofriendly. + /Nailah : PLastic looks cooler 2. which design is more distracting. - Sebas : wood is more distracting and more obvious. - Skip : wood, because the school walls are more darker themed. - Dano : wood looks off. - Sietse : wood would be out of place. - Ishak : Wood, but in a good way. - Nailah : plastic looks more interesting. + /Sebas : wood is more distracting and more obvious. + /Skip : wood, because the school walls are more darker themed. + /Dano : wood looks off. + /Sietse : wood would be out of place. + /Ishak : Wood, but in a good way. + /Nailah : plastic looks more interesting. 3. Any further comments about the design? - Sebas : Don't do wood, plastic is more sleek. - Skip : plastic looks more professional. - Dano : no. - Sietse: no. - Ishak : in the wood you can burn in your logo. - Nailah : The wood can look better inside the school. + /Sebas : Don't do wood, plastic is more sleek. + /Skip : plastic looks more professional. + /Dano : no. + /Sietse: no. + /Ishak : in the wood you can burn in your logo. + /Nailah : The wood can look better inside the school. In conclusion, Even though the wood would atract more attention, the plastic looks better according to the students. So from this information we will continue to make plastic cases for the nodes. \ No newline at end of file From 91f24a6f42b478e8d1f7ad8f383888b72d291665 Mon Sep 17 00:00:00 2001 From: sietse jonker Date: Tue, 26 Mar 2024 19:42:29 +0100 Subject: [PATCH 8/8] Add getNodeInfoIndex route to Flask main.py --- server/Flask/main.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/server/Flask/main.py b/server/Flask/main.py index c8ff4ac..c185937 100644 --- a/server/Flask/main.py +++ b/server/Flask/main.py @@ -16,7 +16,11 @@ def updateDataIndex(): new_name = request.args.get('name', None) new_location = request.args.get('location', None) return updateData(node_id, new_name, new_location) - + +@app.route('/getNodeInfo') +def getNodeInfoIndex(): + macAdress = request.args.get('macAdress', None) + return getNodeInfo(macAdress) def updateData(node, name, location): mydb = loginDB() @@ -50,5 +54,16 @@ def getData(node, dataType, MAC): return result +def getNodeInfo(macAdress): + mydb = loginDB() + query = get_query(False, False, macAdress) + cursor = mydb.cursor(dictionary=True) # Enable dictionary output + cursor.execute(query) + result = cursor.fetchall() # Fetch the results + cursor.close() + mydb.close() + + return result + if __name__ == '__main__': app.run(debug=True, host='localhost')