Salut a tout le monde !!!
je suis en pls (possition lateral de securité).
Mon serveur YunoHost
Matériel: Raspberry Pi 4 Samsung T7 1T raid 5 (5 disques 2T)
Version de YunoHost: YunoHost 11.2.3
J’ai accès à mon serveur : En SSH | Par la webadmin | En direct avec un clavier/écran
Êtes-vous dans un contexte particulier ou avez-vous effectué des modificiations particulières sur votre instance ? : non
J’ai activé le SLL
Je cherche a faire une requet post depuis mon esp32 sur mon node red installé avec l’utilitaire yunohost.
Pour renvoyer des info de capteur climatique.
Mon code et le suivant:
#include <Arduino.h>
#include <WiFiClient.h>
#include <HTTPClient.h>
const char* ssid = “Bbox-B1882023”;
const char* password = “SLDnY6JzjXDKLrcwYc”;
//Your Domain name with URL path or IP address with path
String serverName = “https://(mon nom de domain):1880/update-sensor”;
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastTime = 0;
// Timer set to 10 minutes (600000)
//unsigned long timerDelay = 600000;
// Set timer to 5 seconds (5000)
unsigned long timerDelay = 5000;
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println(“Connecting”);
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(“.”);
}
Serial.println(“”);
Serial.print("Connected to WiFi network with IP Address: ");
Serial.println(WiFi.localIP());
Serial.println(“Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.”);
}
void loop() {
//Send an HTTP POST request every 10 minutes
if ((millis() - lastTime) > timerDelay) {
//Check WiFi connection status
if(WiFi.status()== WL_CONNECTED){
HTTPClient http;
String serverPath = serverName + "?temperature=24.37";
// Your Domain name with URL path or IP address with path
http.begin(serverPath.c_str());
// If you need Node-RED/server authentication, insert user and password below
//http.setAuthorization("REPLACE_WITH_SERVER_USERNAME", "REPLACE_WITH_SERVER_PASSWORD");
// Send HTTP GET request
int httpResponseCode = http.GET();
if (httpResponseCode>0) {
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
String payload = http.getString();
Serial.println(payload);
}
else {
Serial.print("Error code: ");
Serial.println(httpResponseCode);
}
// Free resources
http.end();
}
else {
Serial.println("WiFi Disconnected");
}
lastTime = millis();
}
}
Et je pense que la partie d’adressage n’est pas correcte “String serverName = “https://(mon nom de domain):1880/update-sensor”;” je recois une erreur, en console 301.
hellp me please !!!
Merci encore pour yunohost top projet.
Thomas