Trouble using popen() on a pi3

I have a simple program to get data from a python script and publish it. when I call a simple python script (print(‘Hello’)) everything works fine. But the script I want to call has a delay of 10 seconds (scanning bluetooth LE sensors) before it returns a string. If I run the same code on the Pi itself it waits the 10 seconds and then prints the data. But the Particle code doesn’t wait and returns no data.

Having some code to look at would definitely help :wink:

1 Like

Not much to it:

#include <stdio.h>

char c[20];
FILE *pyin;

void setup() {

void loop() {
    if (Time.second() == 0){

void getTemp(){
    pyin = popen("/root/python/","r");
	Serial.printlnf("Data from Python: %s",c);

Thanks peekay123

The fix proved to be simple, added a ‘delay(x)’ between the popen a fscanf lines.