Photon to Ethernet Device Server?


#1

I have a Photon collecting data via its UART which is connected to a device that spits out status data every second.

I have a client who, wants to be able to access the data stored in variables on the Photon over a ethernet port on our product.

I’ve used a Ethernet adapter with a Arduino Uno before to provide a internet connection to the Uno and that worked just fine.

I have not ever used Ethernet to allow another device that connects to it to grab data from it.

I see there are a few ethernet options that can be used with the Photon but I need some guidance on how to set it up so other devices can pull data from the Photon.

Any advice on this is greatly appreciated.

Here are the Ethernet options I see avaliable.

image

@IOTrav


#2

Hi,

You’re going to want this one for Photon:

I have a library on Particle called NCD_Ethernet_Overlay. It’s just a port of WizNet’s W5500 Arduino library really. For your application you would probably want to create a TCP Server(See this example):
https://build.particle.io/libs/NCD_Ethernet_Overlay/1.0.0/tab/example/TCP_Server.ino

Other devices can connect to that server and request data from the Photon in that way.

Note this only works locally. It does not work through Particle’s cloud, but if the other devices are on the same LAN as the Photon/Ethernet Overlay then it should work for you. The WizNet W5500 chip this overlay uses supports up to 8 clients if memory serves me correctly so if you have several devices that need to connect you’ll want to make sure those devices connect, get their data, then close the socket.

If you have any other questions please let me know.


#3

Perfect! :slight_smile:

That’s perfect for this application.

I’m not using the Particle cloud and this will be a local connection only.

There will not be more than 8 clients either, probably only one.

I going to buy 6 of these for some demo units. If this works as needed then I’ll be back for 30 more.

Is the lowest profile setup using your breakouts with a Photon and Ethernet board pictured below?

I will be powering these from a 24v battery bank, not sure if you have any adapter boards that have 3.3/5v voltage converters on board that you would recommend or not. I can provide a external dc to dc converter if needed.


#4

I would say that I2C shield is probably the lowest profile solution for the setup but that would mean everything is powered from the USB connection on the Photon. If you want to power the boards from 24VDC then I would recommend the screw terminal breakout board here:
(Electron footprint): https://store.ncd.io/product/particle-electron-i2c-shield-screw-terminals-2-amp-power-supply/
(Photon footprint): https://store.ncd.io/product/screw-terminal-breakout-board-for-particle-photon-with-power-supply/


#5

I picked up 6 of the Ethernet Overlay Shield’s and the smaller bottom boards that allow me to put a Photon and this Ethernet adapter on the same shield.

I’ve never used the TCP Server code before but I have used an Arduino with a different WizNet W5500 ethernet breakout to allow an Arduino to push data over the internet.

Do you have any advice, links, or examples that you could point me to that would provide an example showing the code that would allow somebody to connect and then ask for data that is saved in variables stored on the Photon?

I’m going to keep looking for examples for this regarding the Wiz5500 module but wanted to ask since maybe you have this info in an easy to share format.

I’m going to need to buy 30-40 more of these once these are up and running correctly.

Any info is appreciated :wink:


#6

After searching the web for Arduino Ethernet WizNet 5500 code I came across this Send/Receive UDP Data example code that looks simple enough to use.

I have a customer who just needs to be able to connect to our product over a Ethernet Port and then be able to do one of the following:

  1. Receive data that I send out over the Ethernet port every few seconds.

  2. Send data in response to a data request over the Ethernet port.

To me this looks promising and simple enough to understand but I have never used it before.

https://www.arduino.cc/en/Tutorial/UDPSendReceiveString

Anybody else use this UDP + Ethernet in the past?


#7

Hi Ryan,

Sorry for the delay. Hollidays have been very busy.

The NCD Ethernet Overlay library which is really just a port of Wiznet’s library does allow for UDP socket connections for sending and receiving data:


That should do everything you have described. Take a look and let me know if you have any questions.

Thanks Ryan,
Travis


#8

I did try the DHCP - UDP Broadcast Message example and it did work just fine so I’m confirming this is good with the client also and if so then were good to go!

Thanks for replying!


#9

I am having trouble using your library.

  1. Using the client example, if the connection is interrupted, the shield senses that immediately but is NEVER able to reconnect.

  2. Library does not work with SDFat’s latest library. It prevents loop() from executing. Please refer to:

I would appreciate your help as I really like this shield.