I would like that my website communicate with my Arduino uno WiFi Rev2

Good morning everyone,

I've created a simple website with the URL htpp://192.168.x.x. (the website is in progress). Also, I have an Arduino WiFi Rev2 and would like to exchange the temperature sensors from my Arduino WiFi Rev2 to my website.
Please, help me process this project. I already know how to interact with my Arduino Uno WiFi Rev2 board with a local network by using this link provided by Arduino.cc:
https://docs.arduino.cc/tutorials/uno-wifi-rev2/uno-wifi-r2-web-server-ap-mode/

Please, let me know what I can do to process this project. If someone has a free website for interacting with my Arduino Wifi rev2, it will be a great help!

Thank you.

Aristide KUDA

You can encode sensor values in an HTTP GET request or send values in an HTTP POST request, maybe even use web sockets. I tried to find a good tutorial but failed. See Send Sensor Data Remotely Over WiFi - #4 by wildbill

1 Like

Have you looked at the Arduino Cloud?

1 Like

Do you want the Arduino R4 to be able to submit temperature from time to time to the web server or do you want the web server to reach out to the Arduino to grab the temperature when needed?

Hi,

I want the web client to reach out to the Arduino WiFi Rev2 to grab the temperature.

Thnaks.

Hi,

I didn't. Is there any solution there?

Thanks

The web client is a browser, so if the above is correct you will need to implement a web server on the Arduino.

However, your opening post seems to indicate you have a website and want to display data from the Arduino on that website. In that case you will need to implement a web client on the Arduino; see post #2 by @Dave_Lowther.

Which web client ??

Perhaps you could draw us a block diagram showing what you want to happen?
This is an example, but it's not based on your project, it's just an example of the kind of block diagram that would be helpful. This was done in power point, but a photo of a hand drawing would be okay.

Hi Dave,
Here are some information about my project.

Thank you,
Aristide

Hi Dave, Hi everyone,
Here are some important point of my project.

Web server using Access point with Arduino WiFi Rev2

  1. Objective:
    The purpose of the project is to control and monitor wirelessly the temperature inside the Arduino Uno WiFi rev2. We use the functionalities of WiFiNINA as a local area network and
    We are not connected to internet (we don’t need to). I use:
    WiFiNINA library
    A sensor to grab temperature
    An Arduino Uno WiFi Board

  2. Functionalities of system:
    I use the access point of my Android phone (Network name and Password).
    Here is the link of the code that I used: https://docs.arduino.cc/tutorials/uno-wifi-rev2/uno-wifi-r2-web-server-ap-mode/

As you can see in the code, the WiFi local IP address is send directly to the Arduino Serial Monitor.
// print your WiFi shield's IP address:
134 IPAddress ip = WiFi.localIP();
135 Serial.print("IP Address: ");
136 Serial.println(ip);

After that, I write the IP address inside a web browser of my phone and I am able
To see the value of temperature.

  1. The way I need:
    I would like to receive the WiFi local IP address directly to a web browser inside my phone, not more in Arduino Serial Monitor, if it’s possible. That's the main issue that I need to resolve.

Architecture:
image

Thank you.
Aristide

I can't think of a way to do that at the moment. I can only think of a partial solution where you write your own app to run on the phone. Perhaps that app would listen using UDP and your Arduino would broadcast its IP address using UDP. The app on the phone would then display the IP of the Arduino.

this is unclear

