DEV Community

Raspberry Pi PM2.5/10 Air Quality Monitor

jeikabu on March 25, 2019

I live and work in Shanghai. We talk about the Air Quality Index (AQI) like people in other places talk about the weather (incidentally, we talk ab...
Collapse
 
halfshavedyaks profile image
halfshavedyaks

doing this as suggested:

Remove console=serial0,115200

seems to break my ssh connection to the pi - it becomes unreliable and gives me broken pipe errors when the SDS011 is active.

does the ssh need that setting? can the SDS011 be connected to the pi on the pins and still allow ssh in some way?

Collapse
 
jeikabu profile image
jeikabu

I don’t recall it breaking ssh.

The official pi docs still have that in “manual” instructions. You can see if the GUI tool does something else:

sudo raspi-config

Select option 5, Interfacing options, then option P6, Serial, and select No. Exit raspi-config.

Collapse
 
halfshavedyaks profile image
halfshavedyaks

I am using a pi zero W headless and ssh over wifi on the lan - could the ssh setup therefore be different from yours?

I can't use the gui tool as I set up the pi without a desktop.

it is hard to tell since the broken pipe events seem to be slightly random, and they don't show an error straight away. but I think the problem arises when I try to do something over ssh while the pi is communicating with the sensor.

can you share a link to the manual instructions you mention?

I confess I didn't know what a uart is until yesterday- but in this doc here:

raspberrypi.org/documentation/conf...

it says "The primary UART is the one assigned to the Linux console, which depends on the Raspberry Pi model as described above. There are also symlinks: /dev/serial0, which always refers to the primary UART"

is the linux console referred to in that quote the same as the terminal in which I am connecting over ssh? If so it suggests a conflict.

Thread Thread
 
jeikabu profile image
jeikabu

It's the same as the link in the post:
raspberrypi.org/documentation/conf...

raspi-config is probably TUI and can be used in a terminal.

Thread Thread
 
halfshavedyaks profile image
halfshavedyaks

OK thanks, now I understand what you are suggesting. I will try using raspi-config

can you tell me anything about the seeming conflict with the sensor and the console both apparently using the primary uart? how does that work?

Thread Thread
 
halfshavedyaks profile image
halfshavedyaks

I tried using raspi-config with the same results - it will read the sensor and it will communicate over ssh in the terminal, but not both at once - if any communication with the pi (including reading web page from lightpd) happens while the sensor is being read then communications break and I get a broken pipe.

Thread Thread
 
halfshavedyaks profile image
halfshavedyaks

maybe it is unrelated - hard for me to tell. but when I connect to the SD011 over usb I have no problems with the ssh connection, or at least far less often.

Thread Thread
 
jeikabu profile image
jeikabu

I don't recall having issues with SSH, but I don't remember if I was using wifi or ethernet.
Perhaps it's related to using a Pi0, I was using a Pi3.

Thread Thread
 
randyrue profile image
Randy Rue

I'm also trying to do this with an SDS011 and a pi xero w but can't get the sensor to detect via USB when I plug it in. I thought the pi might not have enough power for the sensor board as when I unplug and replug the sensor USB adapter the pi reboots, but have the same problem when I plug the sensor in via a powered USB hub with a 3A supply.

In either case I don't get any device at /dev/tty/USB0 and there's nothing in dmesg about it.

When I plug the sensor board into a linux laptop I see it in dmesg and at /dev/tty/USB0 so I'm thinking there's nothing wrong with the sensor.

Will hope to hear from you if you have any guidance and will look into connecting the UART directly in the meantime.

Thanks,

Randy in Seattle

Thread Thread
 
jeikabu profile image
jeikabu

I didn't personally try a Pi0, but I'd expect it to work. Did you follow the latest uart instructions?
Try it with another device, although unlikely it's possible your Pi0 is defective.

Thread Thread
 
randyrue profile image
Randy Rue • Edited

I have it working.

I connected directly via the serial GPIO header and disabled console output to S0 and it now works if I set the code to look to /dev/tty/S0

But it still rebooted the pi if I put the SDS011 to sleep and then woke it up, even if I connected the pi to a benchtop 5V power supply.

Finally I separated the power/ground traces of the UART ribbon cable and hacked my micro USB cable so it powers both the pi and also directly powers the SDS011. Now it detects, returns data, and the pi survives a sleep/wake cycle without rebooting.

Next I'm adding a DHT22 temp/humidity sensor and a BMP180 barometric pressure sensor so i can have a more complete "weather" station. I've installed grafana and will create a simple dashboard with the metrics available in a web interface.

Then comes four wheel drive, heated seats and a popcorn machine :)