Skip to content
Snippets Groups Projects
Commit 5e57076f authored by Christian Nordstrøm Rasmussen's avatar Christian Nordstrøm Rasmussen
Browse files

first commit

parent f3d10be2
Branches master
No related tags found
No related merge requests found
Milestone 1:
Building the docker image:
docker build --tag=humid .
Run build:
docker run -p 8080:8080 --privileged humid
Be aware:
We instantiate a socket in the public/readings.js file.
In order for the socket to work, you give the ip as parameter to the io.connect method.
You get the IP by using:
hostname -I
Then you are able to access the data through the browser on localhost:8080
Also be aware:
The buttons do nothing yet ¯\_(?)_/¯
____________________________________________________________________________________________
# IOT node.js project starting template
This repository includes a simple template for a node.js/express application,
......
......@@ -3,15 +3,41 @@
<head>
<meta charset="utf-8">
<title>Websockets 101</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"></script>
<style>
body {
background-color: #F0F3F5;
padding: 20px 20px;
}
.btn {
padding: 8px 12px;
color: white;
font-size: 16px;
font-weight: bold;
background-color: #f44336;
display: block;
margin: 10px 10px;
border: none;
}
#btn-red {
background-color: #f44336;
}
#btn-green {
background-color: #4caf50;
}
</style>
</head>
<body style="background-color: #F0F3F5; padding: 20px 20px">
<body>
<div>
<h1>RASPBERRY PI VALUES</h1>
<div id="output">
</div>
</div>
<button id="btn-red" class="btn" type="button">Red light</button>
<button id="btn-green" class="btn" type="button">Green light</button>
<script src="readings.js"></script>
</body>
......
......@@ -63,7 +63,6 @@ io.on('connect', function(io){
});
io.on('update', function(data){
console.log("called");
io.emit('update', {
temp: temp,
humidity: humidity,
......
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN)
prev_input = 0
try:
while True:
input = GPIO.input(4)
if((not prev_input) and input):
print("under pressure")
prev_input = input
time.sleep(0.10)
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment