Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By giuse
#67946 This is my first use of MAX7219 and ESP8266.
I wrote some code but has very slow scrolling speed,
could I please have some suggestions?
Thanks
Code: Select all#include <ESP8266WiFi.h>

#include <ESP8266HTTPClient.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define PAUSE_TIME    0
#define SCROLL_SPEED  0
#define  MAX_DEVICES 4
#define CLK_PIN   D5  // or SCK
#define DATA_PIN  D7  // or MOSI
#define CS_PIN    D8  // or SS

MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
 HTTPClient http;
void setupWiFi()
{
    WiFi.begin("rete1", "pw");
   while(WiFi.status() != WL_CONNECTED)
   {
     delay(500);
     Serial.print(".");
   }

   Serial.println("Connected");
}
 
void setup() {

     setupWiFi();

  P.begin();
   P.addChar('$', degC);

}

  char tem[100];
  char umi[22];
 
 void rx(){
 
        http.begin("http://192.168.1.58/dati"); //HTTP

        int httpCode = http.GET();

               static String payload = http.getString();
               static String aa= "Tem:"+payload.substring(1,7)+"$ Umi:"+payload.substring(9,14)+"%";
             
                aa.toCharArray(tem, 100)

        http.end();

 }
void loop() {
 rx();
char *msg[] =
{
 tem
 
};
   static uint8_t cycle = 0;

  if (P.displayAnimate())
  {

    P.displayText(msg[cycle],  PA_CENTER, 0, 0,  PA_SCROLL_LEFT,  PA_SCROLL_LEFT);

 
    cycle = (cycle + 1) % ARRAY_SIZE(msg);
  }
}
User avatar
By wjburl
#76448 A very old debugging technique is to embed print statements in the code. In the Arduino IDE, many people insert Serial.println statements in the code. It looks like the function
int httpCode = http.GET(); is taking a lot of time.