First post here. I have 4 LM35 sensors connected to A0 - A3 on the SAMD21 Pro RF. Each of the sensors are soldered with various length cable from 0.5 ft to 6ft. I’m double reading the sensors (with a 100ms delay) as I have read in other forum something about the analog mux code causes instability but in the end it appears to be the input voltage.
I’m currently powering from my Laptop usb but also have a LiPo battery connected to the SAMD21 Pro RF. I have read in a forum that others using USB power have similar issues. When I disconnect from USB and display my readings on a SerLCD, the reading are far more stable (though still varying within 1-2 degrees).
The temperature is 23 Celsius and the variation while connected to USB is 13 to 40 on every reading. Its really bouncing around to the point of being entirely unusable.
I’ve been looking at this for weeks now and attempting to find a solution which appear to beyond my experience or others forum posts.
How to I provide a better stable voltage to the SAMD21 Pro RF so that the sensors are happier?
Are there other things I can do circuit-wise to make the sensor more stable?
Here is my loop code if you’d like…
void loop()
{
if (count == 0) {
SerialUSB.print("#"); SerialUSB.print(char(9));
SerialUSB.print("Out"); SerialUSB.print(char(9));
SerialUSB.print("Green"); SerialUSB.print(char(9));
SerialUSB.print("Works"); SerialUSB.print(char(9));
SerialUSB.print("Ref"); SerialUSB.print(char(9));
SerialUSB.print("Moist"); SerialUSB.println();
}
float PrimerReading;
PrimerReading = analogRead(pinOutside); delay (100);
tempOutside = (analogRead(pinOutside) / 1024.0) * cCelmV;
PrimerReading = analogRead(pinWorkshop); delay (100);
tempWorkshop = ( analogRead(pinWorkshop) / 1024.0) * cCelmV;
PrimerReading = analogRead(pinGreenhouse); delay (100);
tempGreenhouse = ( analogRead(pinGreenhouse) / 1024.0) * cCelmV;
PrimerReading = analogRead(pinRef); delay (100);
tempRef = ( analogRead(pinRef) / 1024.0) * cCelmV;
PrimerReading = analogRead(pinMoisture); delay (100);
tempMoisture = ( analogRead(pinMoisture) / 1024.0) * cCelmV;
SerialUSB.print(count); SerialUSB.print(char(9));
SerialUSB.print(tempOutside); SerialUSB.print(char(9));
SerialUSB.print(tempWorkshop); SerialUSB.print(char(9));
SerialUSB.print(tempGreenhouse); SerialUSB.print(char(9));
SerialUSB.print(tempRef); SerialUSB.print(char(9));
SerialUSB.print(tempMoisture);
SerialUSB.println();
lcd.setCursor(8, 0); lcd.print(tempOutside); lcd.print ("OUT");
lcd.setCursor(0, 1); lcd.print(tempWorkshop); lcd.print ("WS");
lcd.setCursor(0, 0); lcd.print(tempGreenhouse); lcd.print ("GH");
lcd.setCursor(8, 1); lcd.print(tempMoisture); lcd.print ("Al");
count ++;
if (count > 15) {
count = 0;
}
delay(2000);
}