marlon360 / opcn3-arduino

An Arduino library for the Alphasense OPC-N3 dust sensor. Compatible with NodeMCU, ESP8266.
9 stars 4 forks source link

OPCN3 Arduino #1

Open amguardia opened 4 years ago

amguardia commented 4 years ago

Hi, I am working with this sensor and I would like to test the library ... do you have any examples for use with Arduino UNO or Mega

marlon360 commented 4 years ago

I published the first release. And updated the readme. The library should work with UNO and Mega. I will write an instruction on how to connect the sensor to the board in a few days.

amguardia commented 4 years ago

excellent thank you very much. Tomorrow I will try to do the first tests. At the moment I am using the standard SPI pins of the UNO R3 with CS on pin 10 and a 5 to 3.3v level shuttle for all signals

amguardia commented 4 years ago

I just tried it with an arduino Mega and it seems to work OK. It didn't allow me to change the Chip select so I had to move the connection to A8 as it was in the example. Look at the output file, there are several values that I do not understand their meaning or in what units are expressed, comments are welcome, but in any case excellent work

MSLNS 9 0 308 36 0 628 14377 Temperature: 26.79 PM 10: 22.82 Validity: 1 Bin Counts 198 51 17 11 8 10 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Time To Cross 28 29 34 49

Sampling Period 538

Sample Flow Rate 488

Temperature 26886

Humidity 17371

pm1 1.35

pm2.5 5.34

pm10 9.13

oscgonfer commented 4 years ago

Hi!

Thanks for sharing this library. I am using it with an Arduino Mega, connecting it to the Alphasense OPC3 N3 with a shift level converter (the OPC N3 is powered at 5V but the SPI works at 3.3V according to my understanding). For /SS I am using pin 37:

// create new instance (specify SS pin in constructor)
OPCN3 myOPCN3(37);

However, I have not managed to make the alphasense to turn on, not even the FAN. Also, according to the user manual, one should be able to run it in standalone mode without SPI, only feeding 5V between pin 1 and 6.

Does any of this sounds weird to you? So far the Serial output is garble:

Initiating SPI
Validity: 0
Serial Number:
������������������������������������������������������������
DACandPowerStatus
-----DACandPowerStatus-----
Validity: 0
Fan: 119, LaserDac: 119, FanDAcVal: 119, laserDACVal 119, Laser Switch: 119, gain and autogain toggle setting: 119
----------
ConfigurationVariables
-----Configuration Variables-----
Validity: 0
Bin Boundries ADC
65021 65021 65023 65021 65535 65533 65535 65535 65535 65023 65535 65535 65535 65533 65023 65533 65535 65535 65535 65535 65535 65535 65535 65535 65533
... 
Sampa-TRPS commented 4 years ago

Hello Marlon, I’m trying acquire “PM-Data” using your “opcn3-arduino” library and an Arduino micro without success. The SS is the digital pin 12. At the beginning I only get 12:47:17.204 -> Initilize 12:47:18.187 -> Initiating SPI 12:47:20.215 -> Validity: 0 12:47:20.215 -> Serial Number: 12:47:20.215 -> ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮ 12:47:21.245 -> DACandPowerStatus 12:47:21.245 -> -----DACandPowerStatus----- 12:47:21.245 -> Validity: 0 12:47:21.245 -> Fan: 255, LaserDac: 255, FanDAcVal: 255, laserDACVal 255, Laser Switch: 255, gain and autogain toggle setting: 255 12:47:21.245 -> ---------- 12:47:22.227 -> ConfigurationVariables 12:47:22.274 -> -----Configuration Variables----- 12:47:22.274 -> Validity: 0 12:47:22.274 -> Bin Boundries ADC 12:47:22.274 -> 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 After a while the fan turns on and I get “0” everywhere. Do you have an idea, what I’m possibly doing wrong? Many thanks in advance and keep well! Thorsten

P-agullo commented 2 years ago

Good morning, I'm trying to use this Library. I'm not used to programming, I tried the example but the fan didn't switch on. myOPCN3.initialize(); doesn't switch everything on? What is the line to switch the fan/laser on ? Thank you in advance, Best