nodejs IoT device to device communication - node.js

so im working on a my bachelor thesis and for that i need to implement, in a smarthome, d2d communication between IoT devices. So i want to implement the usuall server work, like noticing if a device connects/ disconnects etc. to the IoT devices, so no server/hub is needed at home.
But I can't find good solutions for it, for websockets i need a server, for mqtt a broker and so on, but all need a server.
I found that d2d is done with "LTE" similar technology but i would like to do it with web-protocols.
So my question:
Is there a way to let IoT devices talk to each other over the network?
My IoT devices (raspberry pis) currently use nodejs with typescript but I'm not starting a server, they only have a mqtt connection to publish there sensor data to the users.
Thanks in advance.
And if im understanding something wrong, please say it. :)

Related

Send REST API requests through Azure IoT Hub to a Raspberry Pi webserver

I'll start off by apologizing if this has been asked and answered, but I've been researching this for a few days and either I'm not understanding what I'm reading or I'm trying to do something unique or not possible(guessing it's the former).
Currently what I have is a Raspberry Pi that has a webserver running and a web UI for controlling what's connected to it. It has a slew of REST API's that can be accessed to perform various tasks. I have a couple of these setup with static IP addresses and all works great. My problem is scale. The potential exists to have hundreds(to thousands) of these running and need to be controlled by a single mobile app. I don't want to have thousands of static IP's. Though this would be the easiest solution it certainly wouldn't be cost effective and most likely a nightmare to manage.
My desire is to "connect" all of these Raspberry Pi webservers to the Azure IoT hub. The webservers do not need to talk to each other, but the mobile app needs to be able to send REST messages to each server individually.
The coding of the app, the coding on the Pi's and any additional coding is not an issue. I've been an applications developer for over 20 years so coding is not an issue.
So, my questions are:
What is the minimum necessary to be running on the Pi to connect to the Azure IoT Hub?
Do I understand correctly that to do what I've described above, I have to send a message to the Hub and then the Hub sends a message to the device?
Does anything exist to define the Pi as an endpoint and just be able to send the REST messages directly to that?
Any help provided, even links to relevant documents, would be greatly appreciated. Thank you!
Have you checked the official documentation? It contains an example of what you're trying to achieve (send data from device to iot hub / send command from iot hub to device)
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-csharp-csharp-c2d
All you need is the connection string to the Azure IOT Hub. To register your device, please visit: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-sdks

Can I connect via Bluetooth(or USB) to a device sitting locally at my desk from the App running on Test-Cloud?

I work with POS devices. We have a cross-platform mobile Xamarin App which talks to POS devices using Bluetooth or USB.It would be a great help if you can do that.
No you cannot, unfortunately the only way to interact with any device needed by the mobile client is through web requests. Unfortunately this is limited because no 1 BLE solution would work for everyone (actually it would only work for very few).
Another challenge is that the automated UI tests will run in the order determined by Xamarin Test Cloud and you may potentially have multiple devices interacting with your one device.
You could do this all locally though on your own device. You would just trigger the UITest locally through the command line and have the BLE device by your phone. I know this isn't ideal, but really one of your best options here.
The other option you have is creating a middle-man for your POS devices. Basically the middleman would be a REST API hosted on some IoT device that contains BLE integration. You would than have to forward the BLE requests from the IoT device to your POS device, but this solution would require larger time frames for the data to transfer and wouldn't necessarily be a "real-world" testing scenario. I would expect that you would have some false failure tests due to the details with creating this solution. I have done something similar for Particle, but I was only able to run UI Tests on 1 device at a time.
Disclosure: I work for Xamarin/Microsoft.

Device to device communication in Windows 10 IoT Core

What technologies are recommended when we want to do Device-to-device communication in an IoT Scenario? Does Windows 10 IoT Core have support for this type of communication? Could I use AMQP connections for this?
Device to device communication can happen on multiple levels. Setting up an AMQP server might be feasible using implementations like Apache QPid but this doesn't seem like a responsibility device should be bothered with. You could run an API server on a W10 IoT Core device for other devices to communicate with.
There are specific standards like AllJoyn that lets us communicate device with eachother and Windows IoT Core has native support for this. Take at look at the samples to find out if this fits your scenario: https://developer.microsoft.com/en-us/windows/iot/win10/samples/alljoynjs

Connecting Android device sensors with NodeRED

I am new bee to NodeRED. I refer tutorial on NodeRED connecting devices such as raspberry PI. The partial documentation on NodeRED Website is available that states that how developers can reads sensors connected to GPIO pins on Raspberry PI.
Similar way, I would like to know - how can I read sensors (e.g., proximity sensors, GPS, Accelerometer) on Android device with NodeRED? More specifically, I would like to play with Android device sensors with NodeRED? I have tried to google documentations related to it, but did not find it.
You will need to write an Android app to expose the sensors in a way that can be ingested into Node-RED, I would suggest publishing the values to a MQTT broker.
Node-RED can then subscribe to the topics and process the sensor values.
write an android app, that will expose the android sensor.
either push the data from Android to MQTT server (best choice) or use a microservice like AWS lamda or Firebase .
if used pub-sub with MQTT call it on Node-red, or call Lamda function Api endpoint on node-red or call the firebase directly on Node-red,
choose wisely according to your requirements.

Realtime Bi-direction Socket

I have an Arduino loaded with sensors connected to a Raspberry Pi. The Arduino passes all the data from the sensors to Raspberry.
Now I want to push all of these data in real-time over a socket to a server in the backend, and upload the data into a database.
I'm looking for the most optimal solution for this. Socket.io seems like a popular solution and relies on WebSockets and NodeJS.
Pusher seems like a decent API service that can easily integrate into iOS and Android devices.
What is the best solution out here? It seems like WebSocket is the way to go, but is there a better protocol to use for this purpose?
Check out the MQTT protocol as well. It's becoming widely used for this kind of purpose. You can find both open-source and commercial, as well as cloud-based and self-hosted, MQTT brokers.

Resources