Arduino Uno Wifi Pins 4-5 issue

I recently got an Arduino Uno Wifi (flashed it with WiFi link library - GitHub - arduino/UnoWiFi-FirmwareUpdater-Plugin: Arduino Uno WiFi Firmware Updater Tool for Arduino IDE) and i have created a simple code to read analog values from a Flex Sensor.

I am using the code below (copy paste from the official website)

const int FLEX_PIN = A4; // Pin connected to voltage divider output

// Measure the voltage at 5V and the actual resistance of your
// 47k resistor, and enter them below:
const float VCC = 4.98; // Measured voltage of Ardunio 5V line
const float R_DIV = 47500.0; // Measured resistance of 3.3k resistor

// Upload the code, then try to adjust these values to more
// accurately calculate bend degree.
const float STRAIGHT_RESISTANCE = 37300.0; // resistance when straight
const float BEND_RESISTANCE = 90000.0; // resistance at 90 deg

void setup() 
{
  Serial.begin(9600);
  pinMode(FLEX_PIN, INPUT);
}

void loop() 
{
  // Read the ADC, and calculate voltage and resistance from it
  int flexADC = analogRead(FLEX_PIN);
  float flexV = flexADC * VCC / 1023.0;
  float flexR = R_DIV * (VCC / flexV - 1.0);
  Serial.println("Resistance: " + String(flexR) + " ohms");

  // Use the calculated resistance to estimate the sensor's
  // bend angle:
  float angle = map(flexR, STRAIGHT_RESISTANCE, BEND_RESISTANCE,
                   0, 90.0);
  Serial.println("Bend: " + String(angle) + " degrees");
  Serial.println();

  delay(500);
}

The code does not work in the Arduino Uno Wifi as it does not show any change in the bend degrees. However, it works in another Arduino Uno i have for testing.

Also i made a test and i found out that pins 4 and 5 in Arduino Uno Wifi produce current for some reason even with an empty script, capable of lighting a LED (while pins 0,1,2,3 do not light it up).

The same applies for the values for the sensors. For example if i put the flex sensor in analog pin 0 then the values change when i bend it (e.g. 362 read not bend and 600 bend which is fine).

On the other hand when i put the pin of the sensor in A4 or A5 there is a change from 1023 (starting value) to 982 and it wont change no matter if i bend the sensor.

Also posted in Read analog input from Arduino Uno Wifi Wire/TWI/I2C pins (A4 & A5) - Stack Overflow

Also posted at:

If you're going to do that then please be considerate enough to add links to the other places you cross posted. This will let us avoid wasting time due to duplicate effort and also help others who have the same questions and find your post to discover all the relevant information. When you post links please always use the chain links icon on the toolbar to make them clickable.

pins A4 and A5 are Wire/TWI/I2C pins and there is the additional uart chip connected to which the esp8266 is connected.

Arduino Uno WiFi Developer Edition connects ATmega328 microcontroller to ESP8266 using additional on board UART chip SC16IS750 (here as module). This additional UART is connected to Atmega as I2C device.

zarcarsh:
I recently got an Arduino Uno Wifi (flashed it with WiFi link library - GitHub - arduino/UnoWiFi-FirmwareUpdater-Plugin: Arduino Uno WiFi Firmware Updater Tool for Arduino IDE)

? WiFi Link can't be flashed with UnoWiFi-FirmwareUpdater-Plugin

At first im sorry i got a link wrong for the firmaware, the correct one is GitHub - arduino-libraries/WiFiLink-Firmware: Arduino WiFi Link firmware for ESP8266 based boards

As A4 and A5 are Wire/TWI/I2C pins, is there any way i can read analog input by connecting my flex sensors from those pins?

zarcarsh:
As A4 and A5 are Wire/TWI/I2C pins, is there any way i can read analog input by connecting my flex sensors from those pins?

no. the SC16IS750 is wired on board and whatever you do, the line and connection will disturb the analog reading. use another analog pin or if you don't want to use the wifi capability, buy a regular Uno