Simultaneous GPIO monitoring


I want to monitor two sensor values using two GPIO pins of MetaWearC in MetaWear app,
Is it possible to show two sensor values in a graph simultaneously?

According to the discussion below,
I checked the barometer code in Github to show pressure and altitude simultaneously.
I tried to edit the GPIO Fragment code to nest two timer.scheduleAsync, but it has not worked.


  • This is the code I make nesting.

    protected void setup() {
   ->, env) -> {
                    final Float voltage = data.value(Float.class);
                    LineData chartData = chart.getData();
                    if (startTime == -1) {
                        cl = Calendar.getInstance();
                        startTime = System.currentTimeMillis();
                    } else {
                        if (chartXValues.size() <= sampleCount) {
                            chartData.addXValue(String.format(Locale.US, "%.2f", sampleCount * samplingPeriod));
                    if (chart.getValueCount() < sampleCount) {
                        chartData.addEntry(new Entry(voltage, sampleCount), 0);
        filenameExtraString = String.format(Locale.US, "%s_pin_%d", csvHeaderDataName, gpioPin);
        timer.scheduleAsync(GPIO_SAMPLE_PERIOD, false, () -> {
        }).onSuccessTask(task -> {
                    scheduledTask = task.getResult();
                    return ->, env) -> {
                        final Float voltage2 = data.value(Float.class);
                        LineData chartData = chart.getData();
                        if (chart.getValueCount() < sampleCount) {
                            chartData.addEntry(new Entry(voltage2, sampleCount), 1);
            timer.scheduleAsync(GPIO_SAMPLE_PERIOD, false, () -> {
            }).onSuccess(task -> {
                scheduledTask2 = task.getResult();
                return null;
  • What do you mean by "is has not worked"? Provide more details.

  • Hi Eric,
    Thank you for your attention.

    @Eric said:
    What do you mean by "is has not worked"? Provide more details.

    Though I tap "start sampling" toggle button first, sampling and graphing do not start.
    The curious thing is that, after tap the toggle button (stop) and clear the graph, sampling and graphing start by tapping the toggle button.
    Both data are collected and plotted in the graph, but the sampling rate is doubled.

  • edited March 29

    FYI, I uploaded the video.

Sign In or Register to comment.