1

Is this possible? Basically I want to read sensor data from the raspberry pi and send to (Via wifi) a Node server I am running, the data will be displayed on a webpage ran by Node (using JS/etc... to display the data)

is this even possible? I've been looking around and most stuff seems to be about the R-Pi running Node itself, however thats not what I want to do.

Perhaps this is something better served to have the Pi Capture data AND host the server? Although im honestly looking for the former option.

Thanks!

  • "is this even possible?" Why would it not be? The pi is just a normal computer in this sense. If you wanted to send information to a web server from another computer (without engaging it manually through a browser), how would you do it? That's essentially the question you are asking. – goldilocks Jun 16 '16 at 4:18
1

With the Raspberry Pi being a Linux based computer, you can most certainly use its sensors to accumulate data and then transmit that data to a remote computer. You have many choices available to you in achieving the network connection. Some of these include:

  • Web Socket - Your Node.JS app listens on a Web Socket and the Pi forms a Web Socket connection to the Node.JS app and sends data.

  • MQTT - Your Node.JS app is a subscriber to an MQTT topic and the Pi publishes on MQTT. The MQTT broker can exist either on the PI or on your Node.JS server machine.

  • REST Requests - Your Node.JS app can listen on incoming HTTP requests and the Pi can transmit REST requests to the Node.JS endpoint.

  • Raw sockets - Your Node.JS app can use raw TCP/IP or UDP/IP sockets and receive sockets requests from the Pi.

  • Shared file systems - Your machine running Node.JS can either export part of its file system or the Pi can export part of its file system and have the partner mount that file system for access. The Pi could write to the file system and the Node.JS app could read from it.

As for data formats, the content can be anything you desire. I'd probably suggest staying away from binary data unless the volume is extremely high. If you are using Node.JS, then JavaScript objects are probably in your future and JSON becomes a good data content potential.

REST requests are probably going to be easiest, Web Sockets probably the least network overhead and MQTT if the network was unreliable and you needed to buffer the data.

Your choice of technology will probably be influenced by your choice of implementation language at the Pi end. From what you have said, I'd be tempted to suggest running Node.JS on both the Pi and the PC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.