Bonjour,
Merci par avance pour l'aide que vous pourrait m'apporter.
Je cherche à récupérer des infos de jeedom par un esp32 puis les afficher sur une matrice de LED. Actuellement j'arrive à récupérer une seule info puis l'afficher, je ne trouve pas le moyen d'en récupérer plusieurs.
Voici le code utilisé qui fonctionne pour une info
/*
ESP32 WiFi Message Board
by Roland Pelayo
Full tutorial: https://www.teachmemicro.com/esp32-max7219-wifi-message-board
Rev 1.0 - Initial code - June 7, 2020
*/
//Declare libraries
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include "EEPROM.h"
#include <LEDMatrixDriver.hpp>
#include <HTTPClient.h>
//Headers
#include "mainpage.h"
#include "font.h"
#include "mat_functions.h"
//provide your own WiFi SSID and password
const char* ssid = "*********";
const char* password = "************";
//Create WebServer instance
WebServer server(80);
//Initialize message to display
int win;
int wout;
String message = "";
String payload1 = "";
void setup() {
//This uses EEPROM to store previous message
//Initialize EEPROM
if (!EEPROM.begin(1000)) {
Serial.println("Failed to initialise EEPROM");
Serial.println("Restarting...");
delay(1000);
ESP.restart();
}
//Initialize the display
lmd.setEnabled(true);
lmd.setIntensity(2); // 0 = low, 10 = high
//For debugging
Serial.begin(115200);
//Use ESP32 as WiFi Station
WiFi.mode(WIFI_STA);
//Initiate WiFi Connection
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
//Print your WiFi's SSID (might be insecure)
Serial.println(ssid);
Serial.print("IP address: ");
//Print your local IP address (needed for browsing the app)
Serial.println(WiFi.localIP());
}
void loop() {
if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
HTTPClient http;
http.begin("http://jeedom........."); //Specify the URL
int httpCode = http.GET(); //Make the request
if (httpCode > 0) { //Check for the returning code
String payload1 = http.getString(); //chaine_1.concat(chaine_2);
Serial.println(payload1);
}
else {
Serial.println("Error on HTTP request");
}
http.end(); //Free the resources
//redirect http code
String msg = payload1
Serial.println(msg);
// msg.toUpperCase(); //all incoming string is converted to uppercase since no font for small cases
message = msg;
EEPROM.writeString(0,message); //store received message to EEPROM
EEPROM.commit();
}
int len = message.length(); //get message length
if(len > 100) return; //limit messages to 100 characters
writeToMatrix(message,len); //write to LED Matrix. This function is on mat_functions.h
// Toggle display of the new framebuffer
lmd.display();
// Wait to let the human read the display
delay(ANIM_DELAY);
// Advance to next coordinate
if( --x < len * -8 ) {
x = LEDMATRIX_WIDTH;
}
delay(10); //adjust this for faster/slower scrolling
}
j'ai essayé de créer plusieurs appels http.begin et de stocker les infos, sans succès.
Des idées ?
Merci bien.