Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Hardware
  3. Driving an moving coil meter whit a PWM output

Driving an moving coil meter whit a PWM output

Scheduled Pinned Locked Moved Hardware
5 Posts 3 Posters 944 Views 3 Watching
  • 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.
  • dzjrD Offline
    dzjrD Offline
    dzjr
    wrote on last edited by
    #1

    Hello MySensor-ers,

    I recently started MySensors in combination with Domoticz.

    For a while I have had the idea to use some old panel meters (moving coil meters) to visualize for example (room) temperature or current consumption of electricity.

    When looking around I came out on the Dimmer sketch, is this the only way to control a PWM output or are there other ways to control a PWM output which is more towards a display or meter?

    second question; Does anyone have a tip to set up a script in domoticz where, for example, the measured room temperature can be sent between 0 and (max) 25 degrees to a PWM output?

    thanks in advance
    dzjr

    H 1 Reply Last reply
    0
    • dzjrD dzjr

      Hello MySensor-ers,

      I recently started MySensors in combination with Domoticz.

      For a while I have had the idea to use some old panel meters (moving coil meters) to visualize for example (room) temperature or current consumption of electricity.

      When looking around I came out on the Dimmer sketch, is this the only way to control a PWM output or are there other ways to control a PWM output which is more towards a display or meter?

      second question; Does anyone have a tip to set up a script in domoticz where, for example, the measured room temperature can be sent between 0 and (max) 25 degrees to a PWM output?

      thanks in advance
      dzjr

      H Offline
      H Offline
      hard-shovel
      wrote on last edited by
      #2

      @dzjr I have several meters for quick indications.

      Normally i utilize a message type of V_VAR1 to 5 as these are available for all sensor types, If it just being an information sensor then I use the S_INFO device.

      I send the information to be displayed as direct units
      For example for temperature I would send V_VAR1 = 26.1 as 26.1°C or -5.5
      and then let the node set the display range.

      if you want only a linear display the following code will work,

      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      
      #include <MySensors.h>
      
      #define SKETCH_NAME "MySensors Meter"
      #define SKETCH_VERSION "v1.0"
      
      // Meter Vars
      #define METER_PIN     5
      #define METER_ID      20    // whater childId your using
      #define METER_MIN      0    // meter Minimum value
      #define METER_MAX     30    
      MyMessage msg_S_INFO_VAR1(ID_S_INFO,V_VAR1);
      float info_Var1 = 00.0;
      
      void before()
      {
      }
      
      void setup() {
        // put your setup code here, to run once:
      
      }
      
      void loop() {
        // put your main code here, to run repeatedly:
      
      }
      
      void receive(const MyMessage &message)
      { 
        if (message.type == V.VAR1) {
            info_Var1=message.getFloat();
          Serial.print("Incoming value for ID_S_INFO:");
          Serial.print(message.sensor);
          Serial.print(", V_VAR1: ");
          Serial.print(", New status: ");
          Serial.println(info_Var1,1);
          updateMeter0(info_Var1);
        }
      }
      
      
      void updateMeter0(float meterInput=0){
      // Meter 0   this uses the input value and simple maping
      // Note The map() function uses integer math so will not generate fractions, so can be helpful to multiply input values
      // ie using input temperature value 0 to 30°C  So multiply by 10 to get 0-to 300
      int16_t max_Output=   255;   // maximum PWM Value, 255 for Arduino Uno,  1023 for ESP8266
      meterInput = meterInput *10;
      analogWrite(meter_pin, map(meterInput,meter_MIN, meter_MAX, 0, max_Output )) ;  // map to Max PWM Level        
      }
      
      

      However i like to have arbitrary scales so normally use a look-up array for the pwm values. as used in the meters shown.

      0_1538783259128_IMG_4446.JPG

      1 Reply Last reply
      0
      • dzjrD Offline
        dzjrD Offline
        dzjr
        wrote on last edited by
        #3

        @hard-shovel

        Thank you for your reply.

        It is indeed what I mean and wants to make.
        I have several old meters with various scales, but not all scales are usable, but that does not have to be a problem.

        If you like it, I will use your sketch as an example.
        I myself had not even thought of arranging the minimum / maximum value in the arduino.

        I'm going to set up a test soon.

        Incidentally beautifully composed box with the meters and lights!

        When I have finished I will post a photo!

        thanks again for your push in the right direction !!

        dzjr

        H 1 Reply Last reply
        0
        • dzjrD dzjr

          @hard-shovel

          Thank you for your reply.

          It is indeed what I mean and wants to make.
          I have several old meters with various scales, but not all scales are usable, but that does not have to be a problem.

          If you like it, I will use your sketch as an example.
          I myself had not even thought of arranging the minimum / maximum value in the arduino.

          I'm going to set up a test soon.

          Incidentally beautifully composed box with the meters and lights!

          When I have finished I will post a photo!

          thanks again for your push in the right direction !!

          dzjr

          H Offline
          H Offline
          hard-shovel
          wrote on last edited by
          #4

          @dzjr I also have various old meters, Some have a sealed movement so unable to change the scales.

          Below is my meter showing time since last coffee.
          0_1539880962040_Img_4463x.jpg

          zboblamontZ 1 Reply Last reply
          0
          • H hard-shovel

            @dzjr I also have various old meters, Some have a sealed movement so unable to change the scales.

            Below is my meter showing time since last coffee.
            0_1539880962040_Img_4463x.jpg

            zboblamontZ Offline
            zboblamontZ Offline
            zboblamont
            wrote on last edited by
            #5

            @hard-shovel That would be the cold coffee with cream with a certain Guinness ais quoi? ;)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            15

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular