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
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.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Metro M4 Airlift Lite and BME280
- Attachments
-
- secrets.py
- (363 Bytes) Downloaded 12 times
-
- main.py
- (836 Bytes) Downloaded 11 times
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Metro M4 Airlift Lite and BME280
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"
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
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()
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Metro M4 Airlift Lite and BME280
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
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 (316.71 KiB) Viewed 353 times
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Metro M4 Airlift Lite and BME280
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
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 9 times
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Metro M4 Airlift Lite and BME280
Just got it working tonight.
Thanks for your help.
Tom Henry
Thanks for your help.
Tom Henry
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Metro M4 Airlift Lite and BME280
hurray!Tom_Henry wrote:Just got it working tonight.
Thanks for your help.
Tom Henry
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Metro M4 Airlift Lite and BME280
And here are some dashboard readings:
- Attachments
-
- E576CD89-365B-4E43-92A9-0C75AFF1BA0D.jpeg (442.26 KiB) Viewed 294 times
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.