Hi,
I use a HX701B sensor on an Arduino nano to measure the air pressure and indirectly the waterlevel. It works fine, so I wanted to add a second sensor, but it stucks within the setup.
Can somebody help me?
Here is my code:
Hi Jim,
sorry I didn't mention that my code is only an extract regarding the HX710 issue. I defined the debugOutput well as a global variable. That isn't the problem.
If that does not happen, there can be several possible causes, ranging from no good connections to broken sensor.
First step I advice is to verify the sensors one by one so you know for sure they are in working condition. (From the first you know, the second is unknown).
As author of the library I will create an issue to add a timeout option in the library.
That should handle the endless blocking in some future release.
Usually, the class name comes from the full library name. In your case, the library name is HX710AB.h; but, the class name is: HX710A. Any good reason to drop B?
Long answer: The HX710A and the HX710B are very similar, so I created a base class HX710AB and had two derived classes HX710A and HX710B. The difference is in the fetch() function.
So this library has three classes, which breaks your assumption about class name and full library name. My MCP_ADC library has nine classes in it.
they even share a datasheet (sort of fraternal twins)
On Github there is a develop branch added which allows to set timeout for the read() call.
The default timeout = 1000 milliseconds which is completely arbitrary but at least long enough. You can give it a try to see if the blocking is handled (not per se solved).
Goodeye. In practice, I have only found such omissions to cause trouble with any use of the port, not weird show-stoppers cropping elsewhere.
Thanks for the attention and patchwork.
If only all library authors were tuned in. I read through the code and would have asserted that there is no sign that handling multiple HX701X sensors would be anything less than trivially easy and that the OP's problem was not exzctly because two were in use.
In fact the read() call blocks if the data pin is never pulled low. So with good connections / soldering and working devices it should not block, but the world is not perfect.
One could have an array of HX devices without problems as long as no device blocks. One broken device would block them all when using read(). With the async API the user can detect and act on a broken device. Should spend a few lines on that in the readme.md, even for a single device the async API gives more control.
OK, fair enough
One of the advantages of a higher baud rate is that the internal buffer gets emptied faster so print() functions are less often blocked when spitting out lots of e.g. debug prints.
You (your students) can easily investigate the buffering behavior at different speeds.