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

    Posts

    Recent Best Controversial
    • RE: PM2 auto start and python virtual environment not playing together

      @sdetweil Thanks! That worked. I added a line in mm.sh to connect to the virtual environment before launching mm.

      posted in Troubleshooting
      B
      Brown19
    • PM2 auto start and python virtual environment not playing together

      Hi, I use Tom Hirschberger’s MMM-Temperature to display temp and humidity from an adafruit sht31d. It has a dependency of the Adafruit CircuitPython Library. I’ve upgrade my pi to Bookworm. Python now runs in a virtual environment. I can activate the virtual environment and get everything to work if I launch MM2 in the virtual environment using npm start. It doesn’t work using PM2 start MagicMirror.
      I know you call call python without explicitly activating the environment but I’m not sure what changes need to be made to module.
      Maybe create a systemd unit file to run the the library at startup?
      Ideally, I want the same functionality back; my MM starts on boot and python works normally.
      Has anyone seen this or has a fix?

      Thanks!

      posted in Troubleshooting
      B
      Brown19
    • RE: MMM-Temperature uncaught exception...

      @wishmaster270 Thank you so much for the help and troubleshooting! I wasn’t able to work on this the last few days and when I got back it looks fixed.

      Thanks again.

      posted in Troubleshooting
      B
      Brown19
    • RE: MMM-Temperature uncaught exception...

      @wishmaster270 I’m running 2.24.0 and node is v18.17.0

      posted in Troubleshooting
      B
      Brown19
    • MMM-Temperature uncaught exception...

      I wrote a script to use the SHT31-D temperature and humidity sensor from adafruit. The script works in that it correctly displays the temp and humidity. The log file however shows the following:

      [02.08.2023 19:53.15.002] [LOG] MMM-Temperature: Updating sensor values
      [02.08.2023 19:53.15.002] [LOG] MMM-Temperature Calling: /home/mpi-admin/MagicMirror/modules/MMM-Temperature/scripts/sht31
      [02.08.2023 19:53.15.338] [LOG] {“temperature_c”:24.78637369344625,“humidity”:42.03402761882963,“temperature_f”:76.61547264820325,“error”:false}
      [02.08.2023 19:53.15.339] [LOG] MMM-Temperature: New Values of sensor with id 0 (Indoor): {“temperature_c”:“24.8”,“humidity”:“42.0”,“temperature_f”:“76.6”,“error”:false,“temperature”:“76.6”}
      [02.08.2023 19:53.15.339] [LOG] Sending temp update: [{“temperature_c”:“24.8”,“humidity”:“42.0”,“temperature_f”:“76.6”,“error”:false,“temperature”:“76.6”}]
      [02.08.2023 19:53.15.346] [ERROR] Whoops! There was an uncaught exception…
      [02.08.2023 19:53.15.362] [ERROR] Error: write EFAULT
      at afterWriteDispatched (node:internal/stream_base_commons:160:15)
      at writeGeneric (node:internal/stream_base_commons:151:3)
      at Socket._writeGeneric (node:net:930:11)
      at Socket._write (node:net:942:8)
      at writeOrBuffer (node:internal/streams/writable:392:12)
      at _write (node:internal/streams/writable:333:10)
      at Writable.write (node:internal/streams/writable:337:10)
      at execSync (node:child_process:981:20)
      at node:electron/js2c/asar_bundle:2:12711
      at Class.updateSensorValues (/home/mpi-admin/MagicMirror/modules/MMM-Temperature/node_helper.js:65:24)
      at Class.socketNotificationReceived (/home/mpi-admin/MagicMirror/modules/MMM-Temperature/node_helper.js:165:12)
      at Socket. (/home/mpi-admin/MagicMirror/js/node_helper.js:104:11)
      at Socket.emit (node:events:513:28)
      at Socket.emitUntyped (/home/mpi-admin/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22)
      at /home/mpi-admin/MagicMirror/node_modules/socket.io/dist/socket.js:703:39
      at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
      errno: -14,
      code: ‘EFAULT’,
      syscall: ‘write’
      }

      This is my script:

      #!/usr/bin/env python3
      #Install Dependencies:
      #  cd ~
      #  sudo pip3 install --upgrade adafruit-python-shell
      #  wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/raspi-blinka.py
      #  sudo python3 raspi-blinka.py
      #  sudo pip3 install adafruit-circuitpython-sht31d
      #  
      
      import board
      import adafruit_sht31d
      import json
      
      i2c = board.I2C()
      h = adafruit_sht31d.SHT31D(i2c)
      
      result = {}
      try:    
          result["temperature_c"] = h.temperature
          result["humidity"] = h.relative_humidity
          result["temperature_f"] = (result["temperature_c"]*1.8) + 32
          result["error"] = False
      except:
          result["temperature_c"] = 0.0
          result["humidity"] = 0.0
          result["temperature_f"] = (result["temperature_c"]*1.8) + 32
          result["error"] = True
      
      print(json.dumps(result))
      

      Any help would be appreciate. Python is not my native language.

      posted in Troubleshooting
      B
      Brown19
    • 1 / 1