Porting the ethernet library from Arduino

Hi, I was wondering if anyone here had a solution for connecting a Particle Photon via ethernet rather than Wifi. Perhaps with an Adafruit breakout? Thanks, Sam

W5100 photon library. I was looking for this to use along with the arduino MUDBUS library for a modbusTCP bridge on the photon or electron eventually. i want to implement for the photon to publish data from legacy systems. is there a repository for it? i looked at your public stuff but did not find it…

@1bit, I partially completed the port for others to take and complete. I posted the code in my dropbox here if you are interested.

Thankyou, I got the folder and will have a look at it.

@1bit, when I ported the library it was meant to run as an independent user library with no integration with the Particle system firmware since it already has wifi/cellular network objects. As such, I had to rename all the “standard” network objects so they would not conflict with existing Particle objects. This was a “quick and dirty” approach to get something working without making major changes to the system firmware.

OK, And Thank you for the DIGOLE lib direction. I did buy maybe 8 of them to play with recently.

I have been poking around with this Ethernet issue for the better part of the day. (along with writing a bit of code for for a client.) and I think the ENC28J60 library will work more easily for this..issue ..GitHub - njh/EtherCard: EtherCard is an IPv4 driver for the ENC28J60 chip, compatible with Arduino IDE

Here is why:
the functions and classes were named differently already to coexist with most of the other Ethernet stuff. This would leverage that prior work. Also that board is very similar in function and pretty widely tested. Also it is very cheap. That library is pretty much gcc. I loaded all of the library stuff and it built fine in DEV along with the wire library and the Digole stuff and I also put in some other i2c and digital and analog components. That application compiled without complaint until I got into the PROGMEM bootloader and avr/io.h stuff. I also did port an example of one of my aps from MUDBUS to this library that I had bee using a while back. and that was easy.

UIP is another available one ..GitHub - ntruchsess/arduino_uip: UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernet

As far as internal protocols go...industrial internal hardwired (or modbus TCP , S7, or CIP ) and whatever is the most reliable /secure commerce protocol for the mobile gadget world..... i am focused on the still growing industrial ethernet segment. .I also did port an example of one of my aps from MUDBUSand SNAP7 to this library that I had bee using a while back.

I only liked the MUDBUS because of the way I can handle the register tables and because it has proven very robust.

If I understand some of the other posts you have made on this topic regarding hardwired Ethernet and router capabilities of the time

Thisi s a relaed thread.....

then this MODBUS library may be worth my time to look into as it was made for the the cc3000 stuff...

Also look at Snap7 for Siemens protocol support....this WILL move here easily. I use that one on several platforms. even wireless as it is cleverly a push/publish type protocol and really puts the smaller processor in charge of what it CAN do, well suited for a connection dependent link.

It may end up that I knit a Teensy 3.2 or 3.6 to a particle ELECTRON as a "CELL PHONE" exchange bridge to a secure, external, protocol for the mobile user. If I go that way I can keep the hard real time stuff in the Teensy and treat the particle as another buffered Ethernet port.

After playing with the photon for a couple of days only,,,,I get a feel for it. The ELECTRON might have its hands full with a protocol conversion anyway and buffering anyway. The database size would be small atmost
255 holding registers (int)
128 input registers (int)
255 coils (bool)
255 contacts (bool)

maybe 2K-5k depending on buffering.

I have got them on a Nano with smaller structures and still have room to do useful stuff the teensy will plug into a nano form factor.

I would like to understand what tools can prioritze tasks on the particle; mission critical may need to be on a different processor. I do have a lieweight shceduler I use for the arduino and every task is looked at and the ones who need I/O gt it... but HARD I/O does real things and should preempt connectivity.

I guess I would look at having the particle as a SPI device to a Teensey if I cant have a Hard port on the PARTICLE. This would not require a PI or that level of OS i dont think at this point but I will go back to the office in berkeley an talk about it with my colleagues. We did have a meeting on the topic yesterday for a few hours.

Thanks ...

1 Like

@1bit, did you end up porting and using the ethercard library for the ENC28J60 to use on the Photon? If so, any chance you can make the ported library available? :wink:

I took The idea that I wanted to send my small register database on demand over SPI to the particle. I am looking into the particle Electron as a paired up communications processor with a Teensy 3.2 or 3.6. Today I set up my Electron/Teensy testbed. If I run into trouble with that then I will go back to the porting route. I will however get some advice on the topic next week. That discussion may put me back on it.

I am playing with Teensyduino 1.31 beta#2 under arduino 1.6.12 . I am looking to put the electron on board optionally as a cell interface independent of the hard ethernet port…but I will look back at it…the library mostly was just having some macro work needed in the abscence of Arduino libraries. Let me look back at where I left it.

include i2c_t3.h is giving me some issues.

Hello @peekay123. I would like to take on the work you have done and try to finish it. My question would be, given that there is already a Ethernet Shield v2 will the port you have so far still work? Is the w5500 backwards compatible to the 5100? Or would I have to also port that as well. Seeing what you did with the 5100 it might not be difficult at all but doesn’t hurt to ask.

I would plan to make it work first as a user library rather than integrated to the firmware. Once it is working I would like work on it to add it to the firmware if it is useful.

New to the Photon particle and it would be my first port to it too, so guidance would be appreciated.

Thank you

@sensen88, part of the challenge with the original Ethernet Library was the conflict with the network objects in the library and the Particle firmware. Another member suggested using the ENC28J60 ethernet module instead. He found an Arduino library which was specifically designed not to conflict with other ethernet objects. I have ported the library but I haven’t tested it yet since I’m waiting on cheap module to arrive.

@peekay123, would "namespacing" the library help against that?

@ScruffR, not sure how that will work with the system firmware/HAL. Might be worth trying.

@peekay123 What did you do about the Stash in EtherCard.cpp??

I’ll burn a few of my Enc28J60 and invest a photon…if you need a guinea pig…this one should run at 3.3 V and plugs right into my utility boards…

@1bit, the RAM stash stays the same but I did my best to adapt the EEPROM code. Without an ENC28J60 and some testing, I can’t be sure it works.

I will have a couple of ENC28J60 boards in the near future and have photons to spare so I can join the testing process as well. If you can provide the code it would be great for testing. Though @1bit seems to have a better understanding of whats happening.

I have all the HW to test it…and some ready made testbeds…I do have applications for this.

1 Like

@1bit, do you need the ported library?

I would be glad to use it and provide discussion here for all to use. Does it have a home?

@1bit, I’m just porting a few of the examples. As for the stash, I am not yet confident whether it will work or not. Once you test the examples, I’ll port the stash test and you can try it then. Stay tuned.

1 Like

@peekay123

Hi all, we just started following this thread. We want to add an ethernet shield to particle electron so that we can communicate with a PV inverter over modbus tcp/ip. The particle then becomes a modbus master…

We want to use this modbus master library: http://myarduinoprojects.com/modbus.html

I’ve uploaded your zip file to github with the necessary manifest so that it can be uploaded in the particle IDE: https://github.com/alex254/ethernet

Peekay123 feel free to add your email to the manifest.

When I import it in particle IDE we are running in compilation errors. It seems that Client class is also still conflicting with an internal spark class.

Anybody have experience with Enc28J60 yet?

Alex