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. How do I connect/code to use a flex sensor?

How do I connect/code to use a flex sensor?

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 2 Posters 2.9k Views 1 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by Cliff Karlsson
    #1

    I bought two flex sensor before and would like to know how connect them and if possible a sample code for two sensors.

    DwaltD 1 Reply Last reply
    0
    • Cliff KarlssonC Cliff Karlsson

      I bought two flex sensor before and would like to know how connect them and if possible a sample code for two sensors.

      DwaltD Offline
      DwaltD Offline
      Dwalt
      wrote on last edited by Dwalt
      #2

      @Cliff-Karlsson

      A flex sensor is like an LDR, you would connect to an analog pin as part of a voltage divider. The senjor will give analog readings dependent on the voltage supplied and the range of flex in your application. How you code it would depend on what you are trying to sense. If you want to get an incremental measurement along the entire range of flex, you could use the map function to convert it from the analog read to a 1-100 scale as V_PERCENTAGE. If you were just looking for it to provide an alert when the sensor flexed past a certain level, you could set the level in your code and send it as a V_STATUS using S_BINARY or S_LIGHT. Either way, you need to determine the analog values of your sensor within the working environment of your application before you can finalize your code. E.g. What is the analog read when nothing is happening to the sensor and what is the reading when the sensor is at maximum expected flex.

      Veralite UI5 :: IBoard Ethernet GW :: MyS 1.5

      1 Reply Last reply
      0
      • Cliff KarlssonC Offline
        Cliff KarlssonC Offline
        Cliff Karlsson
        wrote on last edited by
        #3

        How would the code look like If I want a way to monitor the different values wireless when the sensor is placed in the desired place?

        DwaltD 1 Reply Last reply
        0
        • Cliff KarlssonC Cliff Karlsson

          How would the code look like If I want a way to monitor the different values wireless when the sensor is placed in the desired place?

          DwaltD Offline
          DwaltD Offline
          Dwalt
          wrote on last edited by
          #4

          @Cliff-Karlsson

          It might be easier if you explained your intended application.

          The code can be written to read the sensors continuously and only send when a significant change is detected, or it can read the sensors on a time interval and send the value as a percentage or custom value. If you want to continuously read the value at your controller, you will flood your wireless network with messages.

          I would suggest first hooking the sensor up to a Arduino and read the analog values of your sensor through the serial monitor to see what range and fluctuation your application generates.

          Veralite UI5 :: IBoard Ethernet GW :: MyS 1.5

          1 Reply Last reply
          0
          • Cliff KarlssonC Offline
            Cliff KarlssonC Offline
            Cliff Karlsson
            wrote on last edited by
            #5

            @Dwalt said:

            I would suggest first hooking the sensor up to a Arduino and read the analog values of your sensor through the serial monitor to see what range and fluctuation your application generates.

            I would like to use two flex sensors under my bed to try out of they are good as bed occupancy sensors. But I do not know how much "flex" is generated when the sensors is placed underneath the bed. Would the resistance chage be usable even if the flex sensor is just bent a couple of degrees?

            1 Reply Last reply
            0
            • Cliff KarlssonC Offline
              Cliff KarlssonC Offline
              Cliff Karlsson
              wrote on last edited by
              #6

              Does those "button" force sensors work in the same way?

              DwaltD 1 Reply Last reply
              0
              • Cliff KarlssonC Cliff Karlsson

                Does those "button" force sensors work in the same way?

                DwaltD Offline
                DwaltD Offline
                Dwalt
                wrote on last edited by Dwalt
                #7

                @Cliff-Karlsson

                No sure on the button force sensors, I have not used them.

                To test the force sensors under a mattress, I would wire them up to an Arduino with a sketch that simple reads the analog pin and serial prints the result. Place the sensor under the mattress and see what the serial monitor readings are when the bed is unoccupied and occupied. This would give you the unique range for you particular need. Might be tricky if your computer and bed are in different rooms. After you have the range, you could write a sketch with S_BINARY to trigger V_STATUS whenever the reading approached the high end of your tested range.

                If you cannot reach you bed while connected to serial, you could write a sample mySensors sketch to send the analog reading every few seconds to your controller as V_LEVEL. This video helps explain how to wire up the sensor and select the static resistor for the voltage divider. video

                Veralite UI5 :: IBoard Ethernet GW :: MyS 1.5

                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.1k

                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