Nano every + raspberry pi ground cycle noise

Hi,

I have a simple circuit to send all 8 analog inputs (with 1meg pullups. It needs to be very sensitive) serially to a computer. I use 3v as external analog reference.

When I connect it to my macs (stationary or macbookpro) the signal is OK and as expected.

When I connect to a Raspberry Pi 3b I get cyclic nose in the analog inputs. It is very obvious when you look at the serial plotter in Arduino IDE. I assume this is 60 hz ground hum.

Is it due to the Rapsberry Pi power supply? I would guess so. How do I solve this?

Another power supply, but which?
Or lifting ground in some way?
If I power the arduino externally?
Mod the power supply?

Thanks!

Without seeing any components or wiring diagrams or code it could be anything - even men from mars .

Please read forum guidelines and show what you have


...I knew you'd say that. :slight_smile: I took a chance, not being at the studio.

I put the naked wires on the far right in water to detect when it moves. Brown is ground, blue is analog channel one.

Important here is that it works ok with the macs+nano but not with the Raspberry pi+nano It seems like ground is floating with the raspberry pi.

 //for use with water sculptures

int channel = 0;

//int inPins[11] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

int analogPins[8] = {0, 1, 2, 3, 4, 5, 6, 7};

const int AnalogArrLen = sizeof(analogPins) / sizeof(analogPins[0]);

// för att indentifiera aktuell bräda:

int outPins[1] = {13};

void setup() {
/*
  for(int i = 0; i < 11; i++) {
    pinMode(inPins[i], INPUT);
  }
*/
  for (int i = 0; i < 1; i++) {
    pinMode(outPins[i], OUTPUT);
  }

  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);
  pinMode(A4, INPUT);
  pinMode(A5, INPUT);
  pinMode(A6, INPUT);
  pinMode(A7, INPUT);

  analogReference(EXTERNAL);
  
  //Serial.begin(115200);
  Serial.begin(9600);
}

void loop() {

//DO OUTPUTS
  
if (Serial.available()) {
     
    static int temp;
    byte in = Serial.read();
  
    if (isDigit(in)) temp = temp * 10 + in - '0';

    //quote out this section below to avoid crash ella
    
    else if (in == 'c') {
     channel = temp;
      temp = 0;
  }
       
   else if (in == 'd') {
     digitalWrite(outPins[channel], temp);
     temp = 0;
  }
/*
   else if (in == 'p') {
      analogWrite(pwmPins[channel], temp);
      temp = 0;
  }
*/
    //end quote out here
  
  }
    
// DO INPUTS

Serial.print("analog");
  
  for(int i = 0; i < AnalogArrLen; i++){
  //for(int i = 0; i < 6; i++){
  

    unsigned int analogVal = analogRead (analogPins[i]);
    
    Serial.print(" "); 
    Serial.print(analogVal);
  }
  
  Serial.println(); 
/*  
  Serial.print("digital");
    
  for(int i = 0; i < 11; i++) {
    
    unsigned int digitalVal = digitalRead(inPins[i]);
    
    Serial.print(" ");
    Serial.print(digitalVal);
  }  
  
  Serial.println(); 
*/

}

I don’t think we have the full story !
Look at analog read examples , analogs don’t need setting up in setup .
Is the pi powering the nano ?
How does it connect to the nano ever ? The pi power supply could be noisey or not upto supplying power .
Check voltage requirements in the spec for the nano every .

The 3v pin is not a great reference source , use the internal reference or leave as default if measuring ratio relative to the supply .

Often worth taking multiple analog readings and averaging .
Your layout with high impedance inputs will be prone to noise pickup , especially with significant lead lengths .
Some filtering may also help

You say something about “ water “ are you detecting it or trying to make some analysis of it ?

[quote="hammy, post:4, topic:1344533"]
don’t think we have the full story !
Look at analog read examples , analogs don’t need setting up in setup .

-Ok, but it does not change anything.

Is the pi powering the nano ?

-Yes, by the usb cable

How does it connect to the nano ever ?

By usb cable

The pi power supply could be noisey or not upto supplying power .

Yes but it is an official rp power supply

Check voltage requirements in the spec for the nano every .
The 3v pin is not a great reference source , use the internal reference or leave as default if measuring ratio relative to the supply .

-Oh, I have been advised here at the forum that the 3v pin is more stable than the 5v.

Often worth taking multiple analog readings and averaging .

-yes but averaging does not really work when there are cyclic extreme noise.

For example on a scale 0-1023 the range to read is between 400 and
600. Then the cyclic noise come as a peak of 1020-ish each second.

Your layout with high impedance inputs will be prone to noise pickup , especially with significant lead lengths .

-yes that I know, but it has to be very sensitive.

Some filtering may also help

-like capacitors?

You say something about “ water “ are you detecting it or trying to make some analysis of it ?

-yes I am measuring the water level in an interactive sculpture. The values are translated to sound. Its comparable with a musical instrument.

Thanks!

Long wires and high impedance are just an invitation to pick up the AC from the surrounding environment. Replace the long wires with shielded twisted pair wires with one of the two connected to a local ground. The shield must be connected to the same ground at ONE END only.

Yes! We made some experiments with shielding and it shows it can be a solution.

What about adding a magnet around the cables?

What about it? Magic magnets! When we bought this place 18 years ago there were magnets on all the water pipes. Well water! Quickly took them off. If you believe in magic magnets, use them for sure.

Dont know about that, but what I meant is those thick metal rings you can find on the cable of power supplies. Usually they are enclosed in a plastic case. Sorry if I was confusing

Oh, those are NOT magnets. They are called ferrite or powered iron cores. They create an inductance that will limit the radiation of noise from the switching power supply. Otherwise the wiring from the power supply acts like an antenna. Not suitable for 60 cycle noise.

Best to use the shielded wiring to begin with.