Hi, I am looking for someone to help me with ARDUINO code in relation to an Arduino mega and an MIKROE NO2 2 click sensor. I have attached a picture of the specific sensor. Thank you!
Welcome to the forum.
It helps to give a link to the product - so people can see full details:
On that page, there is a schematic of the board - so you can see exactly how it's connected-up:
There's also the datasheet for the sensor.
As the text tells you, the board uses an MCP3201 12-bit ADC by Microchip:
What help, exactly, do you need?
What have you tried so far?
TIP: Whenever you want to find Arduino code related to a thing, try putting "Arduino <thing>" into your favourite internet search engine; eg,
Thanks a million, I have the sensor wired up correctly to the Arduino Mega I just need help with computing a code in order to generate values for NO2 concentration.
Heyah, as it happens I'm also working on getting this sensor working with Arduino. I'm getting some numbers out in the Serial Monitor, but I'm not 100% sure if it's correct or not. Any pointers would be greatly appreciated.
I'm using Arduino Mega 2560, as well as the sensor linked above.
The pins are connected as follows:
CS - 53
SCK - 52
SDO - 50
I had the PHT pin connected to PWM (pin 3), but I found it wasn't making a difference to anything, when connected or disconnected. If anyone could help me understand what this pin is/ how it should interact with the Arduino that would be greatly appreciated!
This is the code I've done so far:
#include <SPI.h>
// Define the SPI pins
int pinCS = 53; // Chip Select (CS or SS) pin
int pinSCK = 52; // SPI Clock (SCK) pin
int spiMISO = 50; // MISO (Master In Slave Out) pin
// Define calibration constants for the sensor
int Offset = 0;
int Sensitivity = 2;
void setup(void)
{
Serial.begin(115200);
pinMode(pinCS, OUTPUT); // Set the CS HIGH - idle
digitalWrite(pinCS, HIGH); // Set the CS HIGH - idle
//start the SPI
SPI.begin();
SPI.setBitOrder( MSBFIRST );
SPI.setDataMode( SPI_MODE3 ); // Modes 0-3 - collect data on different settings
SPI.setClockDivider( SPI_CLOCK_DIV16 );
}
void loop() {
digitalWrite(pinCS, LOW); // Select the Sensor (as it collects data when low)
// Read data from the sensor
// using float instead of int to be able to obtain decimal places
float(SensorValue) = SPI.transfer(0x00);
digitalWrite(pinCS, HIGH); // Deselect the Sensor
Serial.print(SensorValue);
// Convert the bytes to numbers
float(SensorReading) = map(SensorValue, 0, 255, 0, 1023);
//adjust for the sensitivity and calibration
float(NO2_Conc) = (SensorReading - Offset)/Sensitivity;
// Display the reading in the Serial Monitor
Serial.print("Sensor Reading: ");
Serial.print(NO2_Conc);
Serial.println(" ppb");
delay(1000); // Frequency of sample rate
}
As I've said, this code provides me with numbers in the serial monitor every second. They jump from about 48 - 500, with very few values in between - This is why I'm doubting my code.
I'm quite new to Arduino and the forum so apologies for any obvious mistakes, and for my general lack of understanding. Any help is appreciated.
Cheers!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.