Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Record printing temperature and humidity

    Scheduled Pinned Locked Moved Solved
    Gcode meta commands
    2
    5
    214
    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.
    • amimafeundefined
      amimafe
      last edited by

      Hi,

      I am trying to edit daemon.g to make a log of a DHT22 sensor among other data. (Re: while-loop to track temperature)
      I manage to create the .csv file but I always get the same error on line 5:

      Error: in file macro line 5 column 72: meta command: expected an expression

      I am missing some number between the []?
      I attach the code of my daemon.g:

      if !exists(global.logTemps)
          global logTemps = false
      
      while global.logTemps ==true && job.file.fileName != null
          echo >>{"0:/templog/templog.csv"} {state.time}^","^{sensors.analog[].dht22.lastReading}^","^{sensors.analog[].dht-humidity.lastReading}
          G4 S1
      

      Thanks!

      oliofundefined 1 Reply Last reply Reply Quote 0
      • oliofundefined
        oliof @amimafe
        last edited by

        @amimafe try 0 inside the square brackets

        <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

        amimafeundefined 1 Reply Last reply Reply Quote 0
        • amimafeundefined
          amimafe @oliof
          last edited by

          @oliof

          Thanks for your quick response.

          Daemon.g modified:

          if !exists(global.logTemps)
              global logTemps = false
          
          while global.logTemps ==true && job.file.fileName != null
              echo >>{"0:/templog/templog.csv"} {state.time}^","^{sensors.analog[0].dht22.lastReading}^","^{sensors.analog[0].dht-humidity.lastReading}
              G4 S1
          

          I get the following error:

          Error: in file macro line 5 column 57: meta command: reached null object before end of selector string

          oliofundefined 1 Reply Last reply Reply Quote 0
          • oliofundefined
            oliof @amimafe
            last edited by

            @amimafe I think you need to drop the .dht22

            <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

            amimafeundefined 1 Reply Last reply Reply Quote 0
            • amimafeundefined
              amimafe @oliof
              last edited by

              @oliof

              Gracias por tu ayuda. Me diste una pista de cual era el fallo y finalmente lo he podido solucionar. Era un error al indicar el número de sensor que quería.
              Revisé el archivo config.g y lo configuré correctamente.

              Declaración de los sensores en config.g:

              ;DHT Sensor on Temperature Daughterboard SPI CS1 pin
              M308 S10 P"0.spi.cs1" Y"dht22" A"Temperatura" ; define DHT22 temperature sensor
              M308 S11 P"S10.1" Y"dht-humidity" A"Humedad [%]" ; Attach DHT22 humidity sensor to secondary output of temperature sensor
              
              

              daemon.g:

              if !exists(global.logTemps)
                  global logTemps = false
               
              while global.logTemps ==true && job.file.fileName != null
                  echo >>{"0:/sys/templog/templog.csv"} {sensors.analog[10].lastReading}^","^{sensors.analog[11].lastReading}
                  G4 S30
              
              1 Reply Last reply Reply Quote 1
              • amimafeundefined amimafe marked this topic as a question
              • amimafeundefined amimafe has marked this topic as solved
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA