1

I want to sample in the raspberry pi, since I am reading the analog values, the detail is that I need a time function which allows me to have the time in a vector of what I am sampling.

there are a function to do this

  • 1
    I'm sorry, but as written it is impossible to tell what you are asking. It would help if you clarify whether you are already reading the data on the Pi, and if so, what the purpose of the "clock" would be. Do you mean you want the pi to read a sample at timed intervals? – goldilocks Jul 04 '19 at 14:18
  • yes, i want to save the value that i read in a vector y and the time when i sampled this value in vector t. After that i want to plot this relation – Jesus Miguel Herrera Jul 04 '19 at 14:23
  • 1
    Sounds like a general programming question that is dependent on what programming language you are using. In any case, such questions belong on our larger parent site, [Stack Overflow](http://stackoverflow.com/). – goldilocks Jul 04 '19 at 14:28
  • @Jesus Miguel Herrera, your question using maths terms "time function" and "vector" is a bit newbie scary. Let me try to translate your question in everyday newbie language as follows: "I wish to use Rpi to measure the output of say, a temperature sensor, measuring room temperature every hour of the day. I wish to store and print the measurements as below: "12:00 - 25C, 13:00 - 26C, ..." I know the senor outputs analog values, and I know Rpi, not like Arduino, doesn't have ADC pins. So I need an ADC to help Rpi. Everybody seems like MCP3008. Is it good for newbies? – tlfong01 Jul 05 '19 at 03:21
  • @tlfong01 hi, i am using an arduino like serial port to read analog values, my problem is that i want to plot a relation time/volt, but i don't know how create the time vector while i read the analog value – Jesus Miguel Herrera Jul 05 '19 at 12:48
  • Ah I see. So if you are using a serial port, say Rpi UART to read the sensor output, what you get is already digital values converted from analog output of sensor. So if I guess correctly, what you want to know is how can Rpi read the real time clock. There are two ways: (1) you can get the realtime clock from the Internet, if you are online, (2) If you are not connected to Internet, you can use a hardware real time clock module, such as DS3231. Perhaps I can tell you more details tomorrow or day after tomorrow. – tlfong01 Jul 05 '19 at 13:44
  • You might also like to read my answer to the following question and see if that is helpful to you. "What is the most apt way to setup a RTC?" ( https://raspberrypi.stackexchange.com/questions/99490/what-is-the-most-apt-way-to-setup-a-rtc ) If you can read the time, then you can build in python a list of pairs (tuples) , each of which consists of (a) network time and (b) the digital sensor value you read from the serial port. – tlfong01 Jul 05 '19 at 13:49
  • @tlfong01 thank i will read, i would like work with realtime clock from internet, because in my country is hard find an hardware – Jesus Miguel Herrera Jul 05 '19 at 14:32
  • @Jesus Miguel Herrera, it is good to start with the python "datetime" module. DS3231 RealTimeClock has a steep learning curve and I usually don't recommend to newbies. You may also like to search this forum for "network time" for more info. I forgot where is my another answer with a demo program. Anyway, the following PenZu entry should also be helpful to you: ( https://penzu.com/p/8e883ae5 ) BTW, My PenZu stuff is saved under Chinese Windows 10. Do let me know if you cannot read it. Happy Python Programming! :) – tlfong01 Jul 06 '19 at 02:59

0 Answers0