There is a well-known problem with the Arduino UNO ADC (very likely affects other boards as well) that multiple analogRead() performed on different pins with no delay won't give enough time for the ADC to "cool down" and measurements will be completely wrong.
I discovered this issue while trying to make the LM35 temp sensor and an LDR measure correctly in the same circuit with the Johnny-Five library but they only work independently but not together.
In the Arduino community there are two solutions (hacks) to this:
- add a couple of ms delay between measurements on different pins
- perform two analogRead() on the same pin, dump the first and keep the second
I modified the StandardFirmata sketch by adding the dummy analogRead before the actual Firmata read and it solved all my problems:
dummyRead = analogRead(analogPin);
Firmata.sendAnalog(analogPin, analogRead(analogPin));
There is a well-known problem with the Arduino UNO ADC (very likely affects other boards as well) that multiple analogRead() performed on different pins with no delay won't give enough time for the ADC to "cool down" and measurements will be completely wrong.
I discovered this issue while trying to make the LM35 temp sensor and an LDR measure correctly in the same circuit with the Johnny-Five library but they only work independently but not together.
In the Arduino community there are two solutions (hacks) to this:
I modified the StandardFirmata sketch by adding the dummy analogRead before the actual Firmata read and it solved all my problems: