Merge branch 'main' of gitlab.fdmci.hva.nl:propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59
This commit is contained in:
@@ -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
|
||||
```
|
||||
@@ -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: "));
|
||||
@@ -176,16 +184,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 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.
|
||||
if(digitalRead(button) == HIGH){
|
||||
|
@@ -33,4 +33,37 @@ 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.
|
||||
`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. 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. 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?
|
||||
|
||||
/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.
|
@@ -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')
|
||||
|
65
server/brams-script.py
Normal file
65
server/brams-script.py
Normal file
@@ -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())
|
||||
|
Reference in New Issue
Block a user