Analog Touch and Moisture Sensor - Water-Monitor/IoT-Portfolio-FJS GitHub Wiki

Analog touch sensor

My task was to create an analog sensor, that registers if it gets touched or not. The task might seem quite easy in the beginning, but if you do not know that the small cables in our iot-hardware-kits were already analog sensores, then it might take a while till you realize how easy this task could be.

Step by step

  • Start node-red
  • Plug in usb cable with the wemus
  • Put a small cable in the Wemus at the port A0 and leave the other part hanging in the air
  • Create a topic called "touch"

The goal is to let the system know, when the unplugged end of the cable gets touched by someone. Ulrich explained to me that analog cables are already touch sensores. They can detect the smallest amount of voltage, like the one's in our human bodies! That's why it can work as a touch sensor. If the end of the cable is pressed or released, it will send a mqtt message. Pressed is true and released is false.

  • In iotempower, I created a new node which includes a setup.cpp file.
  • Add a command line to it, which can be found in the doc of iotempower
  • 'analog(touch).with_precision(10).with_treshold(100, “pressed”, “unpressed”)' was the original one. Try experimenting with different values.
  • with_precision(1).with_treshold(1020) --> was not so good
  • with_precision(100).with_treshold(500) --> was also bad so I sticked to the original on
  • add filter_binarize which can be found in the doc as well and delete the 'with_treshold'

Now the sensor reacts when being touched, altough it is not very precisely. Changing the precision value to 100 helped a little bit.

In the task it also mentioned to work with Node-red, but the task was not really clear and I managed to solve it without node-red. Ulrich then explained to me, that I was supposed to do everything first in node-red and then in iotempower, but I personally think, that doing it with node-red is even harder. I still sended the values to node-red and created there a gauge, so I could check the voltage values more visually.

Ulrich showed me then, that I can use 'filter_average(50)' to get actually number as values and made it also readable in node-red for the gauge (which did not work before).


Moisture Sensor

The moisture sensor is veeeery similar to the touch sensor. Therefore, the instruction will be a bit shorter.

#Step by step

  • Find the Moisture sensor (a long, flat, black sensor; something labeled with 'soil')
  • Get a voltage divider since this sensor works with 5V which is not good for our Wemus.
  • A voltage divider consists of 2 resistors
  • Put the resistors on the breadboard, connect the wemus and the sensor with it
  • Use the exact same code like before with the analog sensor

Now the sensor should output the moisture values. The only hard part here was the voltage divider and finding the correct sensor. I didn't manage to upload the pictures on github, so the least I could do was to publish them on Google Drive and add the links.

Picture of Analog Sensor

Picture of Moisture Sensor with voltage divider