Hi everyone,
I'm struggling how to use watermark sensors on Arduino Edge Control. In short my question is how to connect them - directly attach the two wires of the sensor to J8-1 and J8-18 or more complicated set-up is needed?
I have done test with 1k resistor attaching it to J8-1 and J8-18 and it seems that its not working correctly. I’ve tried all 3 sketches about watermark implementation in github examples and all 3 give completely different readings and all of them are wrong. I tried also amending the connection adding 10k calib. resistor connected to J8-17 or using the integrated ground with 10k resistor on J11-11 but again with no success.
So what am I doing wrong?
Any help will be much appreciated!
Looks like they have not gotten around to offering documentation for the WATERMARK sensors. If it doesn't magically work when you try it, good luck guessing what is wrong.
We are developing new tutorials on how to connect valves, LCDs, watermark sensors and use many other functionalities of the board. In the mean time you can explore the Arduino Edge Control library to develop your own application.
Do you have a datasheet for this sensor?
Do you wire really just two signals ( J8-1 and J8-18)?
Or are there also power (VCC) and ground (GND)? (at least plus 2 additional wires from sensor).
Are these two wires I2C (SDA, SCL)?
Do you have pull-ups for these I2C signals? (do you see 3.xV on SDA, SCL when quiet?)
Do you have separate power to the sensors, but maybe the COMMON GND is missing?
Most common mistake: the COMMON GND is missing (a wire from GND on sensor to GND on MCU, even the +VCC is separate).
Other issues (not familiar with this sensor board):
are there some other signals, esp. ENABLE signals, which must be driven (tied to +VCC or GND, just to enable functionality)?
I would like to provide some update based on the extensive reading, research and experimenting last days:
On hardware:
Based on Arduino Edge Control schematics the two wires of the sensor should be connected indeed to J8-1 and J8-17/18. There is a voltage divider implemented using 7.87k resistor and the SENSOR_CALIB line. In addition two more features are implemented - 1) to ground the sensor and discharge it (fastDischarge) and 2) to add second 100nF capacitor (setHighPrecision). Based on my knowledge the latter to me seems to be working as a noise filter if you are using long sensor cables and not improving the precision.
On software(github examples):
- 10k example 10 bit ADC resolution is used;
- In Mega example there are several flaws:
- 12 bit ADC resolution is used for the calculations but the code "analogReadResolution(adcResolution);" is missing and therefore the ADC readings are actually in 10bit. Because of that the results are completely wrong;
- 1 should be subtracted when defining maxValue - "constexpr auto maxValue { 1 << adcResolution };" but this is somewhat minor issue.
- there are some discrepancies in the CB conversion formula in comparison to the original example -> resistor value is divided by 1500 instead on 1000, etc
- Tau example is reading Watermark channel 2 in contrast with the other two examples that read channel 1;
If we fix all issues/inconsistencies with the examples one final issue remains but it quite important:
On open pin I get analogRead value around 30, while on short I get around 3850 with 12 bit resolution. When I measured the Voltage of J8-17/18 against GND I get 0.00V for LOW and 3.19V for HIGH. I will try to further investigate whether this comes from the resistance of the MUX or the CPU is not providing the correct 3.3V.
Nevertheless this is a fundamental flaw in the design or I have a buggy board as the most important sensor readings are with relatively low resistance and this embedded resistance of the board around 500 ohms (I have to calculate the exact number) is ridiculous!