September 2019 Update

New! We're moving to the new forum!

ALL new Blog posts will be on the forum.

Please join us there.

This Blog will no longer be updated...

Thursday, August 8, 2019

Hello? Is there a sensor here?

When the Sensor Module reads the attached sensors, it first performs a power test where initially the sensor is read without power being applied, and then again with power. If the difference is very small then there is no sensor on that port.  Reading a sensor without power to it will result in a meaningless value since the pins voltage is actually floating (fluctuating).

By specifying that the analog ports should enable the internal pull-up resistors, we now know that a port without a sensor will read 1024, or very close.

Sensors can be configured to skip the power test, but all pins have the internal pull-up resistors enabled.

Sensors can also be skipped if their readings are outside a configured range allowed for that sensor type. For example, a soil moisture sensor should never read less than 0, but a temperature sensor could, I have one outside, so in the winter it gets down to -30℃ or -35℃

Soil moisture sensors also have their dry and wet values calibrated. The value when it is just held in the air is the dry value, and the value when it is immersed in a glass of water is the wet value. If the sensors reading is outside these numbers, it will be skipped.

So, we have a pretty reliable system for determining if the data is valid. There are three scenarios...

1) A sensor is plugged in and working properly

2019/08/08 00:06:05 > Sensor 076 Pin A02 Tgl Pwr D48 PwrTest: 305
2019/08/08 00:06:05 >   Raw: 379 (DIY-3 Soil)  => 37%

You can see it passed the power test, the difference was 305, which indicates a sensor is attached.
It also has a valid reading of the sensor.

2) A sensor is either unplugged from the voltage divider, so only the voltage divider is plugged into the Sensor Module, or the sensor has been removed from the soil and no longer has anything to measure.  

2019/08/08 00:08:04 > Sensor 076 Pin A02 Tgl Pwr D48 PwrTest: 1
2019/08/08 00:08:05 >   Raw: 232 (DIY-3 Soil)  => 22%

It fails the power test, even though the actual reading looks valid.
This raw value is likely very close to it's calibrated dry value.

3) Nothing at all is plugged into the Sensor Module on that pin

2019/08/08 00:09:03 > Sensor 076 Pin A02 Tgl Pwr D48 PwrTest: 0
2019/08/08 00:09:03 >   Raw: 1021 (DIY-3 Soil)  => 99%

It fails the power test and the reading looks invalid due to the pull up resistor.
The reading will be compared against the calibrated wet value, and in this case, is much higher...

No comments:

Post a Comment

Any comments deemed off topic or offensive will be removed