• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-ArduPort

Scheduled Pinned Locked Moved Troubleshooting
14 Posts 3 Posters 2.1k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    Kereknjek
    last edited by Kereknjek Jan 7, 2020, 4:15 PM Jan 7, 2020, 3:47 PM

    I’m having trouble setting up MMM-ArduPort. So if anyone can help…

    I have to point out that I’m using SAME serial port on arduino for communication with raspberry and RS485 network. For transmiting and receiveing data on RS485 I use fantastic EasyTransfer arduino library.

    Posible problem:
    When arduino receives data from RS485, it gets to TX pin on USB side and never gets to raspberry. Wich is good.
    When arduino is sending data, to transmit over RS485, it first have to activate transmision mode on RS485 module.
    In this situation, data is being sent from arduino TX to RS485 RX. But it is allso sent to USB RX, and to raspberry. Wich is bad. I gues.

    Here are symptoms:
    MM starts and ArduPort is waiting for arduino.
    I connect arduino, ArduPort receives “[status:setup:starting]” and “[status:setup:started]”
    ArduPort shows my sensors list and then it removes them and returns to “Waiting for connection…”

    My arduino code sends “[status:setup:starting]”, waits for 3 seconds and sends “[status:setup:started]” witch is normaly received by Arduport.
    But! Arduino then sends request for sensors status to RS485 wich is allso transmited to raspberry. I think that in this moment it switches to “Waiting for connection”.

    But, again, I have modified MMM-ArduPort.js so it doesen’t disconnect (commented ), and I have aded “this.isArduinoStarting = false;” and “this.isArduinoStarted = true;” right after "case ‘sensor’: "
    I modified this so arduino always stays connected, and data should be displayed whenever and whatever sensor data is received. And it actualy does switch to listing my sensors, but, again, sensor data isn’t shown.

    I taught that EasyTransfer requests that get to PI are chrashing communication, but after my mod, I can see that data is passed normaly and is not affected by EasyTransfer part.
    I gues, that part is discarded at this part in arduino.py

    match = re.match(rgxData, data)
    if match:
                data = data[1:-1]
                case, name, value = data.split(":")
                to_node(case.lower(), {"name": name, "data": value})
    

    Here is photo of data being received on screen /dev/ttyUSB0 (yes… photo. I was in a hurry…)
    0_1578411025419_IMG_20200107_120847384 (Small).jpg

    Pictograms between [sensor:name:data] are EasyTransfer requests.

    I’ve even tryed this modification. It didn’t help.

    1 Reply Last reply Reply Quote 0
    • K Offline
      Kereknjek
      last edited by Kereknjek Jan 9, 2020, 10:44 AM Jan 9, 2020, 10:03 AM

      I have reinstaled all original files for arduport and started debuging… Again.:smiling_face_with_open_mouth_cold_sweat:

      I didn’t mention it before, but I’m running MM on Raspbian lite.
      I’ve found I had problems with python. Force reinstalling modules solved it.

      I have allso found some errors in arduino.py,
      Had to change:

      rgxData = re.compile("[\[][a-zA-Z0-9-].*[\:][a-zA-Z0-9-].*[\:][a-zA-Z0-9-.].*[\]]")
      

      to

      rgxData = re.compile("[\[][a-zA-Z0-9\-].*[\:][a-zA-Z0-9\-].*[\:][a-zA-Z0-9\-\.].*[\]]")
      

      and

      incoming = self.arduino.readline(self.arduino.in_waiting).decode('ascii').replace('\r', '').replace('\n', '')
      

      to

      incoming = self.arduino.readline(self.arduino.in_waiting).decode('ascii', errors="ignore").replace('\r', '').replace('\n', '')
      

      Now, when running

      python arduport.py
      

      I get this:

      {"debug": "SerialPort shell started..."}
      {"debug": "Waiting Ardunio to connect on port..."}
      {"status": {"data": "connected", "name": "connect"}}
      {"status": {"data": "starting", "name": "setup"}}
      {"status": {"data": "started", "name": "setup"}}
      {"sensor": {"data": "0.02", "name": "Baterija"}}
      {"sensor": {"data": "-0.00", "name": "Struja"}}
      {"sensor": {"data": "0.00", "name": "Solarno"}}
      {"sensor": {"data": "-0.12", "name": "Panel"}}
      {"sensor": {"data": "-0.00", "name": "Inverter"}}
      {"sensor": {"data": "0.04", "name": "Baterija"}}
      {"sensor": {"data": "-0.00", "name": "Struja"}}
      {"sensor": {"data": "0.00", "name": "Solarno"}}
      

      I’m guesing, this should be working now. But ArduPort is still stuck at “Waiting for connection…”

      Here is C/P from my config.js

                    {
                    module: "MMM-ArduPort",
                    position: "top_right",
                    header: "Solarni sustav",
                    config:{
                            portname: "/dev/ttyUSB0",
                            updateInterval: 1,
                            animationSpeed: 1000,
                            displayIcons: false,
                            showDescriptopn: true,
                            hideLoading: false,
                            hideWaiting: false,
                            useColors: false,
                            sensors: [
                                    {
                                    name: "Solarno",
                                    description: "Solarni sustav",
                                    maxValue: 5,
                                    maxFormat: "({0}) ",
                                    highestValue: 4,
                                    highestFormat: "({0}) Greska - pregrijavanje",
                                    highValue: 3,
                                    highFormat: "({0}) Greska - preopterecenje",
                                    lowValue: 2,
                                    lowFormat: "({0}) Backup mod",
                                    lowestValue: 1,
                                    lowestFormat: "({0}) Ukljuceno",
                                    minValue: 0,
                                    minFormat: "({0}) Iskljuceno"
                                    },
                                    {
                                    name: "Baterija",
                                    description: "Stanje baterije",
                                    maxValue: 26,
                                    maxFormat: "({0} V) Balansiranje",
                                    highestValue: 25.5,
                                    highestFormat: "({0} V) 100%",
                                    highValue: 24.87,
                                    highFormat: "({0} V) 75%",
                                    lowValue: 24.2,
                                    lowFormat: "({0} V) 50%",
                                    lowestValue: 11.74,
                                    lowestFormat: "({0} V) 25%",
                                    minValue: 23.2,
                                    minFormat: "({0} V) 0%"
                                    },
                                    {
                                    name: "Struja",
                                    description: "Punjenje ili praznjenje",
                                    maxValue: 20,
                                    maxFormat: "({0} A) Punjenje",
                                    highestValue: 10,
                                    highestFormat: "({0} A) Punjenje",
                                    highValue: 0,
                                    highFormat: "({0} A) ",
                                    lowValue: -20,
                                    lowFormat: "({0} A) Praznjenje",
                                    lowestValue: -40,
                                    lowestFormat: "({0} A) Brzo preznjenje",
                                    minValue: -60,
                                    minFormat: "({0} A) PREOPTERECENJE"
                                    },
                                    {
                                    name: "Panel",
                                    description: "Snaga solarnih panela",
                                    maxValue: 500,
                                    maxFormat: "({0} W)",
                                    highestValue: 400,
                                    highestFormat: "({0} W)",
                                    highValue: 300,
                                    highFormat: "({0} W)",
                                    lowValue: 200,
                                    lowFormat: "({0} W)",
                                    lowestValue: 100,
                                    lowestFormat: "({0} W)",
                                    minValue: 0,
                                    minFormat: "({0} W)"
                                    },
                                    {
                                    name: "Inverter",
                                    description: "Potrosnja invertera",
                                    maxValue: 1000,
                                    maxFormat: "({0} W)",
                                    highestValue: 800,
                                    highestFormat: "({0} W)",
                                    highValue: 600,
                                    highFormat: "({0} W)",
                                    lowValue: 400,
                                    lowFormat: "({0} W)",
                                    lowestValue: 200,
                                    lowestFormat: "({0} W)",
                                    minValue: 0,
                                    minFormat: "({0} W)"
                                    }
                                    ]
                            }
                    },
      

      EDIT:

      Here is C/P from chrome console:

      Starting module: MMM-ArduPort
      MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: status
      MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: {
          "action": "status",
          "name": "initialized"
      }
      MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: error
      MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: "pyshell-throw"
      MMM-ArduPort.js:123 [socketNotificationReceived::error]:
      
      S K 2 Replies Last reply Jan 9, 2020, 2:08 PM Reply Quote 0
      • S Offline
        sdetweil @Kereknjek
        last edited by Jan 9, 2020, 2:08 PM

        @Kereknjek said in MMM-ArduPort:

        MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: error
        MMM-ArduPort.js:286 [MMM-ArduPort]:: MMM-ArduPort: “pyshell-throw”
        MMM-ArduPort.js:123 [socketNotificationReceived::error]:

        yes, according to the code, this notifies the module that the python script running in the background ended, unexpectedly.

        I would try running it from the commandshell in the foreground without the MM and see what is going on

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • K Offline
          Kereknjek
          last edited by Jan 9, 2020, 9:55 PM

          How do I do that?

          S 1 Reply Last reply Jan 19, 2020, 1:09 PM Reply Quote 0
          • K Offline
            Kereknjek
            last edited by Jan 19, 2020, 11:52 AM

            It seems I’m having isues with Python.

            I have reinstaled Python and Python3, npm, python-shell and node js. Nothing worked. It was sending errors even with blank arduino, arduino sending only “starting” and “started” commands…
            So, due to my lack of knowlege of Python or anything else surrounding ArduPort, I’m abandoning it…

            To bad. It is very elagant module.

            1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @Kereknjek
              last edited by Jan 19, 2020, 1:09 PM

              @Kereknjek said in MMM-ArduPort:

              How do I do that?

              on the pi, ctrl-alt-t, will open a terminal window, you can also ssh into the pi

              then execute the command that the module would use

              python .......  whatever
              

              I see u dropped this path, but for other…

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • K Offline
                Kereknjek @Kereknjek
                last edited by Kereknjek Jan 19, 2020, 4:20 PM Jan 19, 2020, 4:18 PM

                I tried that.

                @Kereknjek said in MMM-ArduPort:

                Now, when running

                python arduport.py
                

                I get this:

                {"debug": "SerialPort shell started..."}
                {"debug": "Waiting Ardunio to connect on port..."}
                {"status": {"data": "connected", "name": "connect"}}
                {"status": {"data": "starting", "name": "setup"}}
                {"status": {"data": "started", "name": "setup"}}
                {"sensor": {"data": "0.02", "name": "Baterija"}}
                {"sensor": {"data": "-0.00", "name": "Struja"}}
                {"sensor": {"data": "0.00", "name": "Solarno"}}
                {"sensor": {"data": "-0.12", "name": "Panel"}}
                {"sensor": {"data": "-0.00", "name": "Inverter"}}
                {"sensor": {"data": "0.04", "name": "Baterija"}}
                {"sensor": {"data": "-0.00", "name": "Struja"}}
                {"sensor": {"data": "0.00", "name": "Solarno"}}
                
                S 1 Reply Last reply Jan 19, 2020, 4:28 PM Reply Quote 0
                • S Offline
                  sdetweil @Kereknjek
                  last edited by Jan 19, 2020, 4:28 PM

                  @Kereknjek that looks good…

                  looks at the MMM-Arduino module, it shows debugging info on the developers window

                  ctrl-shift-i on the keyboard, select the tab labeled ‘console’

                  you can filter out other modules messages by putting part of the module name in the filter field

                  ardu

                  also, have to set developerMode:true in the module config.js section

                  		    if (self.config.developerMode) {
                  			      var date = new Date();
                  			      var time = date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
                  			      message = self.name + ": (" + self.data.index + ")(" + time + ") " + message;
                  		    } else { message = self.name + ": " + message; }
                  		    switch (type) {
                  			  case "error": Log.error(this.logPrefix + message); break;
                  			  case "warn": Log.warn(this.logPrefix + message); break;
                  			  case "info": Log.info(this.logPrefix + message); break;
                  			  case "dev": if (self.config.developerMode) { Log.log(this.logPrefix + message); } break;
                  			  default: Log.log(this.logPrefix + message);
                  		    }
                  

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    Crime
                    last edited by Sep 26, 2020, 3:27 PM

                    has anyone solved this problem?
                    I don’t understand anything at all in JS?
                    error text from console:

                    Uncaught (in promise) TypeError: "({0}) ".format is MMM-ArduPort.js:143 
                    not a function
                        at Class.formatValue (MMM-ArduPort.js:143)
                        at Class.getDom (MMM-ArduPort.js:250)
                        at main.js:111
                        at new Promise (<anonymous>)
                        at updateDom (main.js:110)
                        at Object.updateDom (main.js:542)
                        at Class.updateDom (module.js:357)
                        at Class.socketNotificationReceived (MMM-ArduPort.js:118)
                        at module.js:243
                        at r.<anonymous> (socketclient.js:39)
                    

                    1.jpg

                    help someone, I’ve been trying to run it for a long time !!!

                    S 1 Reply Last reply Sep 26, 2020, 3:48 PM Reply Quote 0
                    • S Offline
                      sdetweil @Crime
                      last edited by Sep 26, 2020, 3:48 PM

                      @Crime as I posted the other day, someone posted a fix in the issue for the module

                      u have to change some code

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      C 1 Reply Last reply Sep 26, 2020, 5:36 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy