BME680 to Mote


#1

Hey all, bit of a novice so any help would be great.
I’ve got the BME680 sensor running in my classroom, and it’s reading the air quality pretty consistently.
I’ve also got the MOTE lights that I’ve played with before.

I’m looking for some help with the python to get them linked. I have nice ideas but I’m rubbish at the python! I was thinking something along the lines of a colour change as the air quality drops or rises. I just don’t know how to get the mote to be able to read the air quality value!

I’d be forever grateful!
Thanks!
Matt


#2

I’m not sure if this will help but I do something similar I read the temperature with a BMP180, then use that to turn on one of four 10mm LEDs. I turn the LEDs on via GPIO pins. It may look like there is redundant code in there but the extra lines are to make sure only 1 LED is on at a time.
Red if the temp is above 25c.
Green if less than 25c but more than 13c.
Yellow if less than 13c but more than 0c.
And Blue if less than 0c.
I do it with if and statements.

 t = bmp.read_temperature()
    t = (round(t))
          
    if t <= 0: 
        tc = [w, w, 255]  # blue
        GPIO.output(16, 1) #Red
        GPIO.output(19, 1) #Yelow
        GPIO.output(20, 1) #Green
        GPIO.output(21, 0) #Blue
        
    elif t > 0 and t < 13:
        tc = [255, 255, w]  # yellow
        GPIO.output(16, 1) #Red
        GPIO.output(19, 0) #Yelow
        GPIO.output(20, 1) #Green
        GPIO.output(21, 1) #Blue
    elif t >= 13 and t <= 25:
        tc = [w, 255, w]  # green
        GPIO.output(16, 1) #Red
        GPIO.output(19, 1) #Yelow
        GPIO.output(20, 0) #Green
        GPIO.output(21, 1) #Blue
    elif t > 25:
        tc = [255, w, w]  # red
        GPIO.output(16, 0) #Red
        GPIO.output(19, 1) #Yelow
        GPIO.output(20, 1) #Green
        GPIO.output(21, 1) #Blue
        
    msg = "and %sc" % (t)
    sense.show_message(msg, scroll_speed=s, text_colour=tc)

#3

That’s just a little piece of a big python file I use to display info on my sense hat led matrix. The LEDs are a quick look secondary indicator. The code above also changes the color of the message showing the current temp on the sense hat. It’s a continuously scrolling message with date, time, temp, humidity, pressure, that just repeats over and over again.


#4

Hello Matt,

The units for the air quality is Ohms. From my observations over the last few days (an I haven’t spent time looking at the Pimoroni or Bosch docs), the values change significantly even for my stationary environment (and my desk is far away from the kitchen).

Here is some code snippet (from the Pimoroni examples) that can help you get started:

import bme680
import time
sensor = bme680.BME680()
...
    try:
    	while True:
    		if sensor.get_sensor_data():
    			if sensor.data.heat_stable:
    				# \u00f0 == omega upper-case
                   #print("{0},{1:.0f},'Ohms'".format(output, sensor.data.gas_resistance))
    				# use to set LED display
    			else:
    				# use to blank display
    		time.sleep(60)
    except KeyboardInterrupt:
    	# catch exception

Regards.