A0 pin behavior Uno R4 wifi

I’m noticing an issue with the Uno R4 wifi A0 pin, where it stops sending digital out voltage after it connects to the cloud. If I download a standard sketch without cloud interaction it behaves perfectly well. But when I make it into a Thing and connect to the cloud it stops sending voltage out of A0. All other pins behave as expected. I noticed this problem when using the well known LED light cube project that uses 20 pins as digital outputs (A0-A5 and D0-D13). I know that the Uno R4 WiFi pin A0 is capable of true analog output using DAC, I wonder if that could be the issue. Or seems more likely it is somehow related to use of A0 or the DAC for cloud interaction?

  • The light cube sketch is rather large. I have tested on simple sketches and got same result.
  • I have tried it with 0 cloud variables and still get the problem with A0.
  • I have used analogWrite (A0,255) and there is no issue, it maintains about 5V to pin A0.

I can confirm the same behavior on my Uno R4 though you did a lot more troubleshooting. I had to abandon the pin when I couldn't get it to do what I needed. I built my program on an UNO R3 and had no issues and had immediate problems on the R4 I have hooked to the cloud.
I started using the R4 for the simple fact that my project is too hard to move near my development PC anymore.
Not sure how we get visibility to this issue. I'd like at least an explanation if a solution is not possible.

1 Like

Ultimately we still don’t have an answer to this issue, but another workaround I have found is to instead use BLE to communicate to the light cube. Apparently the A0 pin conflict is only occurring when the Arduino cloud is used.

Hi @jonmansfield. I found the culprit here:

The "ArduinoIoTCloud" library does an analogRead on pin A0 in order to seed the random number generator (assuming the pin is floating, the analog reading has a fairly random value) in preparation for requesting the time from an NTP server. The analogRead call puts the pin into INPUT mode.

The library gets the time does this during the initialization phase in preparation to connecting to Arduino Cloud.

The workaround is to add code to the loop function of your sketch to change the pin mode back to OUTPUT once the ArduinoIoTCloud is done using it. Something like this:

  static bool pinModeRestored = false;  // Track state to avoid unnecessary calls to the fairly slow ArduinoCloud.connected()
  if (!pinModeRestored && ArduinoCloud.connected()) {
    pinMode(ledPin, OUTPUT);
    pinModeRestored = true;
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.