MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. cruunnerr
    3. Posts
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    Offline
    • Profile
    • Following 3
    • Followers 7
    • Topics 14
    • Posts 279
    • Groups 0

    Posts

    Recent Best Controversial
    • RE: MMM-Remote-Control show error on start

      Hmm,

      i am running several 3rd Party modules. All modules in config.js:

      GoogleMapsTraffic
      alert
      Watchdog
      Remote Control
      Remote Control Repository
      Buttons
      Podcast
      Clock
      EasyPix
      NOAA
      MovieListings
      SystemStats
      Scrobbler
      CalendarEXT
      MyCommute
      OilTank (just installed this morning, but the error was before)

      Maybe @Jopyth has an idea.

      The odd thing is, that i already installed a Mirror with the exactly same modules and got no error. But this was with Raspbian Stretch lite, now i am using Jessie Desktop. But i cannot imagine that this causes the error

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • MMM-Remote-Control show error on start

      Hey guys,

      i freshly installed MM manually on a RPi 3 with Raspbian Jessie.

      MM starts and i am able to use the Remote Control, but i also get this error from the Remote-Control module. The error is shown 4 times directly behind each other.

      0|mm       | Whoops! There was an uncaught exception...
      0|mm       | TypeError: Cannot read property 'replace' of undefined
      0|mm       |     at /home/pi/MagicMirror/modules/MMM-Remote-Control/node_helper.js:240:24
      0|mm       |     at /home/pi/MagicMirror/modules/MMM-Remote-Control/node_modules/simple-git/src/git.js:768:18
      0|mm       |     at Git. (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_modules/simple-git/src/git.js:808:18)
      0|mm       |     at done (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_modules/simple-git/src/git.js:1354:21)
      0|mm       |     at ChildProcess. (/home/pi/MagicMirror/modules/MMM-Remote-Control/node_modules/simple-git/src/git.js:1379:16)
      0|mm       |     at emitTwo (events.js:106:13)
      0|mm       |     at ChildProcess.emit (events.js:191:7)
      0|mm       |     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
      0|mm       | MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
      0|mm       | If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
      

      How i already said… i can access the Mirror by http://my.RPi.IP.address:8080/remote.html

      So everything is working fine, but i don’t know why this occurs

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: MMM-PIR-Sensor: Everything works fine, just one thing not...

      @Medo

      Glad to hear that :)

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: show integer logs from python script as diagram in MM ?

      @doubleT
      i edited my post while u wrote this ^^

      for the first i didn’t want to create a own module, but maybe later, when i understand the stuff good.

      as u can read in my edit, i can create a JSON with the script i posted. but i don’t know where to put the script to execute it automatically every 24 hours or something like that.

      because i think using cronjob would be the wrong way, right? :D

      edit:

      i just tried the MMM-Charts module, but i even cannot get this to work with a sample JSON.
      i created a test.json and loaded it up to my NAS.

      [["2018-02-04",2490],["2018-02-05",2488]]
      

      in the MM config.js i used this config:

      {
                              module: 'MMM-Chart',
                              position: 'middle_center',
                              header: 'Tankvolumen',
                              config: {
                                      name: "test",
                                      url: "http://192.168.178.220/test.json",
                                      xaxisLabelTicks: true,
                                      maintainAspectRatio: false,
                                      graphLabel0: "Volumen",
                                      graphLineColor0: "rgba(200, 200, 200, 1)",
                                      graphTickColor0: "rgba(200, 200, 200, 0.8)",
                                      graphFillColor0: "rgba(200, 200, 200, 0.4)",
                                      xaxisTimeUnit: "hour",
                                      xaxisTimeFormatLabels: "HH:mm",
                              }
                      },
      

      and modified the custom.css as said in the readme like this:

      .test {
      	width: 1060px;
      	height: 180px;
      }
      

      But it just shows the header and a long line below.
      i am sure i don’t use the module the correct way. ^^

      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: MMM-Podcast don't show/load the latest video

      did you guys install the omxplayer correctly?

      check it like this:

      cd MagicMirror/modules/MMM-Podcast

      omxplayer -o hdmi video.mp4

      this should play the video.

      I am not using a header, so my module isn’t shown on the MM, too. I think that is correct.

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: show integer logs from python script as diagram in MM ?

      wow, thank u guys for your effort :)

      personally for me this project is not that easy, because i need to learn and understand several languages at the same time. So pls be patient ^^

      While u posted here i was able to create a JSON file from the mysql database. But the results were looking like this:

      [{"Datum":"2018-02-03T23:00:00.000Z","Volumen":2488},{"Datum":"2018-02-03T23:00:00.000Z","Volumen":2488},]
      

      thats probably because the columns in the database are defined as “date” (not datetime) and “decimal”
      I think i would get this right and could load this into the MMM-Chart.

      But now u guys posted several solutions. The easiest would be to create a CSV and log this directly with the MMM-Chart @ninjabreadman said.
      To create the CSV is no problem for me, but how changing the MMM-Chart… i need to pass a.t.m. ^^

      Actually i’m not sure how node.js and npm works so i need to read and try a little bit more to understand it better :)

      @doubleT
      How exactly would highcharts work together with the MM? Is it just like a web page or what? :D
      How to start it, where to put the files, and how to implement to MM?
      For me it looks nearly like an own module for the MM.

      Sorry for the much questions, but i am trying not just to use a finished solution. I want to nearly understand that whole stuff XD

      Thank you guys, u are great

      edit:
      So i changed the columns definition from “date” to “text”.
      Now my with the javascript using node i can get a JSON file looks correct:

      [{"Datum":"2018-02-04","Volumen":2490},{"Datum":"2018-02-04","Volumen":2488},]
      

      but i am using a very very simple script i think and i am just able to execute it manually by typing in terminal “node script.js”
      also i don’t know in what direction this has to be saved.

      var mysql      = require('mysql');
      var fs = require('fs');
      var connection = mysql.createConnection({
        host: 'xxx.xxx.xxx.xxx',
        port: '3307',
        user: '...',
        password: '...',
        database: 'Tank'
      });
      
      connection.connect();
      
      connection.query('SELECT * from Volumen', function(err, results, fields) {
          if(err) throw err;
      
          fs.writeFile('results.json', JSON.stringify(results), function (err) {
            if (err) throw err;
            console.log('Saved!');
          });
      });
      
      connection.end();
      
      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: show integer logs from python script as diagram in MM ?

      @ninjabreadman said in show integer logs from python script as diagram in MM ?:

      create a route to output a JSON file

      alright, that sound makable for me i think. ^^Will take a look. Thank you

      edit: ehm…first question :D

      i installed this now (seems to be newer). But where to start? Where i need to create the file, and what type of file, and how will it be loaded?
      Is it a javascript file, which must be saved somewhere in the node directory?

      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: show integer logs from python script as diagram in MM ?

      so i actually edited my python script, so that the results will be automatically loaded up to my MySQL Database on the Synology NAS.

      With PHP i can show the Data as a diagram :)
      So now i could use an iFrame module.
      So far so good ^^ (never thought i get this working)

      next days i will take a look at the MMM-Chart Module and the OpenHAB solution. (or a other that maybe works with MySQL)

      For those, who are interested so far:

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      
      # import required modules
      import time
      import datetime
      import RPi.GPIO as GPIO
      import os
      import ftplib
      import mysql
      import mysql.connector
      
      GPIO.setwarnings(False)
      
      # define server data
      # ftpserver = "..."  //optional, when needed uncomment the FTP-Upload further down
      # ftpuser = "..."
      # ftppassword = "..."
      # ftppath = "/web"
      
      sqlhost = "..."
      sqlport = "..."
      sqluser = "..."
      sqlpassword = "..."
      sqldb = "Tank"
      
      # define GPIO pins
      GPIOTrigger = 18
      GPIOEcho    = 24
      
      # function to measure the distance
      def MeasureDistance():
        # set trigger to high
        time.sleep(0.2)
        GPIO.output(GPIOTrigger, True)
      
        # set trigger after 10µs to low
        time.sleep(0.0001)
        GPIO.output(GPIOTrigger, False)
      
        # store initial start time
        StartTime = time.time()
      
        # store start time
        while GPIO.input(GPIOEcho) == 0:
          StartTime = time.time()
      
        # store stop time
        while GPIO.input(GPIOEcho) == 1:
          StopTime = time.time()
      
        # calculate distance
        TimeElapsed = StopTime - StartTime
        Distance = (TimeElapsed * 34400) / 2
        
        return Distance
      
      print("Messe Volumen...")
      
      # main function
      def main():
        try:
      #    while True:
            Distance0 = MeasureDistance()
            Distance01 = MeasureDistance()
            Distance02 = MeasureDistance()
            Distance03 = MeasureDistance()
            Distance04 = MeasureDistance()
            Distance05 = MeasureDistance()
            Distance06 = MeasureDistance()
            Distance07 = MeasureDistance()
            Distance08 = MeasureDistance()
            Distance09 = MeasureDistance()
            Distance10 = MeasureDistance()
            Distance11 = MeasureDistance()
            Distance12 = MeasureDistance()
            Distance13 = MeasureDistance()
            Distance14 = MeasureDistance()
            Distance15 = MeasureDistance()
            Distance16 = MeasureDistance()
            Distance17 = MeasureDistance()
            Distance18 = MeasureDistance()
            Distance19 = MeasureDistance()
            Distance20 = MeasureDistance()
            Distance_sum = Distance01 + Distance02 + Distance03 + Distance04 + Distance05 + Distance06 + Distance07 + Distance08 + Distance09 + Distance10 + Distance11 + Distance12 + Distance13 + Distance14 + Distance15 + Distance16 + Distance17 + Distance18 + Distance19 + Distance20
            Distance = round(Distance_sum / 20,1)
      #    Meine Tanks haben Maximal 3.200 Liter bei 150 cm Füllhöhe
      #    Zusätzlich 9 cm Offset vom Einbauort des Sensors; 
            Fuelstand = 150 - Distance
            Liter = 3200 / 141 * Fuelstand
            Zeit = time.time()
            ZeitStempel = datetime.datetime.fromtimestamp(Zeit).strftime('%Y-%m-%d_%H:%M:%S')
            print (ZeitStempel),("Entfernung: %.1f cm" % Distance),(" Fuelhoehe: %.1f cm" % Fuelstand),(" Liter: %.0f l" % Liter)
            time.sleep(.1)
      
            Auslesezeitpunkt = datetime.datetime.fromtimestamp(Zeit).strftime('%d-%m-%Y_%H:%M:%S')
            Tag = datetime.datetime.fromtimestamp(Zeit).strftime('%Y-%m-%d')
            Uhr = datetime.datetime.fromtimestamp(Zeit).strftime('%H:%M:%S')
      
      	# schreibe Langzeitmessung in *.csv Datei
            file = open("longtimelog.csv", "a")
            file.write(str(Tag))
            file.write(", ")
            file.write(str(Liter))
            file.write("\n")
            file.close()
      
              # schreibe aktuelle Messung in *.csv Datei
            file = open("log.csv", "w")
            file.write(str(Tag))
            file.write(", ")
            file.write(str(Liter))
            file.write("\n")
            file.close()
      
            print("Logs aktualisiert")
            time.sleep(.1)
            print("Upload Logs auf FTP...")
      
              # Lädt die longtimelog.csv Datei auf das NAS
      #      filename = "longtimelog.csv"
      #      ftp = ftplib.FTP(ftpserver)
      #      ftp.login(ftpuser, ftppassword)
      #      ftp.cwd(ftppath)
      #      os.chdir(r"/home/pi")
      #      myfile = open("longtimelog.csv", 'r')
      #      ftp.storlines('STOR ' + "longtimelog.csv", myfile)
      #      myfile.close()
      
              # Lädt die log.csv Datei auf das NAS
      #      filename = "log.csv"
      #      ftp = ftplib.FTP(ftpserver)
      #      ftp.login(ftpuser, ftppassword)
      #      ftp.cwd(ftppath)
      #      os.chdir(r"/home/pi")
      #      myfile = open("log.csv", 'r')
      #      ftp.storlines('STOR ' + "log.csv", myfile)
      #      myfile.close()
      
            time.sleep(.1)
      
            print("Verbinde mit MySQL-Datenbank...")
      
            time.sleep(.1)
      
            try:
                connection = mysql.connector.connect(host = sqlhost, port = sqlport, user = sqluser, passwd = sqlpassword, db = sqldb)
            except:
                print "Keine Verbindung zum MySQL-Server"
                exit(0)
      
            cursor = connection.cursor()
            cursor.execute("INSERT INTO Volumen VALUES (%s,%s)", (Tag,Liter,))
            cursor.close()
            connection.commit()
      
            time.sleep(.1)
      
            print("Upload erfolgreich")
      
        # reset GPIO settings if user pressed Ctrl+C
        except KeyboardInterrupt:
          print("Measurement stopped by user")
          GPIO.cleanup()
      
      if __name__ == '__main__':
        # use GPIO pin numbering convention
        GPIO.setmode(GPIO.BCM)
      
        # set up GPIO pins
        GPIO.setup(GPIOTrigger, GPIO.OUT)
        GPIO.setup(GPIOEcho, GPIO.IN)
      
        # set trigger to false
        GPIO.output(GPIOTrigger, False)
      
        # call main function
        main()
      
      
      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: Trying to use MMM-MyCommute, config.js doesn't look right

      @deerbelac said in Trying to use MMM-MyCommute, config.js doesn’t look right:

      You’re my new best internet friend.

      LOL

      you are welcome mate ;)

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: Temperature regulated fan on RPI

      @Peter

      why not just using a python script?

      found this one here:

      #!/usr/bin/env python3
      # coding: utf-8
      
      import os
      import time
      import signal
      import sys
      import RPi.GPIO as GPIO
      pin = 36 # The pin ID, edit here to change it
      maxTMP = 50 # The maximum temperature in Celsius after which we trigger the fan
      GPIO.setmode (GPIO.BOARD)
      
      def setup():
          GPIO.setmode(GPIO.BOARD)
          GPIO.setup(pin,GPIO.OUT)
          GPIO.setwarnings(False)
          return()
      def getCPUtemperature():
          res = os.popen('vcgencmd measure_temp').readline()
          temp =(res.replace("temp=","").replace("'C\n",""))
          print("temp is {0}".format(temp)) #Uncomment here for testing
          return temp
      def fanON():
          setPin(True)
          return()
      def fanOFF():
          setPin(False)
          return()
      def getTEMP():
          CPU_temp = float(getCPUtemperature())
      
          if CPU_temp>maxTMP:
              fanON()
      
          else:
              fanOFF()
      
          return()
      def setPin(mode): # A little redundant function but useful if you want to add logging
          GPIO.output(pin, mode)
          return()
      try:
          setup()
          while True:
              getTEMP()
              time. sleep(8) # Read the temperature every 5 sec, increase or decrease this limit if you want
      except KeyboardInterrupt: # trap a CTRL+C keyboard interrupt
      	GPIO.cleanup()
      
      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: MMM-PIR-Sensor: Everything works fine, just one thing not...

      one idea is to just put the tvservice -o command in your rc.local.
      before that u should do a little sleep.

      like this:

      sudo nano /etc/rc.local

      #!/bin/sh -e
      #
      # rc.local
      #
      # This script is executed at the end of each multiuser runlevel.
      # Make sure that the script will "exit 0" on success or any other
      # value on error.
      #
      # In order to enable or disable this script just change the execution
      # bits.
      #
      # By default this script does nothing.
      
      # Print the IP address
      _IP=$(hostname -I) || true
      if [ "$_IP" ]; then
        printf "My IP address is %s\n" "$_IP"
      fi
      
      sleep 60 &
      
      tvservice -o
      
      exit 0
      

      So on every reboot it will wait 60 seconds (just to let everything start like MM) and then turn the monitor off.

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: Trying to use MMM-MyCommute, config.js doesn't look right

      There are some ``` in your clock module.

      in your MyCommute u use the wrong " " (try to use another editor in future)

      no comma , behind the apikey

      in the normal calendar module there is no comma , behind the URL

      missing semicolon in last line

      So try this:

      /* Magic Mirror Config Sample
       *
       * By Michael Teeuw http://michaelteeuw.nl
       * MIT Licensed.
       *
       * For more information how you can configurate this file
       * See https://github.com/MichMich/MagicMirror#configuration
       *
       */
      
      var config = {
              address: "localhost", // Address to listen on, can be:
                                    // - "localhost", "127.0.0.1", "::1" to listen on loopback interface
                                    // - another specific IPv4/6 to listen on a specific interface
                                    // - "", "0.0.0.0", "::" to listen on any interface
                                    // Default, when address config is left out, is "localhost"
              port: 8080,
              ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
                                                                     // or add a specific IPv4 of REDACTED :
                                                                     // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
                                                                     // or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
                                                                     // ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
      
              language: "en",
              timeFormat: 12,
              units: "metric",
      
              modules: [
                      {
                              module: "alert",
                      },
                      {
                              module: "updatenotification",
                              position: "top_bar"
                      },
                      {
                              module: "clock",
      
                              position: "top_left"
                      },
                      {
                              module: "calendar",
                              header: "Today",
                              position: "top_left",
                              config: {
                                      maximumEntries: 5,
                                      calendars: [
                                              {
                                                      symbol: "calendar",
                                                      url: "calendarURL",
                                                      auth:{
                                                              user: "username",
                                                              pass: "secretpassword",
                                                              method: "basic"
                                                      }
                                              },
                                      ],
                              }
                      },
                      {
                              module: "MMM-WunderGround",
                              position: "top_right",
                              config: {
                                      apikey: "secretAPI",
                                      pws: "weatherstationID",
                                      units: "imperial",
                                      hourly: "1",
                                      fctext: "1",
                                      coloricon: "true",
                                      fcdaycount: "1",
                                      hourlyinterval: "3",
                                      hourlycount: "2",
                                      alerttime: "10000",
                                      roundTmpDecs: 0,
                                      layout: "vertical"
                                      }
                      },
                      {
                              module: "MMM-DailyBibleVerse",
                              position: "bottom_bar",
                              config: {
                                      feeds: [
                                              {
                                                      version: "ESV"
                                              }
                                      ],
                              },
                      },
                      {
                              module: "MMM-MyCommute",
                              position: "bottom_left",
                              header: "My Drive",
                              config: {
                                      apikey: "AIzaSyBfJfAgexEpef8VbtTEv6XfyiYTx-4QAge8",
                                      origin: "123 My Street, My City, ST 12345",
                                      startTime: "20:00",
                                      endTime: "22:00",
                                      hideDays: [0,6],
                                      destinations: [
                                              {
                                                      destination: "456 Work Address, City, State ZIP",
                                                      label: "work",
                                                      mode: "driving",
                                              },
                                      ],
                              },
                      },
      //              {
      //                      module: 'MMM-Xmas',
      //                      position: 'fullscreen_above'
      //              }
              ]
      
      };
      
      /*************** DO NOT EDIT THE LINE BELOW ***************/
      if (typeof module !== "undefined") {module.exports = config;}
      

      if u run into this problem again, try www.jshint.com ;)

      or use ssh and do this: https://forum.magicmirror.builders/topic/5399/how-to-check-your-config-for-errors-for-absolute-beginners

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: MagicMirror and Domoticz

      change the port of domoticz or MM. I think they are using both 8080

      posted in Troubleshooting
      cruunnerrC
      cruunnerr
    • RE: show integer logs from python script as diagram in MM ?

      @tbbear

      since u wrote the brilliant Openhab module this would really be a good option :)
      I will keep that in mind.

      @doubleT
      i will take a look at it. looks great. But i am sure i will have questions :D

      edit:

      i also found this: https://forum.magicmirror.builders/topic/2470/mmm-chart-view-your-graphs-on-your-mirror

      But what is meant by “JSON data source”? is it just a *.js file with text in it? And is that the only file needed to use this module? i am still looking. ^^

      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: Speaker for the Raspberry Pi3

      Well, i just ordered these two:

      https://www.amazon.de/Trust-Lautsprecher-USB-Stromversorgung-Smartphone-schwarz/dp/B00JRW0M32/ref=sr_1_9?s=computers&ie=UTF8&qid=1517545229&sr=1-9&keywords=pc+lautsprecher

      https://www.amazon.de/gp/product/B012W70XH8/ref=oh_aui_detailpage_o02_s00?ie=UTF8&psc=1

      I removed the speaker from it’s body and screw big holes in my mirror. The speaker also got a physical volume control. Not really good to hear music, but for alexa and the podcast module it will be absolutely enough.

      The Audio adapter works out of the box for microphone. To enable speaker port u need to select it in raspberry as standard port.

      posted in Hardware
      cruunnerrC
      cruunnerr
    • show integer logs from python script as diagram in MM ?

      Hey guys,

      i am trying again to get a new feature to my MM ^^

      Background Story:

      I finally installed a second Raspberry Pi on my heat oil tank for measuring the tank level.
      Therefore i am using a HC-SR04 and a python script i found in the web.
      As the script just showed the actual measurement in the console, i modified it to write the logs in a *.txt and a *.html file.
      The script will be executed once a day via crontab.

      The index.html will be completely overwritten every time the script will be executed. Then the file will be uploaded to my NAS.
      Actually i am using an iFrame module in the MM to show the result. This was just for trying it out :)

      The *.txt file is doing the longtime log of the results. At the moment it writes a time stamp and the result at the end of the file.
      For future measurements i could also just print the result (in the script it is “Liter”).

      Question:

      My aim is to show the longtime logs in a diagram on the MM. Probably this is just possible with html and an iFrame module, right or not?
      It should look like this, just in MM-style:
      https://forum-raspberrypi.de/attachment/5997-monatsansicht-03-jpg/

      or this: https://www.raspberrypi.org/forums/viewtopic.php?t=83808

      If so, could someone help me find a good solution? Because writing html with python isn’t that easy^^
      And I master neither python nor html

      Here comes the tank.py:

      #!/usr/bin/env python
      # -*- coding: utf-8 -*-
      
      # import required modules
      import time
      import datetime
      import RPi.GPIO as GPIO
      import os
      import ftplib
      
      GPIO.setwarnings(False)
      
      print("Fair volume...")
      
      # define GPIO pins
      GPIOTrigger = 18
      GPIOEcho    = 24
      
      # function to measure the distance
      def MeasureDistance():
        # set trigger to high
        time.sleep(0.2)
        GPIO.output(GPIOTrigger, True)
      
        # set trigger after 10µs to low
        time.sleep(0.0001)
        GPIO.output(GPIOTrigger, False)
      
        # store initial start time
        StartTime = time.time()
      
        # store start time
        while GPIO.input(GPIOEcho) == 0:
          StartTime = time.time()
      
        # store stop time
        while GPIO.input(GPIOEcho) == 1:
          StopTime = time.time()
      
        # calculate distance
        TimeElapsed = StopTime - StartTime
        Distance = (TimeElapsed * 34400) / 2
        
        return Distance
      
      # main function
      def main():
        try:
      #    while True:
            Distance0 = MeasureDistance()
            Distance01 = MeasureDistance()
            Distance02 = MeasureDistance()
            Distance03 = MeasureDistance()
            Distance04 = MeasureDistance()
            Distance05 = MeasureDistance()
            Distance06 = MeasureDistance()
            Distance07 = MeasureDistance()
            Distance08 = MeasureDistance()
            Distance09 = MeasureDistance()
            Distance10 = MeasureDistance()
            Distance11 = MeasureDistance()
            Distance12 = MeasureDistance()
            Distance13 = MeasureDistance()
            Distance14 = MeasureDistance()
            Distance15 = MeasureDistance()
            Distance16 = MeasureDistance()
            Distance17 = MeasureDistance()
            Distance18 = MeasureDistance()
            Distance19 = MeasureDistance()
            Distance20 = MeasureDistance()
            Distance_sum = Distance01 + Distance02 + Distance03 + Distance04 + Distance05 + Distance06 + Distance07 + Distance08 + Distance09 + Distance10 + Distance11 + Distance12 + Distance13 + Distance14 + Distance15 + Distance16 + Distance17 + Distance18 + Distance19 + Distance20
            Distance = round(Distance_sum / 20,1)
      #    Meine Tanks haben Maximal 3.200 Liter bei 150 cm Füllhöhe
      #    Zusätzlich 9 cm Offset vom Einbauort des Sensors; 
            Fuelstand = 150 - Distance
            Liter = 3200 / 141 * Fuelstand
            Zeit = time.time()
            ZeitStempel = datetime.datetime.fromtimestamp(Zeit).strftime('%Y-%m-%d_%H:%M:%S')
            print (ZeitStempel),("Entfernung: %.1f cm" % Distance),(" Fuelhoehe: %.1f cm" % Fuelstand),(" Liter: %.0f l" % Liter)
            time.sleep(1)
      
            Auslesezeitpunkt = datetime.datetime.fromtimestamp(Zeit).strftime('%d.%m.%Y um %H:%M:%S Uhr')
      
      	# write result in *.txt file (add to last line)
            file = open("longtimelog.txt", "a")
            file.write(str(Auslesezeitpunkt))
            file.write(":\n")
            file.write("Ölstand = ")
            file.write(str(Liter))
            file.write("\n\n")
            file.close()
      
      	# write result to *.html file (will be overwritten)
            file = open("index.html", "w")
            file.write("<p></p>")
            file.write(str(Auslesezeitpunkt))
            file.write(":<p>")
            file.write("Oelstand = ")
            file.write(str(Liter))
            file.write("</p>")
            file.write("<p></p><p></p><p></p>")
            file.close()
      
            print("Logs updated")
            time.sleep(1)
            print("Upload actual log...")
      
      	# Lädt die index.html Datei auf das NAS
            filename = "index.html"
            ftp = ftplib.FTP("192.168.178.220")
            ftp.login("USER_NAME", "PASSWORD")
            ftp.cwd("/web")
            os.chdir(r"/home/pi")
            myfile = open("index.html", 'r')
            ftp.storlines('STOR ' + "index.html", myfile)
            myfile.close()
      
            time.sleep(1)
      
            print("Upload done")
      
        # reset GPIO settings if user pressed Ctrl+C
        except KeyboardInterrupt:
          print("Measurement stopped by user")
          GPIO.cleanup()
      
      if __name__ == '__main__':
        # use GPIO pin numbering convention
        GPIO.setmode(GPIO.BCM)
      
        # set up GPIO pins
        GPIO.setup(GPIOTrigger, GPIO.OUT)
        GPIO.setup(GPIOEcho, GPIO.IN)
      
        # set trigger to false
        GPIO.output(GPIOTrigger, False)
      
        # call main function
        main()
      
      

      Even this thought is not makable i would like to thank you guys ahead ;)

      edit:

      oh, and i found this here, but i don’t know if this would help.

      posted in Requests
      cruunnerrC
      cruunnerr
    • RE: {HowTo} turn on/off your monitor (Time based, PIR/Button, App)

      again one step closer :D

      put in the content and save with “ctrl+x” and “y”

      try everything agin and report if u got trouble again :)

      edit:

      oh sorry. Aren’t we using “screen_on/off”?? :D

      so try

      sh screen_off.sh should show a black screen (not turning HDMI off)
      sh screen_on.sh should disable the black screen.

      posted in Tutorials
      cruunnerrC
      cruunnerr
    • RE: {HowTo} turn on/off your monitor (Time based, PIR/Button, App)

      try the shell scripts without the python script.

      sh monitor_off.sh should show a black screen (not turning HDMI off)
      sh monitor_on.sh should disable the black screen.

      if this is working for u, then your pir.py script seems not being correct.

      the chmod +x step is necessary for the python script execute the shell scripts.

      But first try the commands above. If this doesn’t work, then i have to think about and search for a solution.
      But i tried it just a few seconds ago, and it works fine here

      posted in Tutorials
      cruunnerrC
      cruunnerr
    • RE: {HowTo} turn on/off your monitor (Time based, PIR/Button, App)

      :)

      thank you very much ^^

      I am very glad u found out what went wrong. :)
      So now u should be able to use the “screen_on/off” files instead of the monitor_onoff

      Just try out :)

      posted in Tutorials
      cruunnerrC
      cruunnerr
    • RE: {HowTo} turn on/off your monitor (Time based, PIR/Button, App)

      then u probably connected it wrong and the gpio which is used in the script is set to high (1). u can check this…

      type gpio readall to see the GPIO Breakout.

      pi@MagicMirror_Test:~ $ gpio readall
       +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
       | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
       +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
       |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
       |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
       |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
       |   4 |   7 | GPIO. 7 |   IN | 1 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
       |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
       |  17 |   0 | GPIO. 0 |  OUT | 1 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
       |  27 |   2 | GPIO. 2 |  OUT | 1 | 13 || 14 |   |      | 0v      |     |     |
       |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
       |     |     |    3.3v |      |   | 17 || 18 | 1 | IN   | GPIO. 5 | 5   | 24  |
       |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
       |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
       |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 1 | IN   | CE0     | 10  | 8   |
       |     |     |      0v |      |   | 25 || 26 | 1 | IN   | CE1     | 11  | 7   |
       |   0 |  30 |   SDA.0 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.0   | 31  | 1   |
       |   5 |  21 | GPIO.21 |   IN | 1 | 29 || 30 |   |      | 0v      |     |     |
       |   6 |  22 | GPIO.22 |   IN | 1 | 31 || 32 | 0 | IN   | GPIO.26 | 26  | 12  |
       |  13 |  23 | GPIO.23 |   IN | 0 | 33 || 34 |   |      | 0v      |     |     |
       |  19 |  24 | GPIO.24 |   IN | 0 | 35 || 36 | 0 | IN   | GPIO.27 | 27  | 16  |
       |  26 |  25 | GPIO.25 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO.28 | 28  | 20  |
       |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO.29 | 29  | 21  |
       +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
       | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
       +-----+-----+---------+------+---+---Pi 2---+---+------+---------+-----+-----+
      

      In the script the BCM pin 22 is used for the PIR. This is GPIO 3 and physically it is pin 15.

      Please check if your pir is connected correctly.

      Edit:

      Oh, and take a look at your PIR. u can set the delay time from 0.3seconds up to 5 minutes. Maybe its set very high.
      For using the soloutions of this tutorial the PIR adjust time should be set very low, as u can set the time within the script :)
      https://www.mpja.com/download/31227sc.pdf

      posted in Tutorials
      cruunnerrC
      cruunnerr
    • 1 / 1