Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Milestone 1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Nordstrøm Rasmussen
Milestone 1
Commits
5e57076f
Commit
5e57076f
authored
5 years ago
by
Christian Nordstrøm Rasmussen
Browse files
Options
Downloads
Patches
Plain Diff
first commit
parent
f3d10be2
Branches
master
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+20
-0
20 additions, 0 deletions
README.md
public/index.html
+28
-2
28 additions, 2 deletions
public/index.html
src/app.js
+0
-1
0 additions, 1 deletion
src/app.js
src/pressure.js
+18
-0
18 additions, 0 deletions
src/pressure.js
with
66 additions
and
3 deletions
README.md
+
20
−
0
View file @
5e57076f
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,
...
...
This diff is collapsed.
Click to expand it.
public/index.html
+
28
−
2
View file @
5e57076f
...
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
src/app.js
+
0
−
1
View file @
5e57076f
...
...
@@ -63,7 +63,6 @@ io.on('connect', function(io){
});
io
.
on
(
'
update
'
,
function
(
data
){
console
.
log
(
"
called
"
);
io
.
emit
(
'
update
'
,
{
temp
:
temp
,
humidity
:
humidity
,
...
...
This diff is collapsed.
Click to expand it.
src/pressure.js
0 → 100644
+
18
−
0
View file @
5e57076f
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment