Alphasense have quite interesting particle sensor, not cheap, but quite capable.
It can work as standalone logger, writing on internal 16GB SD card (new file every 24h), or can be setup/firmware update/control/log via SPI interface.
According to them they probably going to release later this year Arduino and RPi libraries (ESP8266 WiFi and nRF51, 52 BLE can be quite interesting too), but currently there is only one publically available for RPi.
I am going to try some Arduino porting myself, but was wondering if someone does work on the same time or may be even have a working example/library for Arduino or another platform (except RPi).
If you use the right mode, lower the clock as in the script to 500kHz, use delays as in the script, you can try and test, I think the sensor will not be damaged if the code is wrong.
The part to read the firmware information is interesting, write 0x3F, wait 9ms, transfer 60 bytes, and you have the firmware information.
Thanks for the tip.Will try this next week, just will make another cable. Now using it their PC software, and SPI/UART/USB adapter.
Have you test OPC yourself?
No, I only read the Python code.
A cable ? Not too long I hope, SPI at 500kHz requires something very short. Maybe you can lower the clock speed, but I would start with 500kHz, just as in the Python code.
Yes, it is short length - PC version runs with adapter SPI/USB implemented with PIC MCU, and connector is awfully small Micro Clasp or something similar, so I made custom short cable to Arduino.
Always wonder why good, old UART is not used...
I am trying as well to interface the Alphasense OPC-N2 with Arduino Uno via the SPI bus, but I haven't had much luck so far.
I have read the proposed codes from github GitHub - dhhagan/opcn2: C++ Library for the Alphasense OPC-N2 particle counter (not for Arduino) and I have tried to write a simple arduino sketch including only the SPI library, that just establishes a SPI communication bus between Arduino and OPC and just turns on the OPC (fan and laser power on).
The SPI logic lines of the OPC are not 5V tolerant (Arduino logic lines are 5V) so I used resistors (2k and 1k (a voltage divider)) to lower the voltage at 3.3 V. Because at startup OPC draws surge current of 1 A, I decided to supply the OPC with a DC power supply (3.3V).
Attached you will find my Arduino sketch and the circuit.
The problem is that the OPC does not respond as expected; does not return the bytes expected (just random numbers) and does not turn on.
For those of you that are interested, I have found the problem; it was so simple after all. The opc is SPI Mode1 device, not SPI Mode0 as I had in my code. By changing that in the Arduino sketch, the OPC works fine.
Panayiota:
The SPI logic lines of the OPC are not 5V tolerant (Arduino logic lines are 5V) so I used resistors (2k and 1k (a voltage divider)) to lower the voltage at 3.3 V.
That may or may not work properly - and is not a replacement for a real level shifter. A high signal of the 5V becomes a nice high signal level for the 3.3V side, but if the 3.3V high remains 3.3V. Should be enough to be detected as high but not too sure.
In case of I2C lines or other signals that use pull-up resistors all kinds of weird effects will happen. So you better get some proper level shifters, the kind that goes both ways.
Because at startup OPC draws surge current of 1 A, I decided to supply the OPC with a DC power supply (3.3V).
That's a very good decision - the Arduino's 3.3V can supply only very little power. Good enough for low-power sensors but that's about it.