Local connection problem [Ethernet Shield]

First, I need to apologise for copy&paste this thread. I accidentaly write one first time in wrong forum division. [ Installation & Troubleshooting - I’m sorry for trouble. Topic shares the same title there. If it’s possible delete this thread. I don’t know how to do this :confused: ]

==========================================================
Hello! :frowning:

I have a big problem with my hardware. I don’t know if it works properly or if I configured something not properly. I guess I’m not doing something right. Anyway, let’s get to the point.
I want to connect my Arduino with the local website by using Ethernet Shield and make it work.

My hardware:
>Arduino Leonardo,
>Ethernet Shield W5100.

I connected my Arduino Leonardo with Ethernet Shield module and it works fine. I even programmed a LCD a bit and it worked.
I’m providing you with that information, because it was very hard for me to find any information if I could assembly Leonardo + Ethernet Shield together without any problem.

Going further I wanted to actually use Ethernet Shield to make a simple connection with Arduino to localhost // local website and see results on my laptop (and maybe control Arduino outputs later on).

The problem is… I can’t use;

more than 1x RJ45 wire,
router.

Then, my plan is using WiFi, Laptop and Ethernet+Arduino connected via RJ45:

WiFi (provided by Smartphone as Hotspot) —> Laptop —RJ45—> Ethernet Shield.
(My laptop has only 1x RJ45 socket by the way)

It doesn’t work. I used the method showed by this Sir:
Link, but it doesn’t work properly.

I used example sketches like:

DhcpAddressPrinter [Doesn’t print an IP in overall.]
WebServer [Was printing 0.0.0.0 (and it didn’t work) earlier, before I have used a preferred IP (Link method). Program WebServer started to print localIP (!= 0.0.0.0) quite fast, but when I tried to enter that website I got message from my browser: “CONNECTION REFUSED”].

I have no idea what is wrong. How can I enter local website to control my Arduino via program or some HTML, PHP stuff later on, If I cannot make a simple connection?

I have no idea how to repair it. I guess the problem lies in WiFi hotspot provided by Smartphone and not by portable router or something else…
Do you have any idea, please?

===============================================================
Also each time I compile those programs I get following warnings ONCE, but program still compiles. Is it a serious problem? Is it a reason it doesn’t work?
----------------------------------------------------------------------------------------------------------
In file included from C:\Users\X\Documents\Arduino\libraries\Ethernet\src\Dns.cpp:7:0:
C:\Users\X\Documents\Arduino\libraries\Ethernet\src\Dns.cpp: In member function ‘uint16_t DNSClient::BuildRequest(const char*)’:
C:\Users\X\Documents\Arduino\libraries\Ethernet\src\utility/util.h:4:24: warning: result of ‘(256 << 8)’ requires 18 bits to represent, but ‘int’ only has 16 bits [-Wshift-overflow=]
*#define htons(x) ( ((x)<< 8 & 0xFF00) | *

C:\Users\X\Documents\Arduino\libraries\Ethernet\src\Dns.cpp:185:21: note: in expansion of macro ‘htons’

  • twoByteBuffer = htons(QUERY_FLAG | OPCODE_STANDARD_QUERY | RECURSION_DESIRED_FLAG);*
  • ^~~~~*
    ----------------------------------------------------------------------------------------------------------
    I noticed on the preview that 8) emote shows up, instead of this emote there should be ‘8’)’ in that code.

===============================================================

I really want this to work. I’m looking forward for any help :frowning:

It doesn't work. I used the method showed by this Sir:
Link, but it doesn't work properly.

That link shows how to do that with a WiFi connection. Did you adapt the procedure to use the wired Ethernet instead?

I have no idea what is wrong. How can I enter local website to control my Arduino via program or some HTML, PHP stuff later on, If I cannot make a simple connection?

You have to configure the connected device to provide DHCP functionality or use fixed IPs on the network. As you don't want to use a router (you didn't provide a reason for this BTW), you have to adapt your PC to provide the same functioality the router usually offers.

pylon:
That link shows how to do that with a WiFi connection. Did you adapt the procedure to use the wired Ethernet instead?

I adapted to the first method this guy presents and then jumped to webserver method using Ethernet wire to connect Ethernet Shield with the laptop together.
Also laptop should have WiFi connection itself from the hotspot generated by smartphone, not by router.

pylon:
You have to configure the connected device to provide DHCP functionality or use fixed IPs on the network. As you don't want to use a router (you didn't provide a reason for this BTW), you have to adapt your PC to provide the same functioality the router usually offers.

Yeah, in my project I cannot use a router for few reasons (project demands it), that's why I need to go for a hotspot generated by smartphone.
I think I configured something wrong and now I can see it. Somehow hotspot from smartphone cannot be shared. I do not have a 'share' tab. You can see it on the picture below.


Funny part is... Ethernet Shield connected with laptop via Ethernet wire (RJ45) DOES have a "Share" tab...

It makes this project impossible to execute.
It should be reverted in my opinion;

  • Laptop can share Wi-Fi (hotspot) with Arduino and Arduino shouldn't be able to do this.

Meanwhile I have completely reverted situation:

  • Laptop cannot share Wi-Fi (hotspot) with Arduino and Arduino CAN share a connection... which... It doesn't even have... I'm confused.

I guess I will be forced to use router anyway :confused:

If you have any ideas how to fix this I would be grateful. Thank you.

It makes this project impossible to execute.
It should be reverted in my opinion;

  • Laptop can share Wi-Fi (hotspot) with Arduino and Arduino shouldn't be able to do this.

Meanwhile I have completely reverted situation:

  • Laptop cannot share Wi-Fi (hotspot) with Arduino and Arduino CAN share a connection... which... It doesn't even have... I'm confused.

I found an option to share my hotspot with my laptop in Windows 10 options. It actually REVERTED the share tab to be in WiFi connection in the right place where it was meant to be in my project in the beginning...

I will test devices again and let you know about progress soon.
I will try to configure it all in the right way this time - and hopefully it will start work.

Such small mistakes... And they make me look silly... I'm sorry.

Still nothing works.

IP I gain from hotspot is random generated and this tutorial says i need to choose one IP and then stick to it while connecting to the Arduino Webserver.

Preferred IP by laptop changes each time I connect to the hotspot and when I change it in Webserver program and compile it - i can’t still connect to the webserver as browser says:

CONNECTION_REFUSED.

What exactly are you trying to achieve?

I got the impression that you want to connect the Arduino to the internet by the way of your laptop and your phone.

But in your first post you wrote you want to connect your Arduino to your local website, so it doesn't need any Internet connectivity.

Yes, I admit I'm not quite good at explaining things really clearly.

In few words:

I want my Arduino to hold local webserver and print PHP / HTML code written inside of the code.

I want my Arduino to hold local webserver and print PHP / HTML code written inside of the code.

For that you don't need an internet connection. So you want to serve HTML pages from your Arduino. To make this easy available you have to set a fixed IP address on your Arduino so you can enter that IP on the Laptop to access the web pages.

Yeah, I made it.
Thank you my friend.
It should let me work for now for a certain amount of time.

I will leave that part of knowledge I got from You here. It allowed me to do local webserver without doing weird stuff with changing values of internet sharing options and more cringe stuff I would never understand...

The problem will begin later with making real connection to the internet, but I really think Router is needed for that in the long run and there is no way to do this without it.

I guess it is going to be a separate thread for this problem.

Additional notes for compile warnings:
I've discovered it happens only once per compile attempt, but does not damage the program's work itself. After 1st compilation attempt these messages do NOT show again unless you connect your Arduino with your PC/Laptop once again via USB cable.

Thank you @pylon for your help.