Ethernet shield with XAMPP database (no router)

I’m trying to create a project in which my arduino must upload sensor readings into a database. I decided to use Xampp for this project and for the past week I’ve been struggling to establish a connection with my arduino using an Ethernet shield. Thing is the shield should be used with a router but I do not own one, I use a hotspot wifi for all of my needs. I’ve been trying to make the connection using my own PC as the local host, but to no avail. I’m simply wondering if it’s actually possible to establish a connection to the database using my PC without the need of a router.

Do keep in mind I’m fairly new to this topic so I may be missing critical steps for this to work.

side note:
I used the “DhcpAddressPrinter” script for obtaining my Ethernet ip, it used to work before but now it won’t work and simply prints “Failed to configure Ethernet using DHCP”. I’ve kept the ip it used to give me before in my project as the ip for the shield.

my ethernet shield module is a W5100 in case if that’s needed

This the code for my proyect:

/*Radio Libraries*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*Radio variables*/
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";

/*Ethernet libraries*/
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address
byte server[] = { 192, 168, 43, 13 };
//IPAddress ip( 192, 168, 137, 2 );
//IPAddress ip( 192, 168, 137, 166 );
IPAddress ip( 192, 168, 137, 177 ); 
EthernetClient client; 

int Temperature = 100;
int Humidity = 20;
int AirP;
int CarbonM;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();

  Ethernet.begin(mac, ip);
}


void loop() {
  if (radio.available()) 
  {
    int text;
    radio.read(&text, sizeof(text));
    Serial.println(text);
  } 
  Sending_To_phpmyadmindatabase(); 
  Temperature++;
  Humidity++;
  delay(5000);
}

  void Sending_To_phpmyadmindatabase()   //CONNECTING WITH MYSQL
 {
   if (client.connect(server, 8080)) {
    Serial.println("connected");
    // Make a HTTP request:
    Serial.print("GET /PHPArduinoscript/ArduinoDB.php?Humidity=");
    client.print("GET /PHPArduinoscript/ArduinoDB.php?Humidity=");     //YOUR URL
    Serial.println(Humidity);
    client.print(Humidity);
    client.print("&Temperature=");
    Serial.println("&Temperature=");
    client.print(Temperature);
    Serial.println(Temperature);
    client.print(" ");      //SPACE BEFORE HTTP/1.1
    client.print("HTTP/1.1");
    client.println();
    client.println("Host: 192.168.43.13");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
 }

Why is your network address different between you arduino and your PC?
server = { 192, 168, 43, 13 }
IPAddress ip( 192, 168, 137, 177 );

Typically, the first 3 bytes would be the same, only the last byte would differ.

I’m not sure, that’s just how it’s configured when checking the IPs in the CMD. I’ve already tried manually changing the Ethernet’s IPV4 similar to the PC on “Network sharing center” and it still didn’t solve the problem.

The fact that I’m using a hotspot wifi may be contributing to that, but it shouldn’t really be that related since the server I’m hosting is being locally hosted in the PC not through the internet.

I’m trying to create a project in which my Arduino must upload sensor readings into a database. I decided to use Xampp for this project and for the past week I’ve been struggling to establish a connection with my Arduino using an Ethernet shield. Thing is the shield should be used with a router but I do not have one at the moment, I use a hotspot WiFi for all of my needs. I’ve been trying to make the connection using my own PC as the local host, but to no avail. I’m simply wondering if it’s actually possible to establish a connection to the database using my PC without the need of a router.

Do keep in mind I’m fairly new to this topic so I may be missing critical steps for this to work.

side note:
I used the “DhcpAddressPrinter” example script for obtaining my Ethernet IP, it used to work before but now it won’t work and simply prints “Failed to configure Ethernet using DHCP”. I’ve used DHCP server for windows application and it did fix the script’s issue, but it still did not fix my connection to Xampp’s database.

I also tried using “TelnetClient” example script to see if it could establish a simple port connection using Hercules application, but this also did not work.

my Ethernet shield module is a W5100 in case if that’s needed

This the code for my proyect:

/*Radio Libraries*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

/*Radio variables*/
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";

/*Ethernet libraries*/
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //Setting MAC Address
byte server[] = { 192, 168, 43, 13 };
//IPAddress ip( 192, 168, 137, 177 );
IPAddress ip( 192, 168, 137, 3 ); 
EthernetClient client; 

int Temperature = 100;
int Humidity = 20;
int AirP;
int CarbonM;

void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();

  Ethernet.begin(mac, ip);
}


void loop() {
  if (radio.available()) 
  {
    int text;
    radio.read(&text, sizeof(text));
    Serial.println(text);
  } 
  Sending_To_phpmyadmindatabase(); 
  Temperature++;
  Humidity++;
  delay(5000);
}

  void Sending_To_phpmyadmindatabase()   //CONNECTING WITH MYSQL
 {
   if (client.connect(server, 8080)) {
    Serial.println("connected");
    // Make a HTTP request:
    Serial.print("GET /PHPArduinoscript/ArduinoDB.php?Humidity=");
    client.print("GET /PHPArduinoscript/ArduinoDB.php?Humidity=");     //YOUR URL
    Serial.println(Humidity);
    client.print(Humidity);
    client.print("&Temperature=");
    Serial.println("&Temperature=");
    client.print(Temperature);
    Serial.println(Temperature);
    client.print(" ");      //SPACE BEFORE HTTP/1.1
    client.print("HTTP/1.1");
    client.println();
    client.println("Host: 192.168.43.13");
    client.println("Connection: close");
    client.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
 }

I believe you'll need to get yourself a crossover cable: Ethernet crossover cable - Wikipedia

byte server = { 192, 168, 43, 13 };
IPAddress ip( 192, 168, 137, 3 );

try again with the same octet

don’t hardcode the HOST IP in your request, use your variables (which might be const also!).

client.println(“Host: 192.168.43.13”);

I've already tried using the same octects but that as well didn't fix the problem. I may have to get one those crossover cables and see if that fixes the problem. I do have an old router laying around which I can test for simply creating a LAN network, but alas I'm also missing a second ethernet cable to test this.

Will be getting both if not one of the two missing components today and see if I can finally make progress with this project.

@d0ntk

TOPIC MERGED.

Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum.