-1

How can I take data from my house main power and reconstruct it signal? I used an transformer and an inverter amplifier to low voltage to 5 volts and read it with A0 analog pin, but I got a very strange datan and just a few numbers

data = analogRead(A0); Serial.println(data);

  • What kind of data are you trying to retrieve? – VE7JRO Nov 6 at 21:32
  • The Sin wave at 60Hz – Victor Vital Nov 6 at 21:34
  • 1
    Please show us the sketch you used that gave you the "...very strange data and just a few numbers". – VE7JRO Nov 7 at 1:40
  • Please show us a complete sketch and a sample of the corresponding data – chrisl Nov 7 at 23:00
1

The Serial output on an Arduino is quite slow. By printing your output, you will slow down the readings so much that it will appear to be nonsense.

You should collect a series of readings into a C array of floats in RAM, stop recording, and then log that array of values.

Note that you don't have a lot of RAM to work with on most Arduinos, so you will only be able to record a small number of values. A Mega 2560 has a lot more memory than others (8KB). It's still not a lot, but better than other boards. One of the ARM based Arduinos will have both a much faster processor and a lot more RAM.

  • I have working code which could be added to this answer after a little cleanup github.com/jandrassy/Regulator/blob/… – Juraj Nov 7 at 8:58
  • Is the speed of data transmission really such a big problem here, that you need to buffer the data? I mean, it's only 60Hz. I would think, that is is sufficient to choose a higher baudrate. – chrisl Nov 7 at 22:59
  • 1
    "Is the speed of data transmission really such a big problem here...?" Yes. Imagine a Serial.write() takes 1/10th of a second. You need what, 10 readings per full cycle of a sine wave to get a crude picture of its shape? That would mean you would need 600 readings/second. If instead you get 10 readings per second, out of phase with the wave, you're going to see seemingly random readings. – Duncan C Nov 7 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.