Anonymní profil palkovic – Programujte.com
 x   TIP: Přetáhni ikonu na hlavní panel pro připnutí webu

Anonymní profil palkovic – Programujte.comAnonymní profil palkovic – Programujte.com

 

Příspěvky odeslané z IP adresy 5.22.154.–

Mikrokontroléry › zapisovanie teploty na ds k…
14. 2. 2018   #219738

#3 MilanL
Dakujem vám inač som nevedel ako tam dať čas. vyskúšám to bez toho.

Mikrokontroléry › zapisovanie teploty na ds k…
13. 2. 2018   #219730

Dobrý deň, prosím vás potrebujem pomoc s programom. Zvášť mi to funguje ale keď to spojím tak my to len zapisuje na sd kartu a nenačítávajú sa cez internet záznamy.Za pomoc, ďakujem.NOro

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
 File sdcard_file;
#include "DHT.h"
#define DHTPIN A8
#define DHTTYPE DHT11
const int chipSelect = 4;
DHT sensor(DHTPIN, DHTTYPE);
long minutes=55;
long hours=21;
long den=13;
long mesiac=3;
long rok=2018;
// maximum length of file name including path
#define FILE_NAME_LEN  20
// HTTP request type
#define HTTP_invalid   0
#define HTTP_GET       1
#define HTTP_POST      2

// file types
#define FT_HTML       0
#define FT_ICON       1
#define FT_CSS        2
#define FT_JAVASCRIPT 3
#define FT_JPG        4
#define FT_PNG        5
#define FT_GIF        6
#define FT_TEXT       7
#define FT_INVALID    8

// pin used for Ethernet chip SPI chip select
#define PIN_ETH_SPI   10

// the media access control (ethernet hardware) address for the shield:
const byte mac[] PROGMEM = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//the IP address for the shield:
const byte ip[] = { 192, 168, 1, 177 };  // does not work if this is put into Flash
// the router's gateway address:
const byte gateway[] PROGMEM = { 192, 168, 1, 1 };
// the subnet:
const byte subnet[] PROGMEM = { 255, 255, 255, 0 };

EthernetServer server(80);

void setup() {
  // deselect Ethernet chip on SPI bus
  pinMode(PIN_ETH_SPI, OUTPUT);
  digitalWrite(PIN_ETH_SPI, HIGH);
 
  Serial.begin(115200);       // for debugging
 
  if (!SD.begin(4)) {
    return;  // SD card initialization failed
  }
  Ethernet.begin((uint8_t*)mac, ip, gateway, subnet);
  server.begin();  // start listening for clients
}

void loop() {
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (ServiceClient(&client)) {
        // received request from client and finished responding
        break;
      }
    }  // while (client.connected())
    delay(1);
    client.stop();
  }  // if (client)
 
   sdcard_file = SD.open("txt.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (sdcard_file) {
   senddata();
    // close the file:
    sdcard_file.close();
   
  } else {
    // if the file didn't open, print an error:
    //Serial.println("error opening test.txt");
  }
 
}// void loop()

