Problems with Smart Rain Detection Module UART
Moving my post here from the product page ---
Ok, so I'm having weird results. Sometimes the commands return data, most times not. And it seems like each command only works once or so. I've written a little Circuit Python program (trying to basically build a little "Hello, World" type of program.)
Using a XIAO RP2040. With the mini expansion board.
I have a grove cable which has single female pins on the non grove end.
From the black pin on the grove connector, I run that (via jumper) to the red pin on the sensor cable. (G to G)
From the red pin on the grove connector, I run that (via jumper) to the black pin on the sensor cable ( 3.3 to 3.3)
From the white pin on the grove connector, I run that (via jumper) to the yellow pin on the for cable (TX to TX)
From the yellow pin on the grove connector, I run that (via jumper) to the white pin on the sensor cable ( RX to RX)
That's as per the manual.
Here's my little CircuitPython program
"""CircuitPython Essentials UART Serial example""
import board
import busio
import digitalio
print("Starting up")
uart = busio.UART(board.TX, board.RX, baudrate=115200, bits=8, parity=None, stop=1, timeout=2)
# This should show system status and clear system error status
uart.write(bytearray(b'3A020000C7'))
data = uart.read(10)
print(data)
# This should show Firemware Version
uart.write(bytearray(b'3A0000004B'))
data = uart.read(10)
print(data)
# This should command module to wake from sleep mode
uart.write(bytearray(b'3A91010088'))
data = uart.read(10)
print(data)
# This should give us chip temp
uart.write(bytearray(b'3A100000EF'))
data = uart.read(10)
print(data)
# This should show rainfall state
uart.write(bytearray(b'3A0100000D'))
data = uart.read(10)
print(data)
All of those byte sequences are from the manual. (and I have gotten a response for most of them, but only once -- and it looked like the response was duplicated in the output stream... and cut off after 10 bytes of course... and I never saw the CRC coming back..) My current output is :
Starting up
None
None
None
None
None
Which makes no sense to me. Those values are taken straight from the documentation. Any ideas??
A couple days later, I posted :
I've tried (today) a Sparkfun Thing Plus RP2040 with same code. Exactly same results.
I can try other boards, but I feel pretty confident that these two boards work properly.
And given that I got good data at least once, I'm feeling fairly frustrated that I can't get consistent working behavior.
The code isn't that complicated... Any thoughts?
I got a reply from DFRobot Support :
Hello, please try connect RX to TX, and vice versa. The Rx pin is used to receive data. The Tx pin is used to transmit data. When two devices are connected using a UART, the Rx pin of one device is connected to the Tx pin of the second device.
I replied :
I have already tried both orientations. Neither works. The manual said to connect TX-TX and RX-RX (which was opposite to what I've done before). But neither produced any results. What continues to puzzle me is that I did get data once on each code... Maybe I'll try some more (but I don't understand how it works with each code once and once only)
And I got this last reply (and is why I opened this new topic) :
Hello, thank you for your support and enthusiasm, we would love to learn more about the problem that you are facing. However, it would be difficult to share codes and pictures in the comment section. Would you mind sharing your results with us through our tech support email or our official forum?
E-mail: [email protected]
Forum: https://www.dfrobot.com/forum/
Your contribution to our community is much appreciated.
So, I'm now awaiting any further questions. I believe I've given a good description of the setup and the issue (and included example code). What other information would you want?