This is a boilerplate to create Node.js IoT system with Arduino and Socket.io I have been using this system for most of my network controlled hardware project.
The system is divided to of 3 parts.
- Web server (hosts controller website & socket.io connections)
server.js
- Controller website
views/controller.html
- Arduino Client
client.js
For sample, I've included small code to turn LED on and off from website, & receive message on webserver when button is pressed.
- Set up your hard ware as below
- From your computer (or on your server) start a server
node server.js
- From your computer connected to Arduino via USB, start Arduino client
node client.js
- Open
localhost:5030
in your browser to see controller site
note: if you are running server.js
and client.js
from different computer (i.e server.js
on hosting service & client.js
on your Raspberry Pi) You'll need to change socket.io address in client.js
and views/controller.html
- For hardware setup, I recommend browsing Johnny-five doc and edit
client.js
- You can add as many socket message as you like and customize your controller website by editing
server.js
andviews/controller.html
.