{"product_id":"water-level-sensor-module","title":"Water Level Sensor Module for Arduino and ESP32","description":"\u003cdiv class=\"nznpd\"\u003e\n\u003cdiv class=\"nznpd__lead\"\u003e\n\u003cp class=\"nznpd__intro\"\u003eA water sensor tells a microcontroller when water is touching it. This one has ten bare metal stripes along a strip about 40mm long. Water bridging the stripes raises the voltage on the S pin, so the reading climbs as more of the strip gets wet. It tells wet from dry and gives a rough idea of depth over that 40mm. It is not a measuring gauge, because the reading also changes with how clean the water is and with the supply voltage.\u003c\/p\u003e\n\u003cp class=\"nznpd__intro\"\u003eYou can use it as a leak alarm under a sink, an overflow alarm near the top of a sump, or a rain detector. It runs on 3.3V or 5V, and its three pins connect with jumper wires to an analogue input on an Arduino, ESP32 or Raspberry Pi Pico. The stripes corrode if the board sits powered in water, so you power it from a spare output pin and switch it on only for each reading. The steps below show how. For a tank you want to monitor all year, an \u003ca href=\"\/products\/hc-sr04-ultrasonic-distance-sensor-module\"\u003eHC-SR04 ultrasonic sensor\u003c\/a\u003e mounted above the water measures the level without touching it.\u003c\/p\u003e\n\u003c\/div\u003e\n\n\u003csection class=\"nznpd__block\"\u003e\n\u003ch3 class=\"nznpd__h\"\u003eSpecifications\u003c\/h3\u003e\n\u003cdiv class=\"nznpd__specs\"\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eSenses\u003c\/span\u003e\u003cstrong\u003eWater touching the stripes: wet or dry, and rough depth\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eSensing length\u003c\/span\u003e\u003cstrong\u003eAbout 40mm, 10 stripes\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eOutput\u003c\/span\u003e\u003cstrong\u003eAnalogue voltage on S, rises as more is wet\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eSupply\u003c\/span\u003e\u003cstrong\u003e3.3V to 5V DC\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eCurrent\u003c\/span\u003e\u003cstrong\u003eUnder 20mA\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003ePins\u003c\/span\u003e\u003cstrong\u003eS, + and - on a 2.54mm header\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eSize\u003c\/span\u003e\u003cstrong\u003e59 x 20mm, about 66mm with pins\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eMounting\u003c\/span\u003e\u003cstrong\u003e2 holes at the pin end, about 15mm apart\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003cdiv class=\"nznpd__spec\"\u003e\n\u003cspan\u003eIn the box\u003c\/span\u003e\u003cstrong\u003e1 sensor with header fitted, no jumper wires\u003c\/strong\u003e\n\u003c\/div\u003e\n\u003c\/div\u003e\n\u003c\/section\u003e\n\n\u003csection class=\"nznpd__block\"\u003e\n\u003ch3 class=\"nznpd__h\"\u003eDatasheets\u003c\/h3\u003e\n\u003cdiv class=\"nznpd__ds\"\u003e\n\u003ca class=\"nznpd__dsbar\" href=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0664\/6127\/0112\/files\/MOD-WATER-SENSOR-Datasheet-Rev1.pdf?v=1794353687\" target=\"_blank\" rel=\"noopener\" aria-label=\"Download the water level sensor module technical datasheet (PDF)\"\u003e\n\u003csvg width=\"20\" height=\"20\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\u003cpath d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\"\u003e\u003c\/path\u003e\u003cpolyline points=\"14 2 14 8 20 8\"\u003e\u003c\/polyline\u003e\u003c\/svg\u003e\n\u003cspan\u003eFull technical datasheet\u003c\/span\u003e\n\u003cspan class=\"nznpd__dsmeta\"\u003ePDF\u003csvg width=\"17\" height=\"17\" viewbox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\u003e\u003cpath d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"\u003e\u003c\/path\u003e\u003cpolyline points=\"7 10 12 15 17 10\"\u003e\u003c\/polyline\u003e\u003cline x1=\"12\" y1=\"15\" x2=\"12\" y2=\"3\"\u003e\u003c\/line\u003e\u003c\/svg\u003e\u003c\/span\u003e\n\u003c\/a\u003e\n\u003c\/div\u003e\n\u003c\/section\u003e\n\n\u003csection class=\"nznpd__block\"\u003e\n\u003cdiv class=\"nznpd__qs\"\u003e\n\u003ch3\u003eWiring \u0026amp; getting started\u003c\/h3\u003e\n\u003cdetails class=\"nznpd__figbox\" open\u003e\u003csummary\u003eWiring diagram\u003cspan class=\"nznpd__codelang\"\u003eArduino Nano and ESP32\u003c\/span\u003e\u003c\/summary\u003e\u003cfigure class=\"nznpd__fig\"\u003e\u003ca href=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0664\/6127\/0112\/files\/MOD-WATER-SENSOR-wiring-nano-esp32-wide.png?v=1794355133\" target=\"_blank\" rel=\"noopener\"\u003e\u003cpicture\u003e\u003csource media=\"(min-width: 600px)\" srcset=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0664\/6127\/0112\/files\/MOD-WATER-SENSOR-wiring-nano-esp32-wide.png?v=1794355133\" width=\"920\" height=\"1570\"\u003e\u003cimg src=\"https:\/\/cdn.shopify.com\/s\/files\/1\/0664\/6127\/0112\/files\/MOD-WATER-SENSOR-wiring-nano-esp32.png?v=1794355133\" alt=\"Wiring drawing: water level sensor S to Arduino Nano A0 or ESP32 GPIO34, + to Nano D7 or ESP32 GPIO26, and - to GND on both\" width=\"690\" height=\"1859\" loading=\"lazy\"\u003e\u003c\/picture\u003e\u003c\/a\u003e\u003cfigcaption\u003eTap the drawing to open it full size.\u003c\/figcaption\u003e\u003c\/figure\u003e\u003c\/details\u003e\n\u003col class=\"nznpd__steps\"\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eFind the pins\u003c\/strong\u003e\u003cp\u003eHold the board with the parts facing you and the stripes pointing left. The three pins are marked S, + and - from top to bottom. S is the signal, + is power and - is ground.\u003c\/p\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eWire it to an Arduino\u003c\/strong\u003e\u003cp\u003eConnect S to A0, + to D7 and - to GND. Our \u003ca href=\"\/products\/rainbow-dupont-jumper-wire-kit-20cm\"\u003efemale-to-male jumper wires\u003c\/a\u003e push straight onto the pins. Powering + from pin D7 instead of the 5V pin lets the code switch the sensor off between readings.\u003c\/p\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eOn an ESP32 or Pico\u003c\/strong\u003e\u003cp\u003eConnect S to an analogue input pin, + to a spare output pin and - to GND, then change the two pin numbers at the top of the code. These boards run at 3.3V, and a sensor powered from a 3.3V pin keeps its S output within what the input pin can take. On a 38-pin ESP32, GPIO34 for S and GPIO26 for + both work with WiFi on.\u003c\/p\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eLoad the test code\u003c\/strong\u003e\u003cp\u003eUpload the code below and open the Serial Monitor at 9600 baud. A new reading appears every second.\u003c\/p\u003e\n\u003cdetails class=\"nznpd__codebox\" open\u003e\u003csummary\u003eExample Arduino code\u003cspan class=\"nznpd__codelang\"\u003eArduino C++\u003c\/span\u003e\u003c\/summary\u003e\u003cpre\u003e\u003ccode\u003e\u003cspan class=\"t-c\"\u003e\/\/ Water sensor test for an Arduino Uno or Nano.\u003c\/span\u003e\n\u003cspan class=\"t-c\"\u003e\/\/ Wiring: S to A0, + to D7, - to GND.\u003c\/span\u003e\n\u003cspan class=\"t-c\"\u003e\/\/ The sensor is only switched on while it takes a reading,\u003c\/span\u003e\n\u003cspan class=\"t-c\"\u003e\/\/ which slows the wear on the bare metal stripes in water.\u003c\/span\u003e\n\u003cspan class=\"t-t\"\u003econst\u003c\/span\u003e \u003cspan class=\"t-t\"\u003eint\u003c\/span\u003e \u003cspan class=\"t-v\"\u003ePOWER_PIN\u003c\/span\u003e = \u003cspan class=\"t-n\"\u003e7\u003c\/span\u003e;\n\u003cspan class=\"t-t\"\u003econst\u003c\/span\u003e \u003cspan class=\"t-t\"\u003eint\u003c\/span\u003e \u003cspan class=\"t-v\"\u003eSIGNAL_PIN\u003c\/span\u003e = \u003cspan class=\"t-v\"\u003eA0\u003c\/span\u003e;\n\n\u003cspan class=\"t-t\"\u003evoid\u003c\/span\u003e \u003cspan class=\"t-f\"\u003esetup\u003c\/span\u003e() {\n  \u003cspan class=\"t-o\"\u003eSerial\u003c\/span\u003e.\u003cspan class=\"t-f\"\u003ebegin\u003c\/span\u003e(\u003cspan class=\"t-n\"\u003e9600\u003c\/span\u003e);\n  \u003cspan class=\"t-f\"\u003epinMode\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003ePOWER_PIN\u003c\/span\u003e, \u003cspan class=\"t-t\"\u003eOUTPUT\u003c\/span\u003e);\n  \u003cspan class=\"t-f\"\u003edigitalWrite\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003ePOWER_PIN\u003c\/span\u003e, \u003cspan class=\"t-t\"\u003eLOW\u003c\/span\u003e);    \u003cspan class=\"t-c\"\u003e\/\/ sensor off\u003c\/span\u003e\n}\n\n\u003cspan class=\"t-t\"\u003evoid\u003c\/span\u003e \u003cspan class=\"t-f\"\u003eloop\u003c\/span\u003e() {\n  \u003cspan class=\"t-f\"\u003edigitalWrite\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003ePOWER_PIN\u003c\/span\u003e, \u003cspan class=\"t-t\"\u003eHIGH\u003c\/span\u003e);   \u003cspan class=\"t-c\"\u003e\/\/ sensor on\u003c\/span\u003e\n  \u003cspan class=\"t-f\"\u003edelay\u003c\/span\u003e(\u003cspan class=\"t-n\"\u003e10\u003c\/span\u003e);                       \u003cspan class=\"t-c\"\u003e\/\/ let the reading settle\u003c\/span\u003e\n  \u003cspan class=\"t-t\"\u003eint\u003c\/span\u003e \u003cspan class=\"t-v\"\u003ereading\u003c\/span\u003e = \u003cspan class=\"t-f\"\u003eanalogRead\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003eSIGNAL_PIN\u003c\/span\u003e);\n  \u003cspan class=\"t-f\"\u003edigitalWrite\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003ePOWER_PIN\u003c\/span\u003e, \u003cspan class=\"t-t\"\u003eLOW\u003c\/span\u003e);    \u003cspan class=\"t-c\"\u003e\/\/ sensor off again\u003c\/span\u003e\n\n  \u003cspan class=\"t-o\"\u003eSerial\u003c\/span\u003e.\u003cspan class=\"t-f\"\u003eprint\u003c\/span\u003e(\u003cspan class=\"t-s\"\u003e\"Water reading: \"\u003c\/span\u003e);\n  \u003cspan class=\"t-o\"\u003eSerial\u003c\/span\u003e.\u003cspan class=\"t-f\"\u003eprintln\u003c\/span\u003e(\u003cspan class=\"t-v\"\u003ereading\u003c\/span\u003e);\n  \u003cspan class=\"t-f\"\u003edelay\u003c\/span\u003e(\u003cspan class=\"t-n\"\u003e1000\u003c\/span\u003e);                     \u003cspan class=\"t-c\"\u003e\/\/ one reading a second\u003c\/span\u003e\n}\u003c\/code\u003e\u003c\/pre\u003e\u003c\/details\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eCheck it works\u003c\/strong\u003e\u003cp\u003eWith the sensor dry, the reading sits at or near 0. Dip the stripes into a glass of tap water and the number jumps, then climbs as you lower the board. Write down the dry number and the number with the stripes fully under your water, and use those two as your empty and full marks. If the reading stays at 0, check that + goes to D7. The Power light on the board should flicker once a second, each time the code switches the sensor on.\u003c\/p\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003cli\u003e\u003cdiv\u003e\n\u003cstrong\u003eKeep the pin end dry\u003c\/strong\u003e\u003cp\u003eOnly the striped end goes in the water. Keep the end with the parts and the pins above the surface.\u003c\/p\u003e\n\u003c\/div\u003e\u003c\/li\u003e\n\u003c\/ol\u003e\n\u003c\/div\u003e\n\u003c\/section\u003e\n\n\u003cp class=\"nznpd__note\"\u003e\u003cstrong\u003eNote:\u003c\/strong\u003e The bare metal stripes corrode in water over time, so keep this sensor out of drinking water, food and fish tanks.\u003c\/p\u003e\n\u003c\/div\u003e","brand":"NZN Electronics","offers":[{"title":"Default Title","offer_id":67765345452128,"sku":"MOD-WATER-SENSOR","price":1.79,"currency_code":"NZD","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0664\/6127\/0112\/files\/MOD-WATER-SENSOR_01_hero.png?v=1794353731","url":"https:\/\/www.nznelectronics.co.nz\/products\/water-level-sensor-module","provider":"NZN Electronics","version":"1.0","type":"link"}