How to send the Sine wave into Analog input and Display on Thingspeak

Hello everyone.

How to send the Sine wave into Analog input (A0) and Display on Thingspeak.
I have sine wave frequency 0-100 Hz. and I want send this signal to analogRead (A0).
and Show on Thingspeak.

I’ve some question, The output on console LOGs can’t shown this signal correctly.
I attach the code and the Logs Screen as following.

Could you please advise me to correct this problem.

First of, what results do you expect from sampling a 100Hz signal at 0.0002Hz?
And then you need to convert val into a string in order to use it in Particle.publish().

3 Likes

I don’t think it will be possible to display a sine wave with ThingSpeak, since you are limited to one data point every 15 seconds per channel (you can send a string of 255 bytes each 15 seconds, so that could represent quite a few data points, but I don’t think there would be any way in ThingSpeak to parse that out into its individual data points ). You also need to sample your sine wave at at least 2x the highest frequency, though you would normally want more like 5x the frequency to get a reasonably accurate representation of your sine wave. What is the ultimate purpose of displaying this sine wave? What information do you want to get from it? How does this wave vary; does it vary quickly and/or randomly between 0 and 100 Hz?

5 Likes

I agree with @Ric, what data are you trying to show in Thingspeak? If the frequency varies perhaps you could determine the frequency and then post the frequency, and not the complete wave, to Thingspeak?

2 Likes

Could you give me an suggestion. and How to solve this problem?

It depends what you are trying to do. If it is to visualize the signal, for debugging purpose, you could use the Arduino Serial Plotter.
It works fine, but you need the Photon to be connected to a computer through serial.

2 Likes

You haven't really answered any of the open points outlined in posts 2, 3 and 4 - so no we can't really.

BTW, you had another post where I answered but that was worth nothing either?
At least you neither cared to reply on that nor incorporate the respective advice in your code posted a day later.

How Upload data from Electron to Cloud - #2 by ScruffR

3 Likes

I do not think Thingspeak was made for displaying frequencies like an oscilloscope.
But what I could suggest is to sample OFF-line for a few seconds and at least at a frequency enough to see a decent sinus (As mention Ric you need at lest 5 samples per sinus, and according to me you need more, probably 10-20 samples per sinus).
First check if you can sample this fast with Particle, (I never try this) save the data in memory (make an array) and download your sinus data using the serial port.
You can check if the sinus is fine using Excel.
Then once you found the right sampling frequency you can stop the sampling and send these data saved to Thingspeak at a lower rate, one per seconds or even less. Then interpret the data according to the frequency.
Do not forget to “string” these values.
Does this sound realistic?

2 Likes

Thank you for suggestion All, I’ll try.

Hello, If i used signal frequency 1 Hz. Particle It can be send data to cloud continue sinewave ? right.

My statement still stands

[...] help you with that.

Using Particle.publish() has a limit of 1 per second. Sampling requires at least double the frequency of the signal you’re trying to measure. Regardless of what you do, you can’t send more frequently than once a second using the publish system. So instead of sending each measured point, you could sample/calculate the frequency on the device and send that value periodically.

Then again, this has all been said before, so I’m not even sure what you’re really asking? It depends on what you want to do with it and what your requirements are. Until you’ve explained those, there’s not much more we can do…

@Moors7, @ScruffR, it seems that everyone is trying to answer the OP’s question without having ANY clarification from the OP. I suggest that before we respond any further to @tgmumean, that he (or she) clearly answer the outstanding questions. So far, questions have only been answered with other confusing questions. @tgmumean, the responsibility falls to you now to be clear as to what your requirements are.

4 Likes

@peekay123, I’d even go further and unlist this “flytrap” if there will be another “ask-another-question-but-don’t-answer-any” post.

3 Likes