Aufzeichnung der Temperaturwerte und Graphische Darstellung von DS18x20 Sensoren

    Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

    • Ja, habe einen Mac. Ich habe beide zip Dateien, welche ich hochgeladen habe, runtergeladen und entpackt. Alles sauber vorhanden.

      Ich pack das jetzt noch mal in code


      C-Quellcode

      1. #include <Arduino.h>
      2. // wenn aktiv: Meldungen per Serial
      3. #define SERIAL
      4. // wenn auskommentiert: delay()
      5. // wenn aktiv: deep sleep nutzen (Hardwaremodifikation notwendig)
      6. #define DEEP
      7. //sekunden zwischen Aufwachvorgängen
      8. #define WAIT 120
      9. const String host = "192.168.200.230“;
      10. const unsigned int port = 80;
      11. const String url_start = "/vz/htdocs/middleware.php/data/";
      12. const String url_stop = ".json?operation=add&value=";
      13. const String uuid_temp = „ded9a1c0-0bd7-11e6-8442-cb029c9116e8“;
      14. const String uuid_humid = „4df5a320-0bd8-11e6-ac6d-f50f4729e917“;
      15. byte maxwait = 120; //Wifi must connect in < x seconds
      16. #define DHTPIN 2 // Pin which is connected to the DHT sensor.
      17. #define DHTTYPE DHT22 // DHT 22 (AM2302)
      18. #include <ESP8266WiFi.h>
      19. #include <ESP8266WiFiMulti.h>
      20. #include <ESP8266HTTPClient.h>
      21. #include <Adafruit_Sensor.h>
      22. #include <DHT.h>
      23. #include <DHT_U.h>
      24. ESP8266WiFiMulti WiFiMulti;
      25. DHT_Unified dht(DHTPIN, DHTTYPE);
      26. void setup() {
      27. #ifdef SERIAL
      28. Serial.begin(115200);
      29. Serial.println("BOOT");
      30. Serial.print("Wifi...");
      31. #endif
      32. WiFiMulti.addAP(„SSID“, „Password xxxyyyxxx“);
      33. #ifdef SERIAL
      34. Serial.println("OK");
      35. Serial.print("DHT...");
      36. #endif
      37. dht.begin();
      38. #ifdef SERIAL
      39. Serial.print("OK");
      40. #endif
      41. sensor_t sensor;
      42. #ifdef SERIAL
      43. dht.temperature().getSensor(&sensor);
      44. Serial.println("------------------------------------");
      45. Serial.println("Temperature");
      46. Serial.print ("Sensor: "); Serial.println(sensor.name);
      47. Serial.print ("Driver Ver: "); Serial.println(sensor.version);
      48. Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
      49. Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" °C");
      50. Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" °C");
      51. Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" °C");
      52. #endif
      53. dht.humidity().getSensor(&sensor);
      54. #ifdef SERIAL
      55. Serial.println("------------------------------------");
      56. Serial.println("Humidity");
      57. Serial.print ("Sensor: "); Serial.println(sensor.name);
      58. Serial.print ("Driver Ver: "); Serial.println(sensor.version);
      59. Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
      60. Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%");
      61. Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%");
      62. Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%");
      63. Serial.println("------------------------------------");
      64. #endif
      65. }
      66. bool waitWifi() {
      67. while((WiFiMulti.run() != WL_CONNECTED) && maxwait > 0) {
      68. #ifdef SERIAL
      69. Serial.println("Wait Wifi");
      70. #endif
      71. delay(1000);
      72. maxwait--;
      73. }
      74. if(WiFiMulti.run() == WL_CONNECTED) return true;
      75. return false;
      76. }
      77. void sendHttpData(String url) {
      78. HTTPClient http;
      79. if(waitWifi()) {
      80. #ifdef SERIAL
      81. Serial.print("GET: "); Serial.println(url);
      82. #endif
      83. http.begin(host, port, url); //HTTP
      84. int httpCode = http.GET();
      85. #ifdef SERIAL
      86. if(httpCode) {
      87. if(httpCode == 200) {
      88. String payload = http.getString();
      89. Serial.println(payload);
      90. }else{
      91. Serial.print("HTTP "); Serial.println(httpCode);
      92. }
      93. } else {
      94. Serial.print("[HTTP] GET... failed, no connection or no HTTP server\n");
      95. }
      96. #endif
      97. }else{
      98. #ifdef SERIAL
      99. Serial.print("No WiFi available\n");
      100. #endif
      101. }
      102. }
      103. void loop() {
      104. String url_temp = "";
      105. #ifndef SERIAL
      106. digitalWrite(1, HIGH); //LED off
      107. #endif
      108. delay(2000); //If we've just started the power might be somewhat distorted - lets wait a bit to get things setteled...
      109. sensors_event_t event;
      110. dht.temperature().getEvent(&event);
      111. if (isnan(event.temperature)) {
      112. #ifdef SERIAL
      113. Serial.println("Error reading temperature!");
      114. #endif
      115. } else{
      116. #ifdef SERIAL
      117. Serial.print("Temperature: ");
      118. Serial.print(event.temperature);
      119. Serial.println(" °C");
      120. #endif
      121. url_temp = url_start;
      122. url_temp += uuid_temp;
      123. url_temp += url_stop;
      124. url_temp += event.temperature;
      125. sendHttpData(url_temp);
      126. }
      127. dht.humidity().getEvent(&event);
      128. if (isnan(event.relative_humidity)) {
      129. #ifdef SERIAL
      130. Serial.println("Error reading humidity!");
      131. #endif
      132. }
      133. else {
      134. #ifdef SERIAL
      135. Serial.print("Humidity: ");
      136. Serial.print(event.relative_humidity);
      137. Serial.println("%");
      138. #endif
      139. url_temp = url_start;
      140. url_temp += uuid_humid;
      141. url_temp += url_stop;
      142. url_temp += event.relative_humidity;
      143. sendHttpData(url_temp);
      144. }
      145. #ifdef SERIAL
      146. Serial.println("SLEEP");
      147. Serial.flush();
      148. #endif
      149. #ifdef DEEP
      150. ESP.deepSleep(1000000 * WAIT);
      151. #else
      152. //@todo disconnect WiFi to save power?
      153. delay(1000 * WAIT);
      154. #endif
      155. }
      Alles anzeigen
      Zeilen 14 + 17 +20 +21+ 55 müssen angepasst werden.
      SHC Master B2+ WLAN sowie 1 Slave B2+, 2 Slave B+ und 2 Slave Raspi B. 5x Pi Cam; Imac mit OSX El Capitan; Iphone 6 plus; Ipad mini; Lenovo Android Tablet.

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von rmjspa ()

    • Habe mal unter Download eine Installations.- und kleine Anwendunganleitung für Middleware reingesetzt, so wie es bei mit funktioniert.
      Ist mit Wordpad erstellt.

      Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von premo ()

    • Habe die Anleitung zum auslagern der sql Database vom Volkszähler auf einen USB Stick wiedergefunden.

      Hiernach bin ich vorgegangen:

      Mysql on USB Stick

      First of all, plug in the USB drive. We want to format it to ext4 file system:

      sudo mkfs.ext4 /dev/sda1 -L usbdrive

      Now we want to auto-mount the USB drive. We need to edit the /etc/fstab file:

      sudo nano /etc/fstab

      Add the following line to the bottom:

      /dev/sda1 /mnt/disk1 ext4 defaults 0 0

      sudo reboot

      Now we need to test that the auto-mount works:

      sudo mount -a

      Now go to the folder we have mounted it to see if it has worked:

      mount

      And you should see the line at the bottom saying something like:

      /dev/sda1 on /mnt/disk1 type ext4 (rw,relatime,data=ordered)


      move an existing Database


      Now to move the MySQL data folder to the USB drive. First we need to stop the MySQL server:

      sudo service mysql stop

      Then navigate to the folder where we would like to put the MySQL data folder:

      cd /mnt/disk1

      Create the folder for the data files:

      sudo mkdir mysql

      Now to copy the data files. We need to do this as a superuser to access the data folder:

      sudo su

      Now the prompt will look different:

      root@raspberrypi:/mnt/disk1#

      Enter the following to copy the files:

      cp –Rv /var/lib/mysql/* /mnt/disk1/mysql/

      Change the ownership of the folder so MySQL can access it:

      chown -R mysql:mysql /mnt/disk1/mysql

      exit

      Now we're back to the usual prompt:

      pi@raspberrypi /mnt/disk1 $

      Now we must edit the MySQL configuration to let it know where the new data folder is:

      sudo nano /etc/mysql/my.cnf

      Change the line:

      datadir = /var/lib/mysql

      to:

      datadir = /mnt/disk1/mysql

      Now restart the MySQL server:

      sudo service mysql start

      Hopefully you will see a message like the following:

      [ ok ] Stopping MySQL database server: mysqld.
      [ ok ] Starting MySQL database server: mysqld . ..
      [info] Checking for tables which need an upgrade, are corrupt or were
      not closed cleanly..
      SHC Master B2+ WLAN sowie 1 Slave B2+, 2 Slave B+ und 2 Slave Raspi B. 5x Pi Cam; Imac mit OSX El Capitan; Iphone 6 plus; Ipad mini; Lenovo Android Tablet.
    • Nach wochenlangem Störungsfreiem Aufzeichnen verschiedener Werte im VZ
      auf mehreren RPis haben sich la viele Daten angesammelt.
      Da ich die Daten nicht benötige und diese nicht brauche, sollen die
      Daten vom RPi entfernt werden.
      Die Daten befinden sich bei mir unter

      Quellcode

      1. /var/lib/mysql/ib_logfile0
      2. /var/lib/mysql/ib_logfile1
      3. /var/lib/mysql/ibdata1
      Wie aber entfernt man diese.
      Öffnen lassen sich die Dateien, aber es erscheinen seltsame Symbole.
    • Auch hier ein Dank an rmjspa, habe jetzt schon über viele Wochen Erfolgreich
      mit einigen RPi`s die Werte von DS18 und BMP aufzeichnen können.
      Bei mir laufen so einige RPi wegen verschiedenen Aufgaben.
      RPi 1 für den Pool, 2 für die Heizung, 3 Wintergarten, 4 Wohnung, 5 Hobby - Testraum, u.s.w.
    • Hallo
      Habe heute auf einem Rpi3B+ mit Stretch den VZ Middleware installiert.
      Ein DS18B20 wird nur angezeigt wenn das Skript manuell gestartet wird.
      Nach dem Neustart des Rpi wird nichts mehr angezeigt aber im Hintergrund.
      Wenn ich das Skript wieder manuell starte wird der Kurvenverlauf weiter
      angezeigt.

      Das Skript wurde so angelegt.

      Quellcode

      1. cd /usr/bin
      2. sudo nano shc10neu.php "PHP-Script anlegen"
      3. sudo chmod +x shc10neu.php "ausführbar machen"
      4. Zum testen einfach mit: shc10neu.php& "es erscheint nun die ID und der Wert vom DS18"
      5. sudo reboot
      6. Anschliessend crontab -e angelegt.
      7. sudo crontab -e
      8. @reboot /usr/bin/php7.0 /usr/bin/shc10neu.php & > /dev/null 2>&1
      9. sudo reboot

      Die ersten Zeilen im Skript sehen so aus.

      PHP-Quellcode

      1. #!/usr/bin/php
      2. <?php
      3. if (! function_exists('pcntl_fork')) die('PCNTL functions not available on this PHP installation');
      4. $mapping = array(
      5. '000006d28427' => 'f3286b40-3b0e-11e8-81cd-a1faf2753ca3', // shc_10
      6. );
      7. $middleware = 'http://192.168.178.10/volkszaehler.org/htdocs/middleware.php';
      8. $maxforks = 10;
      9. $forks = 0;
      Alles anzeigen

      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von premo () aus folgendem Grund: Fehler gefunden. Im crontab -e habe ich hinter shc10neu das .php vergessen.