PatriceG / MMM-MPR121

a MagicMirror² Module based on MMM-Buttons to use a MPR121 touch-button controller instead of push-buttons
5 stars 2 forks source link

MagicMirror remains Black #3

Open fredall opened 6 years ago

fredall commented 6 years ago

Hi I have installed the MMM-MPR121 Module on my magic mirror and have copy pasted the example config to my config.js file but when I restart the mirror remains back. As soon as I comment "//" the MPR121 related config in config.js the mirror is working fine again. I can't find the error.

following is my config.js section related to MPR121: // { // module: 'MMM-MPR121', // config: { // buttons: [ // { // pin: 0, // name: "monitor_control", // longPress: { // notification: "REMOTE_ACTION", // payload: {action: "MONITOROFF"} // }, // shortPress: { // notification: "REMOTE_ACTION", // payload: {action: "MONITORON"} // } // }, // { // pin: 1, // name: "power", // longPress: { // title: "Power off", // message: "Keep pressed for 3 sec$ // imageFA: "power-off", // notification: "REMOTE_ACTION", // payload: {action: "SHUTDOWN"} // }, // shortPress: undefined // } // ] // } // },

I followed the installation guide for MMM-MPR121 module. I am using 12 keys MPR121 board from adafruit. I installed the mpr-121 controller as descibed in Adafruit. The module is working as tests as explained here is showing touch buttons are working perfectly: https://learn.adafruit.com/mpr121-capacitive-touch-sensor-on-raspberry-pi-and-beaglebone-black/usage

fredall commented 6 years ago

some additional information. I got folowing warning after running "npm install" for MMM-MPR121

i@raspberrypi:~/MagicMirror/modules/MMM-MPR121 $ sudo npm install npm WARN prefer global node-gyp@3.6.2 should be installed with -g

i2c-bus@1.2.5 install /home/pi/MagicMirror/modules/MMM-MPR121/node_modules/i2c- bus node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root /.node-gyp/6.12.3" gyp WARN EACCES attempting to reinstall using temporary dev dir "/home/pi/MagicMi rror/modules/MMM-MPR121/node_modules/i2c-bus/.node-gyp" make: Entering directory '/home/pi/MagicMirror/modules/MMM-MPR121/node_modules/i2 c-bus/build' CXX(target) Release/obj.target/i2c/src/i2c.o SOLINK_MODULE(target) Release/obj.target/i2c.node COPY Release/i2c.node make: Leaving directory '/home/pi/MagicMirror/modules/MMM-MPR121/node_modules/i2c -bus/build' npm WARN lifecycle Magic-Mirror-Module-MPR121@1.0.0~postinstall: cannot run in wd %s %s (wd=%s) Magic-Mirror-Module-MPR121@1.0.0 electron-rebuild -e ../../node_mo dules/electron /home/pi/MagicMirror/modules/MMM-MPR121

PatriceG commented 6 years ago

Hello, Depending on which user you're logged with on your Raspberry PI you should indeed run sudo npm -g install

This should fix your issues with permissions and install the required library correctly.

If the magicmirror remains black, check its log in ~/.pm2/logs The error log usually shows what's preventing the MagicMirror from starting up.

fredall commented 6 years ago

This did not work unfortunately. I now get errors:

sudo npm -g install

i2c-bus@1.2.5 install /usr/lib/node_modules/Magic-Mirror-Module-MPR121/node_modules/i2c-bus node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.13.1" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/Magic-Mirror-Module-MPR121/node_modules/i2c-bus/.node-gyp" make: Entering directory '/usr/lib/node_modules/Magic-Mirror-Module-MPR121/node_modules/i2c-bus/build' CXX(target) Release/obj.target/i2c/src/i2c.o SOLINK_MODULE(target) Release/obj.target/i2c.node COPY Release/i2c.node make: Leaving directory '/usr/lib/node_modules/Magic-Mirror-Module-MPR121/node_modules/i2c-bus/build'

Magic-Mirror-Module-MPR121@1.0.0 postinstall /usr/lib/node_modules/Magic-Mirror-Module-MPR121 electron-rebuild -e ../../node_modules/electron

sh: 1: electron-rebuild: not found npm ERR! Linux 4.9.35-v7+ npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "-g" "install" npm ERR! node v6.13.1 npm ERR! npm v3.10.10 npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn

npm ERR! Magic-Mirror-Module-MPR121@1.0.0 postinstall: electron-rebuild -e ../../node_modules/electron npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the Magic-Mirror-Module-MPR121@1.0.0 postinstall script 'electron-rebuild -e ../../node_modules/electron'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the Magic-Mirror-Module-MPR121 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! electron-rebuild -e ../../node_modules/electron npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs Magic-Mirror-Module-MPR121 npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls Magic-Mirror-Module-MPR121 npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /home/pi/MagicMirror/modules/MMM-MPR121/npm-debug.log

I tried allready to uninstall MMM-MPR121 and have deleted the MMM-MPR121 directory. Redo the installation but get same error messages. Also updated with apt-get update and apt-get upgrade and error remains.

I did not find the .pm2 folder.

PatriceG commented 6 years ago

I'm no nodejs expert so I'm not sure I can help you. Maybe try not to install the module globally: sudo npm install I don't understand why the root user would not have the required permissions.

The .pm2 folder should be in your home dir type: cd ~ ls -a

And you should see a .pm2 folder

My MagicMirror installation is 1 year old and does not use the latest framework so it might be different with the latest one. I won't update mine since my mirror is working fine and I know there are breaking changes in the latest version (related to the webcam usage).

fredall commented 6 years ago

I have now update npm and node.js to latest version. I reran npm install and now get no more error messages.

But still black screen whenever I activate MMM-MPR121 in config.js I could find the .pm2 folder but have no clue where the error is comming from.

I'll stop for tonight.

PatriceG commented 6 years ago

Good. In the .pm2 folder you have the pm2.log file, which does not have much information but may be useful anyway when pm2 can't start the MagirMirror app for instance. The .pm2/logs folder contains the MagicMirror log files mm-error-0.log and mm-out-0.log When the Mirror won't start you will likely have the cause of the error in one of these log files. This happened a lot to me when I was configuring my mirror.

By the way, I think I found the cause of the problem. Your config is incorrect here, you typed a $ instead of a " to terminate the string and forgot the comma: // message: "Keep pressed for 3 sec$

should be // message: "Keep pressed for 3 sec",

When the mirror won't start I often copy and paste my config file into an online json validator to make sure its syntax is correct. And most of the startup errors I had were caused by missing commas or quotes :)

fredall commented 6 years ago

thx for the reply. Unfortunately the $ is not the error. this is just from the nano editor because my window was not large enough to display the whole line.

Thx for the hint on json validator. I did not know that exists.

fredall commented 6 years ago

Hi I got it solved by running "npm install --unsafe-perm"

PatriceG commented 6 years ago

Good. I've added a note to my readme.md page with this in case someone else runs into this issue. The json validator I often use is this one: https://jsonlint.com/

BTW, you may already know but I've shown my mirror on the forum, here: https://forum.magicmirror.builders/topic/2641/my-living-room-mirror