# How to use DFRobot sensors with MicroBit This is a documentation about how to make a sensor work using microbit and doing an easy task with it (like showing the information or switching the led screen). Also the idiea is work with the Kitronic Robotics board shield. ## Materials needed * Microbit * Kitronik Compact All-in-one Robotics Board for bbc microbit * Analog resistance type soil moisteure sensor dfrobot SEN0114 ## Preparation Check that you're able to upload some programs to the microbit using makecode. This is not covered by this documentation. ## How to install the extension of the kitronik board :::info You don't need this extension for the sensor to work but I show because it's relevant for the motors and the project about it. ::: Once we are in the project ![image](https://hackmd.io/_uploads/r1p6nTgblx.png) We go to the wheel of settings and click "Extensions" ![image](https://hackmd.io/_uploads/r11kTTx-ee.png) There we look for "Kitronik robotics" ![image](https://hackmd.io/_uploads/ry8-6aeWeg.png) And we click kitronik-robotics-board If you have it properly installed you should see this: ![image](https://hackmd.io/_uploads/B1-He0e-el.png) ## The sensor input ### The sensor itself ![image](https://hackmd.io/_uploads/S1z4dkZ-el.png) https://wiki.dfrobot.com/Moisture_Sensor__SKU_SEN0114_ The sensor has 3 pins, Ground (GND), 3V3 and any reading pin You can see the pinout here: ![image](https://hackmd.io/_uploads/Hk8OE0x-xx.png) From the website: Power supply: 3.3v or 5v Output voltage signal: 0~4.2v Current: 35mA Pin definition: Analog output(Blue wire) GND(Black wire) Power(Red wire) Size: 60x20x5mm Value range: 0 ~300 : dry soil 300~700 : humid soil 700~950 : in water ### The connection We use the cable that comes and we use solid wire to connect it to the board. ![image](https://hackmd.io/_uploads/HkuGdJW-gg.png) It's easy to do a simple hinge wit the solid wires and that's why I suggest to use for the simple projec rather than a dupont cable. Here you can see the hinges ![image](https://hackmd.io/_uploads/B11Zd1-Wgg.png) Then we have to use Analog Read in our code ![image](https://hackmd.io/_uploads/HJO9QCeZex.png) ### Sample code with microbit This is a sample code using the specifications from the website, in this case we have the led screen changing <div style="position:relative;height:calc(300px + 5em);width:100%;overflow:hidden;"><iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="https://makecode.microbit.org/---codeembed#pub:_K5WFfCY733u4" allowfullscreen="allowfullscreen" frameborder="0" sandbox="allow-scripts allow-same-origin"></iframe></div> In photos This is alone (dry) ![image](https://hackmd.io/_uploads/S1kJ_JWZxg.png) And here when you touch both pads with water in your fingers (humid) ![image](https://hackmd.io/_uploads/BJDnw1bbex.png) ## Yet another moisture sensor Asair DHT11 https://naylampmechatronics.com/blog/40_tutorial-sensor-de-temperatura-y-humedad-dht11-y-dht22.html