2023-07-20 12:16 PM
Hello everyone,
It is a quite basic question, I have this stm32767zi nucleo board with a LAN driver and rj45 connector, and I intend to test the basic ping/web server examples.So for now, I do not have a router with me, so I was wondering, if I could use my laptop as a router itself , if it is connected to the WiFi and connect my board to laptop using an Ethernet cable.
Solved! Go to Solution.
2023-07-20 10:23 PM - edited 2023-07-20 10:39 PM
I'm not sure if I understand correctly...
If you just ask: can I connect Nucleo to laptop via ethernet jack and check the Nucleo's webserver?
Then the answer is: yes!
I recently did that while travelling on a train
But you either need some PC app to run it as a DHCP server, or you have to give the Nucleo a static IP address, with most parts matching that of your PC's.
subnet mask and gateway must be identical, IP4 address itself has to match the first 3 (or 2?) bytes.
Example:
laptop's address (find out via cmd / ipconfig)
IP4 address: 169.254.111.7
SubNet: 255.255.0.0
GateWay: 169.254.111.1
then your Nucleo's address should be set to:
IP4 address: 169.254.111.x
SubNet: 255.255.0.0
GateWay: 169.254.111.1
with x any 8 bit value except the laptop's (7 here)
I just tested that (but with a USB-ethernet bridge adapter with a Microchip LAN9512), it's working here.
Edit:
It will probably 169.254.x.y
wikipedia says:
169.254.0.0/16 | 169.254.0.0–169.254.255.255 | 65536 | Subnet | Used for link-local addresses[10] between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server. |
2023-07-20 02:30 PM - edited 2023-07-20 02:32 PM
You can't plug in the board and expect the board to show up as a device on the network via your laptop.
You can communicate directly with the laptop via an ethernet cable, but setup is a bit of a mess.
A WiFi to ethernet adapter can provide the setup you want.
2023-07-20 05:17 PM
Thank you for the response and time, But is it possible to run a web server using fixed.static ip addresses?
2023-07-20 06:47 PM
Possible, yes, but not very practical to run a web server from a microcontroller due to the low onboard memory and relatively slow processing speed. A raspberry Pi or similar would be much better suited and much easier to put together.
2023-07-20 07:50 PM
Thank you again, I do understand the code constraints on this design of writing a web server in a uC.So all I have to do is run the webserver/html page on raspberry pi and communicate to the IP of raspberry pi using the wifi to ethernet adapter from my board(IP of the uC board). Please feel to correct me, if I am wrong.
2023-07-20 10:23 PM - edited 2023-07-20 10:39 PM
I'm not sure if I understand correctly...
If you just ask: can I connect Nucleo to laptop via ethernet jack and check the Nucleo's webserver?
Then the answer is: yes!
I recently did that while travelling on a train
But you either need some PC app to run it as a DHCP server, or you have to give the Nucleo a static IP address, with most parts matching that of your PC's.
subnet mask and gateway must be identical, IP4 address itself has to match the first 3 (or 2?) bytes.
Example:
laptop's address (find out via cmd / ipconfig)
IP4 address: 169.254.111.7
SubNet: 255.255.0.0
GateWay: 169.254.111.1
then your Nucleo's address should be set to:
IP4 address: 169.254.111.x
SubNet: 255.255.0.0
GateWay: 169.254.111.1
with x any 8 bit value except the laptop's (7 here)
I just tested that (but with a USB-ethernet bridge adapter with a Microchip LAN9512), it's working here.
Edit:
It will probably 169.254.x.y
wikipedia says:
169.254.0.0/16 | 169.254.0.0–169.254.255.255 | 65536 | Subnet | Used for link-local addresses[10] between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server. |
2023-07-23 07:17 AM - edited 2023-08-01 02:13 PM
Possible, yes, but not very practical to run a web server from a microcontroller due to the low onboard memory and relatively slow processing speed.
You shouldn't always assume the author is trying to make a server for YouTube. There are countless examples for which the resources on STM32 MCUs are not only sufficient, but plentiful. I am serving a non-trivial web-page with HTML, CSS, JavaScript, AJAX and the related services on MCU side running as a charm and it takes just a few tens of KB of FLASH memory. I am running it on F7, but it could run even on F1 with 128 KB of FLASH.
@LCE , in addition to static configuration link-local addresses can also be assigned by AutoIP.
But is it possible to run a web server using fixed.static ip addresses?
The web server doesn't care who assigned the IP address.
I do not have a router with me
As LCE already said, there is no need for a router and there is no even need for a switch.
The real problem is this:
2023-07-30 09:34 PM
Thank you so much for the detailed response and references.I really appreciate the insights.
2023-07-30 09:35 PM
Thank you for your time and efforts to answer my queries, I really appreciate it.
2023-07-30 10:54 PM
Actually try what @Piranha told us about, it's called AutoIP in lwIP, activated by the #define LWIP_AUTOIP 1 in opt.h.
I didn't know about that, I'm still an ethernet beginner, but included AutoIP last week.
It's working great!
So now my application starts with DHCP, when that times out it starts AutoIP, if that fails it uses a static IP.
Thanks @Piranha !