Websockets using Particle Electron?

Hi, I’m having a hard time trying to figure out if I can use WebSockets with the electron over lte. Can anyone point me in the right direction? A tutorial or walkthrough would be great, I have googled myself a headache looking for this.

Do you mean can the Electron connect to a web server and exchange raw data with it by entering websockets mode? The answer is theoretically yes, however I don’t believe there is a library that currently does it.

If you mean, can the Electron be a web server that allows a client on the Internet to connect to it in websockets mode, the answer is no, because the cellular modem does not support TCP server mode and can’t be a server. Also, the cellular provider does not allow incoming connections, and the Electron/E Series/Boron don’t get a unique IP address assigned. They’re behind NAT.

Hey Rick, thanks for the reply. I was hoping to have the server send the particle an sms message indicating an event, then having the device connect to the server via websockets for live data transfer.

That is theoretically possible. Note, however, that you need to use a 3rd-party SIM card as the Particle SIM does not support sending or receiving SMS.

Also note that the maximum data rate is around 2K to 3Kbytes/second even over 3G, so there is a limit to the kinds of data you can stream live.

I didn’t realize that they had a limitation on sms. What options do I have to send data to a specific particle?

Do you need to connect to the device directly? Can you use the cloud features such as Publish/Subscribe and Particle.function()?

Use the cloud with Particle.publish() and Particle.subscribe. It would be pretty easy to script something to even just use the particle-cli to publish events for your Electron to subscribe to. And if you really want SMS, you could look into Twilio. For quick-and-dirty, you could just paste things together with IFTTT, though I’m not sure if the response time would be satisfactory.

2 Likes

You know, I’ve been playing with this thing for a while now and I’ve never noticed the subscribe function. Sounds like it will do the job. I can just publish the data in bulk every minute or so I guess.