Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

Metro M4 Airlift Lite and BME280
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Metro M4 Airlift Lite and BME280

by Tom_Henry on Thu Jun 10, 2021 11:27 pm

I am using Adafruit's Metro Me Airlift Lite board and have connected Adafruit's BME280 Temperature Humidity and Pressure sensors via I2C. I am using CircuitPython and have attached the main.py program I am using that generates the following output:

Temperature: 25.7 C
Temperature: 78.2 F
Humidity: 37.4 %
Pressure: 1014.4 hPa
Pressure: 14.7 psi

See attached copy of main.py.

Now my task is to connect this to Adafruit IO. So far I have created a secrets.py file. See attached.

I am hoping someone can help me find a python code example that will help me connect to Adafruit IO. I have seen some examples but I am looking for one that uses the Metro M4 Airlift Lite board and my I2C connection.

I have created my Adafruit IO Dashboard, and feeds for Temperature, Humidity, and Pressure.

Would appreciate any help someone can give me.

Tom Henry
Attachments
secrets.py
(363 Bytes) Downloaded 4 times
main.py
(836 Bytes) Downloaded 2 times

Tom_Henry
 
Posts: 32
Joined: Wed Aug 26, 2020 8:19 pm

Re: Metro M4 Airlift Lite and BME280

by brubell on Fri Jun 11, 2021 9:29 am

This example (https://github.com/adafruit/Adafruit_Ci ... pletest.py) will work with the Metro M4 AirLift.

First, make sure it works as-is, without modification.


Then, you'll want to incorporate the Adafruit IO code into your sketch, and modify the io.publish("feedKey", value) calls to contain the values from the BME280.

For example, this snippet will handle sending the temperature sensor's value to AIO assuming you have a feed named "temperature"

Code: Select all | TOGGLE FULL SIZE
while True:
    print("\nTemperature: %0.1f C" % bme280.temperature)
    print("Temperature: %0.1f F" %f)
   # publish temperature to adafruit io
    io.publish("temperature", bme280.temperature)
    print()

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Re: Metro M4 Airlift Lite and BME280

by Tom_Henry on Fri Jun 11, 2021 4:36 pm

Ok, I changed the name of the simpltest.py program to main.py and loaded it into mu and ran the program on the Metro M4 Airlift Lite with the BME280 sensor connected to the I2C connections: SDA, SCL, 3.3 volts and ground.

Here is the main.py output:

main.py output:

Connecting to WiFi...
Connected!

Connecting to Adafruit IO...

Traceback (most recent call last):
File "main.py", line 122, in <module>
File "adafruit_io/adafruit_io.py", line 110, in connect
File "adafruit_io/adafruit_io.py", line 110, in connect
AdafruitIO_MQTTError: MQTT Error: Unable to connect to Adafruit IO.

I have attached a copy of the bottom portion of the main.py program so you can see what I did.

Any idea what is not allowing me to connect with Adafruit IO?

Thanks again,

Tom Henry
Attachments
main.py partial.png
main.py partial.png (316.71 KiB) Viewed 180 times

Tom_Henry
 
Posts: 32
Joined: Wed Aug 26, 2020 8:19 pm

Re: Metro M4 Airlift Lite and BME280

by Tom_Henry on Sun Jun 13, 2021 7:58 pm

Sunday

I have made some modifications to main.py for this project running under CircuitPython.

I have uploaded the modified file below.

Here is the output from main.py:

main.py output:
Connecting to WiFi...
Connected!
Connecting to Adafruit IO...
Connected to Adafruit IO! Listening for DemoFeed changes...
Subscribed to Tom_Henry/f/DemoFeed with QOS level 0
Traceback (most recent call last):
File "main.py", line 125, in <module>
NameError: name 'bme280' is not defined

Code done running.

I do have 3 feeds set up in my Adafruit io: Temperature, Pressure, and Humidity.

I feel like I am getting real close to getting all this to work.

As always, would appreciate any suggestions on how to make it work.

Thanks,

Tom Henry
Attachments
main.py
(4.82 KiB) Downloaded 1 time

Tom_Henry
 
Posts: 32
Joined: Wed Aug 26, 2020 8:19 pm

Re: Metro M4 Airlift Lite and BME280

by Tom_Henry on Sun Jun 13, 2021 11:52 pm

Just got it working tonight.

Thanks for your help.

Tom Henry

Tom_Henry
 
Posts: 32
Joined: Wed Aug 26, 2020 8:19 pm

Re: Metro M4 Airlift Lite and BME280

by brubell on Mon Jun 14, 2021 9:44 am

Tom_Henry wrote:Just got it working tonight.

Thanks for your help.

Tom Henry

hurray!

brubell
 
Posts: 1381
Joined: Fri Jul 17, 2015 10:33 pm

Re: Metro M4 Airlift Lite and BME280

by Tom_Henry on Mon Jun 14, 2021 5:54 pm

And here are some dashboard readings:
Attachments
E576CD89-365B-4E43-92A9-0C75AFF1BA0D.jpeg
E576CD89-365B-4E43-92A9-0C75AFF1BA0D.jpeg (442.26 KiB) Viewed 121 times

Tom_Henry
 
Posts: 32
Joined: Wed Aug 26, 2020 8:19 pm

Please be positive and constructive with your questions and comments.