Photon Connection to Remote Server - Need basic Example

I am working on establishing a two-way communication link between a photon and node.js server. In a previous post here I established a connection between the photon, Particle Cloud and node.js server. Allowing the server to request variables from the Particle Cloud that were published by the Photon. However, now I would like to extend communication such that the photon can request data or send requests to the node.js server.

Recently I found a few documents touching on this subject, yet I can not seem to understand an example well enough to set up an example program [1, 2] . Additionally when I load the firmware via the Particle cloud IDE I have no idea where the Photon is outputting the comments from println.

Can someone please provide a basic example that will allow me to test a photon connecting a specific IP Adress and port number and then printing to the server console?

Hi! The Photon is printing the serial monitor. You can access this through the CLI using particle serial monitor or through Particle Dev which has a serial monitor in it. I’m not sure if that answers your question but you should at least be able to see what the output is!

Well one such approach is to implement a local Particle cloud, and then rekey the Photon to that private IP. Technically, that’s a node.js server that is directly communicating with your devices, with no intermediary.

But I’m sure you mean you want to get entirely rid of the Particle cloud infrastructure. In this case, check out the HTTPCLIENT library inside the Particle IDE. That should get you started in the right direction. It will load an example app that sends GET requests to a custom IP.

If you aren’t using HTTP requests, then you want a more generic TCP client. There’s a few libs for that last I checked.