Python stop execution

Hi, i have a setup: pi 4b bme680 and are using the python exampel ( to run it, i need to stop that script after one sec i only need one or a few lines to put into my database every five min., i have tried:
import sys
and they all give:
syntax error
Any good ideas

One way to do it is to add an
import time
at the top, and then do a
in the while true loop.
is 5 minutes.
And just leave the file running.

Thank you for your answer, i am a python newbee could you please show where to place time.sleep i have done import time on top and done >>>import.time in python3
while True:
if sensor.get_sensor_data():
output = ‘{0:.2f} C,{1:.2f} hPa,{2:.3f} %’.format(,,

Sorry for missing indent in copy/paste

Code tags are three ` at the top and three more at the end of your code.
Try this, you may have to change the indent on the time sleep line, not sure.

#!/usr/bin/env python

import bme680
import time

print(""" - Displays temperature, pressure, and humidity.
If you don't need gas readings, then you can read temperature,
pressure and humidity quickly.
Press Ctrl+C to exit

    sensor = bme680.BME680(bme680.I2C_ADDR_PRIMARY)
except (RuntimeError, IOError):
    sensor = bme680.BME680(bme680.I2C_ADDR_SECONDARY)

# These oversampling settings can be tweaked to
# change the balance between accuracy and noise in
# the data.


    while True:
        if sensor.get_sensor_data():
            output = '{0:.2f} C,{1:.2f} hPa,{2:.3f} %RH'.format(

except KeyboardInterrupt:

It is perfect, thank you very much, i will now pipe the output to a text file for further processing, i have made a bash script to load the database from a text file and run that script by crontab

No problem, glad to help. I usually run those types of files automatically on boot up via crontab.
I have several Enviro+ like builds displaying temp, humidity and pressure.
I don’t send anything to the cloud though, or log the data. I have one setup that graphs to a small LCD so I can see trends. I like to know if the pressure is going up or down etc.