void senddata()  {
  float humidity = sensor.readHumidity();
  float temperature_C = sensor.readTemperature();
  float temperature_F = sensor.readTemperature(true);
  if (isnan(humidity) || isnan(temperature_C) || isnan(temperature_F)) {

  return;
  }
  float heat_indexF = sensor.computeHeatIndex(temperature_F, humidity);
  float heat_indexC = sensor.convertFtoC(heat_indexF);

  if (webFile) {
  for(long minutes = 00; minutes < 60; minutes=minutes+5)  {
    
    sdcard_file.print(den);
    sdcard_file.print(".");
    sdcard_file.print(mesiac);
    sdcard_file.print(".");
    sdcard_file.print(rok);
    sdcard_file.print("   ");
    
    sdcard_file.print(hours);
    sdcard_file.print(":");
    sdcard_file.print(minutes);
     
    sdcard_file.print(",  ");
    sdcard_file.print(temperature_C);
    sdcard_file.print(",  ");
    sdcard_file.print(humidity);
    sdcard_file.print(", ");
    sdcard_file.println(heat_indexC);
 
    if (minutes==55)  {
      hours = hours + 1;
      minutes = 0;
    }
    if (hours>24)  {
      hours = 0;
      den=den+1;
    }
    if (den>31)  {
      den = 0;
      mesiac=mesiac+1;
    }
    sdcard_file.flush(); //saving the file
    sdcard_file.close();
   delay(300000);
     }
}   
}
bool ServiceClient(EthernetClient *client)
{
  static boolean currentLineIsBlank = true;
  char cl_char;
  //File webFile;
  // file name from request including path + 1 of null terminator
  char file_name[FILE_NAME_LEN + 1] = {0};  // requested file name
  char http_req_type = 0;
  char req_file_type = FT_INVALID;
  const char *file_types[] = {"text/html", "image/x-icon", "text/css", "application/javascript", "image/jpeg", "image/png", "image/gif", "text/plain"};
 
  static char req_line_1[40] = {0};  // stores the first line of the HTTP request
  static unsigned char req_line_index = 0;
  static bool got_line_1 = false;

  if (client->available()) {   // client data available to read
    cl_char = client->read();
    
    if ((req_line_index < 39) && (got_line_1 == false)) {
      if ((cl_char != '\r') && (cl_char != '\n')) {
        req_line_1[req_line_index] = cl_char;
        req_line_index++;
      }
      else {
        got_line_1 = true;
        req_line_1[39] = 0;
      }
    }
    
    if ((cl_char == '\n') && currentLineIsBlank) {
      // get HTTP request type, file name and file extension type index
      http_req_type = GetRequestedHttpResource(req_line_1, file_name, &req_file_type);
      if (http_req_type == HTTP_GET) {         // HTTP GET request
        if (req_file_type < FT_INVALID) {      // valid file type
          webFile = SD.open(file_name);        // open requested file
          if (webFile) {
            // send a standard http response header
            client->println(F("HTTP/1.1 200 OK"));
            client->print(F("Content-Type: "));
            client->println(file_types[req_file_type]);
            client->println(F("Connection: close"));
            client->println();
            // send web page
            while(webFile.available()) {
              int num_bytes_read;
              char byte_buffer[64];
              // get bytes from requested file
              num_bytes_read = webFile.read(byte_buffer, 64);
              // send the file bytes to the client
              client->write(byte_buffer, num_bytes_read);
            }
            webFile.close();
          }
          else {
            // failed to open file
          }
        }
        else {
          // invalid file type
        }
      }
      else if (http_req_type == HTTP_POST) {
        // a POST HTTP request was received
      }
      else {
        // unsupported HTTP request received
      }
      req_line_1[0] = 0;
      req_line_index = 0;
      got_line_1 = false;
      // finished sending response and web page
      return 1;
    }
    if (cl_char == '\n') {
      currentLineIsBlank = true;
    }
    else if (cl_char != '\r') {
      currentLineIsBlank = false;
    }
  }  // if (client.available())
  return 0;
}

// extract file name from first line of HTTP request
char GetRequestedHttpResource(char *req_line, char *file_name, char *file_type)
{
  char request_type = HTTP_invalid;  // 1 = GET, 2 = POST. 0 = invalid
  char *str_token;
 
  *file_type = FT_INVALID;
 
  str_token =  strtok(req_line, " ");    // get the request type
  if (strcmp(str_token, "GET") == 0) {
    request_type = HTTP_GET;
    str_token =  strtok(NULL, " ");      // get the file name
    if (strcmp(str_token, "/") == 0) {
      strcpy(file_name, "index.htm");
      *file_type = FT_HTML;
    }
    else if (strlen(str_token) <= FILE_NAME_LEN) {
      // file name is within allowed length
      strcpy(file_name, str_token);
      // get the file extension
      str_token = strtok(str_token, ".");
      str_token = strtok(NULL, ".");
      
      if      (strcmp(str_token, "htm") == 0) {*file_type = 0;}
      else if (strcmp(str_token, "ico") == 0) {*file_type = 1;}
      else if (strcmp(str_token, "css") == 0) {*file_type = 2;}
      else if (strcmp(str_token, "js")  == 0) {*file_type = 3;}
      else if (strcmp(str_token, "jpg") == 0) {*file_type = 4;}
      else if (strcmp(str_token, "png") == 0) {*file_type = 5;}
      else if (strcmp(str_token, "gif") == 0) {*file_type = 6;}
      else if (strcmp(str_token, "txt") == 0) {*file_type = 7;}
      else {*file_type = 8;}
    }
    else {
      // file name too long
    }
  }
  else if (strcmp(str_token, "POST") == 0) {
    request_type = HTTP_POST;
  }

  return request_type;
}

