The Tamagotchi P's can only connect to the following:
1. Pierce
2. Computer or Phone via IrDA
3. Tamagotchi P's
4. Tamagotchi iD L
5. Tamagotchi iD L 15th anniversary edition
6. Tamagotchi iD L Princess Spacy
7. Tamagotchi P's Station
The Tamagotchi iD can only connect to the following:
1. Tamagotchi Plus Color (TMGC+C)
2.Tamagotchi ID
3. Tamagotchi iD SPOT
4. Tamagotchi ID Conan
5. Tamagotchi Lovely Melody (Melody Crown)
6. Tamagotchi Lovely Melody (Lovely Music)
7. Computer or Phone via IrDA
8. Tamagotchi More ID! Home station (& Plus)
9. Tamagotchi iD L
10. Tamagotchi iD L 15th anniversary edition
11. Tamagotchi iD L Princess Spacy
As long as it isn't two generation away from each other, it should be able to connect. (This acts like the Other mode in Tamagotchi Connection, it is just that it can only connect to one generartion before, it can't connect to two generation before.
Also, since Tamagotchi P's uses IrDA it can't connect with the new 4U (Uses NFC, Near field communication) either.
Myiko is right. I have an Tamagotchi iD L and I can confirm this.