can you clarify if your Arduino WiFi Rev2 actually joins the WiFi network created by your Android phone or if the Arduino WiFi Rev2 actually creates its own WiFi network (it's an access point) and you join that special wifi network from your Android phone.

Hi JML,
inside my code:
I introduce the name and password of my mobile hotsop and Tethering of my phone.
char ssid[] = "AndroidYannicKuda"; // your network SSID (name) between the " BELL972 "
char pass[] = "Password123";

once that, I am able to communicate with the wifi local IP of the Arduino Uno Wifi rev2. The wifi local IP of the Arduino uno Wifi rev2 is send through serial monitor interface pf Arduino IDE.
When I said I am not connected on internet is true because I am using wireless local network to communicate. In this case if I open a browser of another Android phone and tape the previous wifi local IP address it won't work...

Hi Dave,

Here is a code found on internet, where the wifi local IP is sent via an URL:

/*
Connect Arduino WiFi to AskSensors

#include <SoftwareSerial.h>

// serial config
#define RX 10
#define TX 11
SoftwareSerial AT(RX,TX);

// TODO: change user config
String ssid = "............."; //Wifi SSID
String password = "............."; //Wifi Password
String apiKeyIn = "............."; // API Key
const unsigned int writeInterval = 25000; // write inte rval (in ms)

// ASKSENSORS API host config
String host = "api.asksensors.com"; // API host name
String port = "80"; // port

int AT_cmd_time;
boolean AT_cmd_result = false;

void setup() {
Serial.begin(9600);
// open serial
Serial.println("*****************************************************");
Serial.println("********** Program Start : Connect Arduino WiFi to AskSensors");
AT.begin(115200);
Serial.println("Initiate AT commands with ESP8266 ");
sendATcmd("AT",5,"OK");
sendATcmd("AT+CWMODE=1",5,"OK");
Serial.print("Connecting to WiFi:");
Serial.println(ssid);
sendATcmd("AT+CWJAP=""+ ssid +"",""+ password +""",20,"OK");
}

void loop() {

// Create the URL for the request
String url = "GET /write/";
url += ;
url += "?module1=";
url += random(10, 100);
Serial.println("*****************************************************");
Serial.println("********** Open TCP connection ");
sendATcmd("AT+CIPMUX=1", 10, "OK");
sendATcmd("AT+CIPSTART=0, "TCP","" + host +""," + port, 20, "OK");
sendATcmd("AT+CIPSEND=0," + String(url.length() + 4), 10, ">");

Serial.print("********** requesting URL: ");
Serial.println(url);
AT.println(url);
delay(2000);
sendATcmd("AT+CIPCLOSE=0", 10, "OK");

Serial.println("********** Close TCP Connection ");
Serial.println("*****************************************************");

delay(writeInterval); // delay
}

// sendATcmd
void sendATcmd(String AT_cmd, int AT_cmd_maxTime, char readReplay[]) {
Serial.print("AT command:");
Serial.println(AT_cmd);

while(AT_cmd_time < (AT_cmd_maxTime)) {
AT.println(AT_cmd);
if(AT.find(readReplay)) {
AT_cmd_result = true;
break;
}

AT_cmd_time++;

}
Serial.print("...Result:");
if(AT_cmd_result == true) {
Serial.println("DONE");
AT_cmd_time = 0;
}

if(AT_cmd_result == false) {
Serial.println("FAILED");
AT_cmd_time = 0;
}

AT_cmd_result = false;
}

Can we adapt this code for WiFiNINA? Because the code above use ESP8266.
This can resolve my issue.

Thanks,
Aristide

Sure, when an Arduino connects to an smartphone via tethering, it gets an IP address from the phone's tethering network, not the WiFi network the phone might be connected to. The Arduino is isolated from that WiFi network and can only communicate with devices within the phone’s tethering network (The phone itself is handling the network routing and may forward traffic from the Arduino to the wireless network it’s connected to to provide internet access). So other phones, even on the same WiFi network (not tethered) can't see the Arduino.

Would you be willing to reverse the roles ? Would it work for you if the Android phone were to connect to the arduino if the arduino was seen as an access point?

It would mean to change your WiFi network on your phone and join the Arduino's network.

Yes, that might be a help.
To process it, what should I do?

Consider WiFiManager and what captive portal can bring to the equation.

Sorry, but I don't have time to study this.

To send temperature data from your Arduino WiFi Rev2 to your website, set it up as a web server using the Arduino tutorial you mentioned. Then, use HTTP POST or GET requests to send the sensor data to your website's backend (e.g., PHP or Node.js). For a free online platform, consider using services like Firebase or ThingSpeak to interact with your Arduino.