palkovic
HTML / XHTML › načítanie dát na do grafu
27. 1. 2018   #219523

#3 palkovic
Už to funguje

palkovic
HTML / XHTML › načítanie dát na do grafu
27. 1. 2018   #219521

#2 peter
Ďakujem ti. Proim ta náhodou nevieš čo mám s wapseverom. Svieti na zeleno, tvárí sa že je všetko v poriadku len mi nejde localhost spustiť.Toto mi vypisuje:

[Fri Jan 26 23:35:19.142242 2018] [mpm_winnt:notice] [pid 2000:tid 392] AH00455: Apache/2.4.27 (Win64) PHP/5.6.31 configured -- resuming normal operations
[Fri Jan 26 23:35:19.142242 2018] [mpm_winnt:notice] [pid 2000:tid 392] AH00456: Apache Lounge VC15 Server built: Jul  7 2017 12:46:00
[Fri Jan 26 23:35:19.142242 2018] [core:notice] [pid 2000:tid 392] AH00094: Command line: 'c:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.27'
[Fri Jan 26 23:35:19.157842 2018] [mpm_winnt:notice] [pid 2000:tid 392] AH00418: Parent: Created child process 4304
[Fri Jan 26 23:35:20.171844 2018] [mpm_winnt:notice] [pid 4304:tid 316] AH00354: Child: Starting 64 worker threads.
[Fri Jan 26 23:42:56.639562 2018] [mpm_winnt:notice] [pid 2000:tid 392] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Fri Jan 26 23:42:58.667565 2018] [mpm_winnt:notice] [pid 4304:tid 316] AH00364: Child: All worker threads have exited.
[Fri Jan 26 23:42:58.995166 2018] [mpm_winnt:notice] [pid 2000:tid 392] AH00430: Parent: Child process 4304 exited successfully.
[Fri Jan 26 23:46:07.692842 2018] [mpm_winnt:notice] [pid 3596:tid 392] AH00455: Apache/2.4.27 (Win64) PHP/5.6.31 configured -- resuming normal operations
[Fri Jan 26 23:46:07.692842 2018] [mpm_winnt:notice] [pid 3596:tid 392] AH00456: Apache Lounge VC15 Server built: Jul  7 2017 12:46:00
[Fri Jan 26 23:46:07.692842 2018] [core:notice] [pid 3596:tid 392] AH00094: Command line: 'c:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.27'
[Fri Jan 26 23:46:07.708442 2018] [mpm_winnt:notice] [pid 3596:tid 392] AH00418: Parent: Created child process 3632
[Fri Jan 26 23:46:08.457243 2018] [mpm_winnt:notice] [pid 3632:tid 316] AH00354: Child: Starting 64 worker threads.
[Sat Jan 27 00:03:50.622216 2018] [mpm_winnt:notice] [pid 3596:tid 392] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Jan 27 00:03:52.665820 2018] [mpm_winnt:notice] [pid 3632:tid 316] AH00364: Child: All worker threads have exited.
[Sat Jan 27 00:03:52.743820 2018] [mpm_winnt:notice] [pid 3596:tid 392] AH00430: Parent: Child process 3632 exited successfully.
[Sat Jan 27 00:03:58.547030 2018] [mpm_winnt:notice] [pid 668:tid 392] AH00455: Apache/2.4.27 (Win64) PHP/5.6.31 configured -- resuming normal operations
[Sat Jan 27 00:03:58.547030 2018] [mpm_winnt:notice] [pid 668:tid 392] AH00456: Apache Lounge VC15 Server built: Jul  7 2017 12:46:00
[Sat Jan 27 00:03:58.547030 2018] [core:notice] [pid 668:tid 392] AH00094: Command line: 'c:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.27'
[Sat Jan 27 00:03:58.562630 2018] [mpm_winnt:notice] [pid 668:tid 392] AH00418: Parent: Created child process 5000
[Sat Jan 27 00:03:59.171031 2018] [mpm_winnt:notice] [pid 5000:tid 316] AH00354: Child: Starting 64 worker threads.
[Sat Jan 27 00:06:03.908850 2018] [mpm_winnt:notice] [pid 668:tid 392] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sat Jan 27 00:06:05.936854 2018] [mpm_winnt:notice] [pid 5000:tid 316] AH00364: Child: All worker threads have exited.
[Sat Jan 27 00:06:05.968054 2018] [mpm_winnt:notice] [pid 668:tid 392] AH00430: Parent: Child process 5000 exited successfully.
[Sat Jan 27 00:06:14.813270 2018] [mpm_winnt:notice] [pid 4472:tid 400] AH00455: Apache/2.4.27 (Win64) PHP/5.6.31 configured -- resuming normal operations
[Sat Jan 27 00:06:14.813270 2018] [mpm_winnt:notice] [pid 4472:tid 400] AH00456: Apache Lounge VC15 Server built: Jul  7 2017 12:46:00
[Sat Jan 27 00:06:14.813270 2018] [core:notice] [pid 4472:tid 400] AH00094: Command line: 'c:\\wamp64\\bin\\apache\\apache2.4.27\\bin\\httpd.exe -d C:/wamp64/bin/apache/apache2.4.27'
[Sat Jan 27 00:06:14.813270 2018] [mpm_winnt:notice] [pid 4472:tid 400] AH00418: Parent: Created child process 4252
[Sat Jan 27 00:06:15.577671 2018] [mpm_winnt:notice] [pid 4252:tid 332] AH00354: Child: Starting 64 worker threads.

