Reading analog value from Arduino 101 too large

Hi, I'm trying to read an analog value using Arduino 101 and a Current Sensor ACS712-20 at analog input #0 and AIM-for-Things-Arduino101.ino.

And I do get values... but as high as 59300?
As I read the documentation this should be [0..1023].

Any ideas?
Bless Teddy

You have HumidityReceived and Temperature Received event blocks?

Can you provide a link to this extension and its docs?

I haven't seen that before on this board.

This is part of our Arduino 101 extension: MIT App Inventor + Internet of Things

@Teddy, what are the properties set to in the designer for the Arduino101Current component? I have an intuition about why this is happening but need some more data.

For Temperature and Humidity i'm using a DHT22 at pin 4 and AIM-for-Things-Arduino101.ino

Yep. This is my fault I think. The extension code expects short (2-byte) values but the sketch converts the [0,1023] range to [0,255] and stores it in a single byte, so what you're seeing is really the 2-byte interpretation of A0 and A1. As a short-term solution you could use the bitwise-and block with 255 to get just the value for A0. Longer term we will need to update the extension code to only report the single pin.

1 Like

You are a genius!
It works. I now have a stable reading.
Is it right that value=0 is 0v and value=255 is 3.3v?

@ewpatton - I would love to get 1024 resolution instead of 255!
The Current Sensor ACS712-20 returns values from 2.5v to 0v in steps of 100mV~1A (0A-20A) and the resolution, for now, is simply too coarse to use in real-life applications.

Hi @Teddy,

I'll look into seeing if we could do an update for this but I'm not sure how long it would take to turn that around. I need to check to see if I have an Arduino 101 at home as we're not allowed in the office right now due to the pandemic.

Regards,
Evan

1 Like