NodeMCU / TM1367 / zobrazeni GET parametru (teploty)

zatím neumí https.

JE důležité provést funkci trim() jinak vykreslovalo prázdné znaky.

/*
  Basic usage example

  Demonstrated some of the basic functionality of the library. Initialize the display, set the backlight brightness, print some text, count from 0 to 100 and print on display and blink some text.

  Note: make sure to set your serial monitor to line end: NEW LINE!

  The circuit:
  * connect TM1637 pin CLK to Arduino pin D4
  * connect TM1637 pin DIO to Arduino pin D5
  * connect TM1637 pin Vcc to Arduino pin 5V
  * connect TM1637 pin GND to Arduino pin GND

  Created 25 September 2015
  By Bram Harmsen

  https://github.com/bremme/arduino-tm1637

*/

// include the SevenSegmentTM1637 library
#include "SevenSegmentTM1637.h"
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

/* initialize global TM1637 Display object
*  The constructor takes two arguments, the number of the clock pin and the digital output pin:
* SevenSegmentTM1637(byte pinCLK, byte pinDIO);
*/
const byte PIN_CLK = D5;   // define CLK pin (any digital pin)
const byte PIN_DIO = D6;   // define DIO pin (any digital pin)
SevenSegmentTM1637    display(PIN_CLK, PIN_DIO);

const char* ssid = "Brno4";
const char* password = "******";

// run setup code
void setup() {
  Serial.begin(9600);         // initializes the Serial connection @ 9600 baud
  display.begin();            // initializes the display
  display.setBacklight(100);  // set the brightness to 100 %

  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
 
    delay(500);
    Serial.print(".");
    display.print("----");  
 
  }
  Serial.println("");
  Serial.println("WiFi connected");
  // Print the IP address
  Serial.println(WiFi.localIP());
  display.print("0000");      // display INIT on the display
  delay(500);

 
  
};

// run loop (forever)
void loop() {
  //display.clear();

  if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status


    
    
    Serial.println("Wifi propojena jdeme stahovat..."); 

    HTTPClient http;    //Declare object of class HTTPClient
  
    String Link, payload;

       
  
    //GET Data
   
    //Link = "https://thingspeak.com/channels/379934/field/1/last";
    Link = "http://www.hruby-foto.cz/saliny/last_temp.php";
    
    http.begin(Link);     //Specify request destination
    
    int httpCode = http.GET();            //Send the request
    
    payload = http.getString();    //Get the response payload
    payload.trim();
 
      Serial.println(httpCode);   //Print HTTP return code
      Serial.println(payload);    //Print request response payload
    
      http.end();  //Close connection
      
    
      display.clear();
      display.print(payload);      // display INIT on the display



      
  }else {
      Serial.println("Wifi nepripojena ..."); 
      display.print("----");
    }
    
      //display.clear();
      delay(30000);    //Send a request every 30 seconds
 


};

Napsat komentář