Teensy 4.1 IP Address

Status
Not open for further replies.

Mr.Kara

Member
Hi

I am transmitting data wirelessly with the help of AP/Client by Teensy 4.1. My Accesspoint/Client is communicate with Teensy 4.1 thru Ethernet. I am trying to assign IP address for 4.1, but It didn't work. I am attaching the source code here for the reference.View attachment Accesspoint.ino
 
Before talking of the IP number configuration, let's confirm which ethernet hardware you are really using and whether you're using the correct library. Your program includes Ethernet.h, which is meant to be used with Wiz850io and this adaptor board.

If you are actually using the Ethernet Kit for Teensy 4.1, then Ethernet.h is the wrong library. Instead you need NativeEthernet.h.

Before adding the extra complexity of a wireless access point, I would highly recommend connecting to a normal ethernet LAN and get the example program working.

The code you've shown manually configures Teensy IP number to 192.168.1.177. You didn't configure a netmask or gateway address, so the library will choose defaults. You're trying to communicate with 1.1.1.1, which is Cloudflare's DNS service, which is not on the local network. For this to work, your LAN must have an internet-connected router with internal IP number 192.168.1.1 (the default gateway just replaces the last number of your IP with 1). But even then, it will not work unless Cloudflare's server actually listens for incoming connections on port 10002. I tried connecting just now from my PC and it seems their DNS server doesn't listen to that port (and there is no reason it would), so even if your network settings are perfect, this still can't work until you get the destination IP and port numbers correct.

But the very first step is to check whether you are using the correct library for the hardware you have, and then the 2nd step is to test with one of the known-good examples (like WebClient) on a non-wireless link, so you know your hardware is working correctly. And before adding the wireless link, get a program actually working with whatever remote site you will access and test it with a wired LAN connection first, so you know it works. You must configure Teensy's IP number, netmask and gateway to numbers which work on your local network (LAN). Normally automatic config by DHCP is used, because manual config is tedious and error-prone. For manual config to work, you must get those numbers correct for the settings your LAN uses. Even if the hardware and library and network settings are correct, you can't just imagine an IP number and port and expect that some random server somewhere on the internet will necessarily respond. You have to use the address and port of a server or other computer which will actually talk to you.
 
I just ported an app from a DUE/Ethernet shield combo to the Teensy 4.1. Except for me causing my own problems by putting a lib in the wrong place, the port went extremely smoothly. The NativeEthernet lib worked perfectly without any changes to my program except for the include statement. Thanks for the quality code Paul, I really appreciate it! I am a hobbyist, not an Engineer, so I a really at the mercy of the quality of the libraries.
Thanks,
Len
 
Thanks, Paul, I will let him know. "All I did was make the hardware..." Nice bit of HW! Built in Ethernet, smaller, WAAAAY faster and cheaper than the Arduino DUE. Kind of says it all...
 
Status
Not open for further replies.
Back
Top