Pico Enviro + Pack MQTT help

Greetings"
I recently purchased a Pico Enviro + Pack and I am trying to use the Enviro_all_mqtt.py program to sensor data to Adafruit IO data logging/display site. I cannot seem to get the data to display on the Adafruit site. Has anyone out there tried to do this and be able to assist me?

In the enviro_all_mqtt.py --------- There are four lines that need to properly filled in.
I need some help with with placing the correct info in these places. I have tried putting my Adafruit username and key into the bottom two lines, but cannot get it work, and sure what to put line 2.
Any help would be greaqtly appreciated
thanks
Tom

MQTT broker settings

CLIENT_ID = “EnviroPlus”
SERVER_ADDRESS = “broker_IP_goes_here”
MQTT_USERNAME = “broker_username_goes_here”
MQTT_PASSWORD = “broker_password_goes_here”

Hello! There’s some documentation here about what settings you need to post MQTT data into Adafruit.io here: Adafruit IO API Reference . It’s quite particular about formatting, so you’d probably also need to tweak the example to format your MQTT data in the way it expects - Adafruit IO API Reference

I found the HTTP API easier to figure out than the MQTT one - here’s my (possibly hacky) code that posts data to Adafruit that way: Enviro + into adafruit.io · GitHub

Hel

Thanks for the info.
I have some addition questions.

  1. On the Pico enviro + pack, when I send using enviro_all_mqtt program developed by Pimoroni, I get an IP address, then it says wait minute. The LED above the display lights up red. Is this an error with the program? If so, the program must have some sort of problem, as there is also an error message displayed, I believe at line 275. Has the Enviro_all_ mqtt.py actually been tested by Pimoroni?

  2. In the enviro_all_mqtt.py program should the Adafruit IO address line also include the group name?

  3. Your program that you included at the end of the email.
    Is that program for the Pico enviro+ pack?
    I would like to try if out.

Thanks
Tom

Hel:

I ran the “[enviroplus_into_adafruitio.py” mentioned in you post to me.
I get an error message Error: 401 b’Unauthorized’ , at the same time the LED above the LCD displays in red while the program runs.

Should the LED display red?
What does the error mean?
I am so frustrated with this project!!!
tom

Hey hey

I wrote (and tested!) the MQTT example, but I wrote it for the purposes of sending data into Home Assistant, not Adafruit.io. MQTT is just a protocol for sending messages, different services will require data formatted in different ways to be able to accept it. The MQTT API documentation I linked to above will tell you the format in which the data needs to be sent if you want to adapt it to work with Adafruit IO.

Yes, the code I linked above is for Enviro + Pack. 401 b’Unauthorized’ suggests your login credentials might be wrong, did you add in your adafruit username and key on lines 25 and 26?

If you’re using a free Adafruit.io account you might want to grab the updated code from Enviro + into adafruit.io · GitHub - I’ve reduced the number of feeds it sends as it was exceeding the data limits and giving me an ‘unprocessable entity’ error.

Greeting Hel:

I loaded your latest enviroplus_into_adafruitio.py into the Pico enviro + Pack.
With the addition support packages and I was successful in sending data to Adafruit IO. - yea

A few questions

  1. I now need to be able to display all 9 data items at once - is that possible?
  2. In your program - I assume you are still displaying pm1, pm2.5 and pm10 - I only saw zeros for those three items?
  3. Is it possible to send some of the other pm data displayed in the simple pm5003.py demo?
    Thanks so much for your help
    I will now study the program and the Adafruit IO in more detail.
    Thanks much
    Tom

Hooray! Glad that helped :)

  1. I now need to be able to display all 9 data items at once - is that possible?

You mean display your data on Adafruit.io? You can do that by setting up a dashboard - there’s some instructions on how to do that in the Enviro tutorial (scroll down to the section on ‘viewing your data in adafruit.io’)

  1. In your program - I assume you are still displaying pm1, pm2.5 and pm10 - I only saw zeros for those three items?

Is your Enviro+ inside? My particulates look to be reading in the 0-1 range most of the time if I don’t have the window open (unless I’m soldering something!).

  1. Is it possible to send some of the other pm data displayed in the simple pm5003.py demo

Yep, the pms5003.read() grabs all the data from the particulate sensor, so you could edit or add more lines to the section that sends the data (under #format our data for adafruit.io) to send different data from this sensor.

There’s a basic particulate sensor example here that should show you what other data is available.

Hel

Thanks so much for your help and insight.ltom

1 Like

Hel
I am getting more familiar with the Pico enviro + pack and data sending.
I have a question – I got everything working pretty well now, i want to make the enviroplus_into_adafruitio.py program start automatically from a external battery on startup of the pico enviro+ pack. I changed the program name to main.py but that did not allow the program to start automatically? How can start the program automatically?
thanks
tom

Yep, saving your program as main.py should make it run automatically.

Some USB battery packs don’t start supplying power automatically when you plug something in, and some won’t supply power if the current draw isn’t high enough - might be worth checking if that’s what is happening?

Hel

Got it working now
Thanks for all your help
Tom

1 Like