I would like to add Ethernet to a existing project that uses a UNO. I have a Xbee connected to it using AltSoftSerial so that I can leave the on board serial port open for debugging and I don't run into the problems of downloading a sketch to the Xbee if I forget the switch, which I will.
The problem is AltSoftSerial uses Pins, 8, 9 & 10, the same pins the Ethernet shield uses. Are there any other options out there, I2C, SPI or whatever, to connect the UNO to the Ethernet?
AltSoftSerial uses pin 8 and 9 and ... there is no PWM on pin 10. But pin 10 is not used, it is available as a normal digital pin. I don't see any conflict.
The only problem I see is that you will run out of memory very quick with an Arduino and Ethernet Shield and XBee and AltSoftSerial. Do you use more libraries or sensors ?
I believe PWM pins are 3,5,6,9,10,11 on the 328P cards. Which has nothing to do with the original question.
SPI for ethernet uses 10,11,12,13. You should be okay. Except for maybe running out of memory.
Thanks for the feedback. When I set up the AltSoftSerial it did mention that pin 10 is not used directly, it is listed as "Unusable". I went on the site that explained more about using it and this is what it says:
"The "Unusable PWM" pins can be used normally, with digitalRead() or digitalWrite(), but their PWM function controlled by analogWrite() will not work properly, because AltSoftSerial uses the timer which controls that pin's PWM feature."
So would that interfere with how SPI works? I'm not that familiar with what each pin does with SPI?
Plus where would I get the SPI Ethernet shield? I've been looking for something like that and haven't found it.
Stumpy_L:
So would that interfere with how SPI works? I'm not that familiar with what each pin does with SPI?
No, that shouldn't interfere. Pin 10 is the CS pin for the Ethernet shield so there's no PWM needed.
Stumpy_L:
Plus where would I get the SPI Ethernet shield? I've been looking for something like that and haven't found it.
Unfortunately the official Ethernet Shield 2 is sold out in the Arduino store. You might find it in stock with one of Arduino's distributors. Sparkfun and Adafruit both make unofficial Ethernet shields. You can also get cheap Chinese shields on eBay, Aliexpress, and all the other usual places. All Ethernet shields are SPI. I recommend that you only buy the shields that use the W5100 or w5500 Ethernet controller chip. Don't buy the one with the ENC28j60, even though it's maybe a little cheaper. If you get the W5500 be aware that it requires a different library than the standard Arduino Ethernet library but that's really no problem. You can install a compatible library easily via Library Manager.
PWM has nothing to do with SPI. They are totally different and are independent.
When PWM is not possible with pin 10, you can use pin 10 with SPI and with digitalWrite(), anything, just not PWM.
Although I've started using Mega's on new projects this will keep me from redoing one that I already have together and just need an Ethernet interface on it. It's not a overly complex project so I don't think memory will be a problem, I didn't think of that but will keep an I on it.
Koepel, cool picture reference for the UNO, that will come in handy.
As always great feedback and answers from this forum