Aufzeichnung der Temperaturwerte und Graphische Darstellung von DS18x20 Sensoren
Your browser (%browser%) is out of date. It has known security flaws and may not display all features of this and other websites. \
Learn how to update your browser'.
-
-
wieder verstümmelt.
aber siehe Post 60.
Die neue Datei von der Quellseite ist Da gespeichert und ist lesbar.
Hast du n MAC ?habe SHC aufgegeben.The post was edited 1 time, last by bin dann weg ().
-
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 Source Code
- #include <Arduino.h>
- // wenn aktiv: Meldungen per Serial
- #define SERIAL
- // wenn auskommentiert: delay()
- // wenn aktiv: deep sleep nutzen (Hardwaremodifikation notwendig)
- #define DEEP
- //sekunden zwischen Aufwachvorgängen
- #define WAIT 120
- const String host = "192.168.200.230“;
- const unsigned int port = 80;
- const String url_start = "/vz/htdocs/middleware.php/data/";
- const String url_stop = ".json?operation=add&value=";
- const String uuid_temp = „ded9a1c0-0bd7-11e6-8442-cb029c9116e8“;
- const String uuid_humid = „4df5a320-0bd8-11e6-ac6d-f50f4729e917“;
- byte maxwait = 120; //Wifi must connect in < x seconds
- #define DHTPIN 2 // Pin which is connected to the DHT sensor.
- #define DHTTYPE DHT22 // DHT 22 (AM2302)
- #include <ESP8266WiFi.h>
- #include <ESP8266WiFiMulti.h>
- #include <ESP8266HTTPClient.h>
- #include <Adafruit_Sensor.h>
- #include <DHT.h>
- #include <DHT_U.h>
- ESP8266WiFiMulti WiFiMulti;
- DHT_Unified dht(DHTPIN, DHTTYPE);
- void setup() {
- #ifdef SERIAL
- Serial.begin(115200);
- Serial.println("BOOT");
- Serial.print("Wifi...");
- #endif
- WiFiMulti.addAP(„SSID“, „Password xxxyyyxxx“);
- #ifdef SERIAL
- Serial.println("OK");
- Serial.print("DHT...");
- #endif
- dht.begin();
- #ifdef SERIAL
- Serial.print("OK");
- #endif
- sensor_t sensor;
- #ifdef SERIAL
- dht.temperature().getSensor(&sensor);
- Serial.println("------------------------------------");
- Serial.println("Temperature");
- Serial.print ("Sensor: "); Serial.println(sensor.name);
- Serial.print ("Driver Ver: "); Serial.println(sensor.version);
- Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
- Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" °C");
- Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" °C");
- Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" °C");
- #endif
- dht.humidity().getSensor(&sensor);
- #ifdef SERIAL
- Serial.println("------------------------------------");
- Serial.println("Humidity");
- Serial.print ("Sensor: "); Serial.println(sensor.name);
- Serial.print ("Driver Ver: "); Serial.println(sensor.version);
- Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
- Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%");
- Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%");
- Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%");
- Serial.println("------------------------------------");
- #endif
- }
- bool waitWifi() {
- while((WiFiMulti.run() != WL_CONNECTED) && maxwait > 0) {
- #ifdef SERIAL
- Serial.println("Wait Wifi");
- #endif
- delay(1000);
- maxwait--;
- }
- if(WiFiMulti.run() == WL_CONNECTED) return true;
- return false;
- }
- void sendHttpData(String url) {
- HTTPClient http;
- if(waitWifi()) {
- #ifdef SERIAL
- Serial.print("GET: "); Serial.println(url);
- #endif
- http.begin(host, port, url); //HTTP
- int httpCode = http.GET();
- #ifdef SERIAL
- if(httpCode) {
- if(httpCode == 200) {
- String payload = http.getString();
- Serial.println(payload);
- }else{
- Serial.print("HTTP "); Serial.println(httpCode);
- }
- } else {
- Serial.print("[HTTP] GET... failed, no connection or no HTTP server\n");
- }
- #endif
- }else{
- #ifdef SERIAL
- Serial.print("No WiFi available\n");
- #endif
- }
- }
- void loop() {
- String url_temp = "";
- #ifndef SERIAL
- digitalWrite(1, HIGH); //LED off
- #endif
- delay(2000); //If we've just started the power might be somewhat distorted - lets wait a bit to get things setteled...
- sensors_event_t event;
- dht.temperature().getEvent(&event);
- if (isnan(event.temperature)) {
- #ifdef SERIAL
- Serial.println("Error reading temperature!");
- #endif
- } else{
- #ifdef SERIAL
- Serial.print("Temperature: ");
- Serial.print(event.temperature);
- Serial.println(" °C");
- #endif
- url_temp = url_start;
- url_temp += uuid_temp;
- url_temp += url_stop;
- url_temp += event.temperature;
- sendHttpData(url_temp);
- }
- dht.humidity().getEvent(&event);
- if (isnan(event.relative_humidity)) {
- #ifdef SERIAL
- Serial.println("Error reading humidity!");
- #endif
- }
- else {
- #ifdef SERIAL
- Serial.print("Humidity: ");
- Serial.print(event.relative_humidity);
- Serial.println("%");
- #endif
- url_temp = url_start;
- url_temp += uuid_humid;
- url_temp += url_stop;
- url_temp += event.relative_humidity;
- sendHttpData(url_temp);
- }
- #ifdef SERIAL
- Serial.println("SLEEP");
- Serial.flush();
- #endif
- #ifdef DEEP
- ESP.deepSleep(1000000 * WAIT);
- #else
- //@todo disconnect WiFi to save power?
- delay(1000 * WAIT);
- #endif
- }
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.The post was edited 2 times, last by rmjspa ().
-
vergleich mal mit meiner neu runtergeladenen version.habe SHC aufgegeben.
The post was edited 1 time, last by bin dann weg ().
-
C-3po wrote:
crontab -e
und da dann diese Zeile einfügen:
@reboot /usr/bin/php5 /usr/bin/w1vzSHC.php & > /dev/null 2>&1
aber anpassen !!!
-
Habe mal unter Download eine Installations.- und kleine Anwendunganleitung für Middleware reingesetzt, so wie es bei mit funktioniert.
Ist mit Wordpad erstellt.The post was edited 2 times, last by 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
Wie aber entfernt man diese.
Öffnen lassen sich die Dateien, aber es erscheinen seltsame Symbole. -
-
Ok, das kann es sicherlich sein.
-
-
-
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.
Source Code
- cd /usr/bin
- sudo nano shc10neu.php "PHP-Script anlegen"
- sudo chmod +x shc10neu.php "ausführbar machen"
- Zum testen einfach mit: shc10neu.php& "es erscheint nun die ID und der Wert vom DS18"
- sudo reboot
- Anschliessend crontab -e angelegt.
- sudo crontab -e
- @reboot /usr/bin/php7.0 /usr/bin/shc10neu.php & > /dev/null 2>&1
- sudo reboot
Die ersten Zeilen im Skript sehen so aus.
PHP Source Code
- #!/usr/bin/php
- <?php
- if (! function_exists('pcntl_fork')) die('PCNTL functions not available on this PHP installation');
- $mapping = array(
- '000006d28427' => 'f3286b40-3b0e-11e8-81cd-a1faf2753ca3', // shc_10
- );
- $middleware = 'http://192.168.178.10/volkszaehler.org/htdocs/middleware.php';
- $maxforks = 10;
- $forks = 0;
The post was edited 1 time, last by premo: Fehler gefunden. Im crontab -e habe ich hinter shc10neu das .php vergessen. ().
-
Fehler gefunden.
Habe in crontab -e hinter shc10neu das .php vergessen.
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0