HTML / XHTML › načítanie dát na do grafu
25. 1. 2018   #219503

Dobrý deň,chcel by som aby sa mi zobrazovali údaje ulaožene dokumente dokumente nap. txt., aby sa mi to zobrazovalo v grafe. na zobrazovanie potrebujem aj lokalhost? na internete som našiel tento graf ale neviem sa stým pohnúť pros´m vás pomožte mi.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<script>
window.onload = function () {

var dps = []; // dataPoints
var chart = new CanvasJS.Chart("chartContainer", {
    title :{
        text: "Dynamic Data"
    },
    axisY: {
        includeZero: false
    },      
    data: [{
        type: "line",
        dataPoints: dps
    }]
});

var xVal = 0;
var yVal = 100;
var updateInterval = 1000;
var dataLength = 20; // number of dataPoints visible at any point

var updateChart = function (count) {

    count = count || 1;

    for (var j = 0; j < count; j++) {
        yVal = yVal +  Math.round(5 + Math.random() *(-5-5));
        dps.push({
            x: xVal,
            y: yVal
        });
        xVal++;
    }

    if (dps.length > dataLength) {
        dps.shift();
    }

    chart.render();
};

updateChart(dataLength);
setInterval(function(){updateChart()}, updateInterval);

}
</script>
</head>
<body>
<div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
<script src="../../canvasjs.min.js"></script>
</body>
</html>

 

 

Hostujeme u Českého hostingu       ISSN 1801-1586       ⇡ Nahoru Webtea.cz logo © 20032024 Programujte.com
Zasadilo a pěstuje Webtea.cz, šéfredaktor Lukáš Churý