0

I've bought a module which should communicate via serial RX/TX. The module and code are described here: https://www.dfrobot.com/wiki/index.php/Weather_Station_with_Anemometer/Wind_vane/Rain_bucket_SKU:SEN0186.

I've hooked up everything as described (using an Arduino Nano instead of an Uno, but the rest is the same) and now trying to get things to work. I could not get any decent output. So I decided to switch to a bare-minimum program to read stuff from the serial port in order to see whats going on. I found the following sample: https://gist.github.com/Protoneer/96db95bfb87c3befe46e and implemented this code (only this).

Now what I see is the following: - With RX/TX connected the wrong way, when I reset the nano, the serial monitor shows me one instance of the string I'm looking for (as described in the module documentation). When connected the right way, the text is not there but that's to be expected as the nano should receive it (and not the serial monitor). This does however prove that the module is actually sending data. - Serial.available seems to evaluate to 0 all the time, indicating there is no data to be read from the serial line.

So why would Serial.available return 0 even though there seems to be data being sent to serial, as the monitor does show the string I'm looking for with the pins crossed. I have also tried disconnecting the RX line on the module to prevent statements being sent over serial to interfere with the module. The documentation does not state the need to send anything to the module in order to trigger the response. In fact, if you look at the sample code the first interaction with serial (after Serial.begin(9600)) is Serial.available().

Is there anything else I can do from a debug perspective? As you might notice I'm no expert in this stuff.

18
  • 1st thought, Nano boards come in 3 and 5 volt versions. The weather station clearly says it is a 5 volt device. Maybe you have the wrong Nano?
    – st2000
    Commented Aug 27, 2018 at 9:58
  • No voltage is correct, it's hooked to 5V on the nano.
    – Jasper
    Commented Aug 27, 2018 at 10:16
  • If the serial terminal is showing you the data then it means you have the TX and RX pins connected the wrong way around.
    – Majenko
    Commented Aug 27, 2018 at 10:35
  • 2
    So, you have the module connected to the Nano pins 1 and 2, and are also trying to communicate with the PC via the Serial object and serial monitor? There is a USB/serial converter chip on the Nano that is likely conflicting with your module. You can try SoftwareSerial to get a bit-banged serial port for communicating with the module on some other pins. Commented Aug 27, 2018 at 13:27
  • 1
    @Juraj, pin 0 and 1 are connected to the usb-serial chip with a resistor. The signals can be overridden by something else, but we don't know how strong the tx signal from the module is.
    – Jot
    Commented Aug 27, 2018 at 14:46

1 Answer 1

1

It seems you have the module connected to the Nano pins 0 and 1, and are also trying to communicate with the PC via the Serial object and serial monitor?

There is a USB/serial converter chip on the Nano that is likely conflicting with your module. You can try SoftwareSerial to get a bit-banged serial port for communicating with the module on some other pins.

5
  • you mean pins 0 and 1 - RX and TX?
    – Juraj
    Commented Aug 27, 2018 at 14:18
  • Corrected answer to refer to RX/TX pins 0/1. Commented Aug 27, 2018 at 14:19
  • How is it conflicting? The device only sends data to RX of Nano. TX is not connected to the device so the Nano doesn't send data to the device, only to USB. Nothing is sent from computer to Nano and it would not stop the device.
    – Juraj
    Commented Aug 27, 2018 at 14:41
  • 1
    @Juraj , well even if nothing is sent from the computer, the tx of the usb-serial chip is connected (with a resistor) to the rx of the atmega chip. josecanuc, for 9600 baud, I prefer the AltSoftSerial.
    – Jot
    Commented Aug 27, 2018 at 14:48
  • This indeed fixed it, SoftwareSerial on pins 10 and 11 works as expected.
    – Jasper
    Commented Aug 27, 2018 at 17:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.