How to connect a BME680?

@shramik_salgaonkar Thanks, that is code for both sensors? Where I have to save it? Is this important to save that file in:
/home/pi/bme680_test/
/home/pi/Cayenne-MQTT-Python/examples
/home/pi/
folder?

save where you had saved the bme and cayenne code.

Hi, I’m home now and try tu run Your new code:

python test_bme680.py 
  File "test_bme680.py", line 58
SyntaxError: Non-ASCII character '\xce' in file test_bme680.py on line 58, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
pi@raspberrypi:~/bme680_test $ 

add # -*- coding: utf-8 -*- on top of the code

Like this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cayenne.client
import time
import bme680
import logging
from __future__ import print_function
import serial
import struct
import sys
import time
import json
import subprocess

yes.

There’s also error:

  File "test_bme680.py", line 60
SyntaxError: Non-ASCII character '\xce' in file test_bme680.py on line 60, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

can you share the line on 60?

Line 60 is empty:

58    #print("PM 2.5: {} μg/m^3  PM 10: {} μg/m^3 CRC={}".format(pm25, pm10, "OK" if 59(checksum==r[2] and r[3]==0xab) else "NOK"))
60
61
62 def process_version(d):

delete line 58

Deleted and now this :confused:

  File "test_bme680.py", line 8
    from __future__ import print_function
SyntaxError: from __future__ imports must occur at the beginning of the file

can you do what the error says to do?

I add that line

from __future__ import print_function

at the begginning of file and now it works but don’t send data to dashboard, stops at this:

read-all.py - Displays temperature, pressure, humidity, and gas.Press Ctrl+C to exit!
Calibration data:
par_gh1: -51
par_gh2: -12741
par_gh3: 18
par_h1: 880
par_h2: 990
par_h3: 0
par_h4: 45
par_h5: 20
par_h6: 120
par_h7: -100
par_p1: 37570
par_p10: 30
par_p2: -10627
par_p3: 88
par_p4: 6075
par_p5: -104
par_p6: 30
par_p7: 68
par_p8: -5847
par_p9: -1284
par_t1: 26188
par_t2: 26263
par_t3: 3
range_sw_err: 0
res_heat_range: 1
res_heat_val: 42
t_fine: 115376
Connecting to mqtt.mydevices.com:8883


Initial reading:
gas_index: 0
gas_resistance: 12946860
heat_stable: False
humidity: 36.952
meas_index: 0
pressure: 998.62
status: 32
temperature: 22.53
Y: 18, M: 11, D: 16, ID: 0xd30d, CRC=OK


Polling:
Connected with result code 0
SUB v1/06487d60-1537-11ea-84bb-8f71124cfdfb/things/f9f06b50-1602-11ea-8221-599f77add412/cmd/+
PUB v1/06487d60-1537-11ea-84bb-8f71124cfdfb/things/f9f06b50-1602-11ea-8221-599f77add412/sys/model Python
PUB v1/06487d60-1537-11ea-84bb-8f71124cfdfb/things/f9f06b50-1602-11ea-8221-599f77add412/sys/version 1.1.0
PM2.5:  22.3 , PM10:  31.5
PM2.5:  22.7 , PM10:  31.9
PM2.5:  22.8 , PM10:  31.6
PM2.5:  23.0 , PM10:  32.0
PM2.5:  23.0 , PM10:  31.7
PM2.5:  22.7 , PM10:  31.2
PM2.5:  23.4 , PM10:  32.0

Does it stops after that?

Yes, it stops. Only display that data I show You above.

are yo sure? can you try again.

now it stops here:

python test_bme680.py 
read-all.py - Displays temperature, pressure, humidity, and gas.Press Ctrl+C to exit!
Calibration data:
par_gh1: -51
par_gh2: -12741
par_gh3: 18
par_h1: 880
par_h2: 990
par_h3: 0
par_h4: 45
par_h5: 20
par_h6: 120
par_h7: -100
par_p1: 37570
par_p10: 30
par_p2: -10627
par_p3: 88
par_p4: 6075
par_p5: -104
par_p6: 30
par_p7: 68
par_p8: -5847
par_p9: -1284
par_t1: 26188
par_t2: 26263
par_t3: 3
range_sw_err: 0
res_heat_range: 1
res_heat_val: 42
t_fine: 116556
Connecting to mqtt.mydevices.com:8883


Initial reading:
gas_index: 0
gas_resistance: 12946860
heat_stable: False
humidity: 37.517
meas_index: 0
pressure: 998.43
status: 32
temperature: 22.76

after ctrl+c:

^CTraceback (most recent call last):
  File "test_bme680.py", line 179, in <module>
    cmd_firmware_ver()
  File "test_bme680.py", line 108, in cmd_firmware_ver
    d = read_response()
  File "test_bme680.py", line 72, in read_response
    byte = ser.read(size=1)
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 483, in read
    ready, _, _ = select.select([self.fd, self.pipe_abort_read_r], [], [], timeout.time_left())
KeyboardInterrupt

try sudo python test_bme680.py `

Also stops at the same moment :confused:

try running this code again.