Node.js on Raspberry Pi - node.js

I want to have Node.js running on a RPi and a browser running on the same RPI at the time and the two talking to each other. I know I can do this over a network with a separate client machine - but I want to control the RPi I/O pins with the browser running in the RPi. Is this possible?

I would recommend using the pi-gpio npm package on Node.js. Your browser then controls the GPIO pins thru Node.js.

Related

Raspberry Pi Local Network serving website with node and controlling analog ouput

I imagine the following setup:
A Raspberry Pi creates a local wifi network with a fixed ssid and pw
When connected to the network with any device and going to a set ip address, it opens a website served from the Raspberrys Node server. (Static would also be ok)
The served Website should be able to control Pin outs of the Raspberry, to control other circuits (GPIO).
What would be the right tech stack to do that and what hardware do I need?
Thanks!
This setup would work to drive the outputs of the Pi. You would need the Raspberry Pi, a Micro SD card (Assuming it is a modern Pi), A USB power plug and some way to connect the outputs. A few jumpers and a breadboard would do the trick but there are also breakout modules available,
You can then write your own software for the Pi or use something pre-made like, http://webiopi.trouch.com/

How to send data from Raspberry Pi Python Script to Android App

My senior project partner and I are trying to send data from a Raspberry Pi 4B to an Android Smartphone that is using Android Studio to make an app. The goal is to send multiple data readings from different sensors that are read in the python script in Raspberry Pi to an Android Smartphone. We have been having immense trouble with this and have looked off of many different posts to have nothing work. We have little to no experience with python and android studio. Any help would be appreciated.
Allow me to provide one possible solution. Since you are already using python in the raspberry pi to collect data from sensors, you could extend the script to relay that data to a HTTP REST api endpoint within the pi, using some HTTP microservice libraries like flask, bottle, etc. After this you need to open the communication between the raspberry pi and your phone which are connected via a USB cable. The simplest way of doing so would be to forward the port of your microservice using adb, like so
adb forward tcp:8080 tcp:8080
The above command needs to be run on the raspberry pi (after you setup up adb in it). The above command forwards the raspberry pi port 8080 to the android phones port 8080. Now the only thing you need to do is setup your app to periodically send HTTP requests to the local port 8080 and retrieve the information from raspberry pi. I do not have much experience with Android development so you have to research further on the viability of the app communicating with the forwarded port (permissions and security procedures to be bypassed), but this would be one of the simplest ways to setup communication involving an android device.

Enable both WiFi and Ethernet on Pi running Stretch

I'm working on a project where a Raspberry Pi 3 runs a python server which controls some arduino's that are connected to the same router via a switch. I'm using a websocket to display a GUI in my browser.I need to be able to use the gui over my primary network connection which has internet acces. The situation looks like this :
The problem is that I can't get both WiFi and Ethernet to work, just one at a time. This has mainly to do with running Stretch, but downgrading is not an option. On older Raspbian version's I could use the allow hotplug or auto setting in the interfaces file to make sure both interfaces are up. But I've heard you should not touch the interfaces file on Stretch. Can someone tell me how to do it ?:) Thanks a lot!

Connecting Smart Watch to Raspberry Pi

I am developing project on Raspberry Pi and I need to add feature of measuring heart rate. I want to use Smart Watch to do that but I do not know which smart watch provide environment which allows me to implement wireless communication between watch and Raspberry (Raspbian OS) easily. Thank you in advance for each answer.
I don't think any smart-watch allows direct connection between Raspberry Pi and smart-watch. It is not recommended on android developer site to open lower level sockets as well. You can send smart-watch's sensor data to Phone and then send it to Raspberry Pi.

How to run Node.js on esp8266 (Nodemcu dev board)?

I am trying to connect Apple homekit to nodemcu board, I found a tutorial which works on my computer, but I am wonder if there is any way to load and run Node.JS on a NodeMCU board (ESP8266)?
You can run Espruino on it. I have the HiLetgo NodeMCU ESP-12E Module and was easily able to load the firmware.
Download and install flasher https://github.com/thingsSDK/flasher.js
Press and hold the flash button press the reset button once. It will flash once.
Open up flasher app and flash the firmware for Espruino.
Unplug the esp8266 and plug it back in
download the web ide for Espruino https://chrome.google.com/webstore/detail/espruino-web-ide/bleoifhkdalbjfbobjackfdifdneehpo?hl=en
Change the baud rate Settings --> Communications --> Baud Rate 115200
Connect and enjoy!
Some samples to try out
https://github.com/mertenats/NodeMCU-and-JavaScript
I think you're confusing nodemcu, which is a firmware for the ESP8266 boards that interprets the language lua, with the javascript runtime node.js, which runs on computers.
So, the answer is you cannot run node.js on an ESP8266.

Resources