0

I am currently working on a landslide-detection project coded in Python for a research group. At present we have two different sets of sensors running on two different RPis. One RPi has a strain gauge & one RPi has a set of temperature sensors. I have been tasked with running both sets of sensors at the same time & trying to aggregate data from them onto one CSV file on the temperature RPi via bluetooth.

One of the major sticking points of this current task is that I need to have the data aggregated onto the temperature RPi line-by-line in the format [Strain timestamp][Strain data] - [Temp timestamp][Temp data]. This is opposed to having two different batches of data on the RPi.

This means that each RPi needs to have a synced time over Bluetooth among other things. What way should I go about this? Do I need a common point for each of the RPis to sync their time to, or could I make the temperature sensor RPi wait for the strain gauge RPi to send over before it takes a reading?

3
  • 1
    Don't use BT. Use WiFi or ethernet. For an easy method of shifting data use MQTT (one Raspberry runs mosquitto and a subscriber, the other runs a publisher).
    – Dougie
    Apr 11, 2022 at 21:04
  • WiFi or Ethernet may not be suitable if the Pi pair are to be placed out in the open away from suitable wireless infrastructure. BT doesn’t need such infrastructure but you’ll then need to sync clocks over BT. A Google does yield a few projects that have done such but it’s non trivial.
    – Nick
    Apr 12, 2022 at 21:01
  • @Nick wifi should work though if one RPi syncs to an NTP server on the other correct? The RPis don't need to nessecarily send data anywhere offsite. Apr 12, 2022 at 21:10

1 Answer 1

1

I think if you try timing their communication it should be well within reasonable bounds for something like this -- I'm presuming the samples are relatively far apart, seconds or minutes and not milliseconds. If they are connected to the internet, their system clocks will be set from an NTP server and hence very close, less than a second deviance. If they aren't, you should do the communication over wifi, or, if they are close enough, connect them with an ethernet cable. Using bluetooth seems a waste of time unless there is some specific reason for it.

If you do that (using normal TCP or UDP networking), one Pi can be the lead in the sense of taking a reading, then sending a message to the other containing the reading data, and then that Pi can take a parallel reading and store the data together. This is something that can be done in milliseconds, so again, I do not see latency being an issue in context.

1
  • I think that this is probably the best option. Although I would like to mention that one sensor takes readings at 80hz & the other at - or below - 10hz. Although, I highly doubt that the latency when transmitting over WiFi will be an issue, even if we decide to do 80hz data transmission. Apr 12, 2022 at 3:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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