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. Troubleshooting
  3. Water pressure struggling with sketch

Water pressure struggling with sketch

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 3 Posters 2.8k 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.
  • mikeg291M Offline
    mikeg291M Offline
    mikeg291
    wrote on last edited by sundberg84
    #1

    Can some help with this sketch I can't seem to figure it out. I will be so happy when I get past this newbie stage.

    #include <SPI.h>
    #include <MySensor.h>  
    #define BARO_CHILD 0
    MySensor gw;
    MyMessage pressureMsg(BARO_CHILD, V_PRESSURE);
    
    int pSensor=A0; //assigning pressure sensor to pin A0
    int readValue; //declaring our readValue Variable
    float Voltage; // declare  voltage variable
    float PSI; // declare pressure variable
    
    void setup()
    {
      gw.begin();
    
      // Send the sketch version information to the gateway and Controller
      gw.sendSketchInfo("Water Pressure", "1.1");
    
      // Register sensors to gw (they will be created as child devices)
      gw.present(BARO_CHILD, S_BARO);
    
    
     pinMode(pSensor,INPUT); //declare psensor as a input
     Serial.begin(9600); //start serial port
    }
    
    void loop() {
      
      readValue = analogRead(pSensor); // read psensor and put value in read value
      Voltage = (5./1023.)*readValue; //calculating real  world voltage
      PSI = 17.78*Voltage -8; // Calculate pressure PSI
    
      {
        gw.send (PSI);
      }
    
    Serial.println(PSI); //print results to serial monitor
      delay(1000);   // delay one second
    
    }
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      tripy
      wrote on last edited by tripy
      #2

      What is your error message?
      In your loop, this looks wrong:

      Voltage = (5./1023.)readValue; 
      

      Are you sure you didn't miss an operator or something ?

      You are also missing a presentation of your node, and I don't see anything declaring the radio to be used.
      What are you trying to do?

      mikeg291M 1 Reply Last reply
      0
      • T tripy

        What is your error message?
        In your loop, this looks wrong:

        Voltage = (5./1023.)readValue; 
        

        Are you sure you didn't miss an operator or something ?

        You are also missing a presentation of your node, and I don't see anything declaring the radio to be used.
        What are you trying to do?

        mikeg291M Offline
        mikeg291M Offline
        mikeg291
        wrote on last edited by
        #3

        he error that I get is
        Arduino: 1.6.7 (Windows 7), Board: "Arduino Nano, ATmega328"

        C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino: In function 'void loop()':

        my_pressure_sketch_1:34: error: no matching function for call to 'MySensor::send(float&)'

         gw.send (PSI);
        
                     ^
        

        C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino:34:17: note: candidate is:

        In file included from C:\Users\repair\Desktop\Ardunio Files\my_pressure_sketch_1\my_pressure_sketch_1.ino:2:0:

        C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:215:7: note: bool MySensor::send(MyMessage&, bool)

        bool send(MyMessage &msg, bool ack=false);

           ^
        

        C:\Program Files (x86)\Arduino\libraries\MySensors/MySensor.h:215:7: note: no known conversion for argument 1 from 'float' to 'MyMessage&'

        exit status 1
        no matching function for call to 'MySensor::send(float&)'

        This report would have more information with
        "Show verbose output during compilation"
        enabled in File > Preferences.
        @tripy

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by mfalkvidd
          #4

          Change

          gw.send(PSI);
          

          to

          gw.send(pressureMsg.set(PSI, 0));
          
          1 Reply Last reply
          0
          • T Offline
            T Offline
            tripy
            wrote on last edited by tripy
            #5

            I'm a bit blind here, but your issue seems to be that you are trying to send a raw float value, without encapsulating it inside a message.
            Looking at the example, in the 1.5 version it is:

            gw.send(pressureMsg.set(pressure, 0));
            

            Looking at the 1.5 API (http://www.mysensors.org/download/sensor_api_15#MyMessage), creating the message from a float should be

            MyMessage& set(float value, uint8_t decimals);
            

            So, you should not use

            gw.send (PSI);
            

            but

            //declare and init the message
            MyMessage msg(BARO_CHILD, V_PRESSURE);
            //set it's content
            msg.set(PSI,4); //float value with a 4 numbers after decimal precision
            //and send the message
            gw.send (msg);
            mikeg291M 1 Reply Last reply
            1
            • T tripy

              I'm a bit blind here, but your issue seems to be that you are trying to send a raw float value, without encapsulating it inside a message.
              Looking at the example, in the 1.5 version it is:

              gw.send(pressureMsg.set(pressure, 0));
              

              Looking at the 1.5 API (http://www.mysensors.org/download/sensor_api_15#MyMessage), creating the message from a float should be

              MyMessage& set(float value, uint8_t decimals);
              

              So, you should not use

              gw.send (PSI);
              

              but

              //declare and init the message
              MyMessage msg(BARO_CHILD, V_PRESSURE);
              //set it's content
              msg.set(PSI,4); //float value with a 4 numbers after decimal precision
              //and send the message
              gw.send (msg);
              mikeg291M Offline
              mikeg291M Offline
              mikeg291
              wrote on last edited by
              #6

              @tripy Thanks ; Tripy your solution solve the problem and pointed me in new info . I am slowly learning the solutions are available here .

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tripy
                wrote on last edited by
                #7

                Glad I was able to help.

                1 Reply Last reply
                1

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                27

                Online

                12.0k

                Users

                11.2k

                Topics

                113.4k

                Posts


                Copyright 2025 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