Hi,
my project is about to measure NOx and store the values with a data logger on a SD-card.
My setup:
- Arduino UNO
- NOx -Sensor
- Bluetooth shield HC-05
- Seedstudio CAN-Bus shield (29 bit extented identifier)
- Adafruit data logger shield+SD Card
The NOx sensor is connected with the CAN_low and CAN_high of the CAN-bus shield.
The supply voltage of the sensor is 24 V (for testing with a power supply).
I tested this code (and several examples of the CAN library but no changes):
// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13
#include <SPI.h>
#include "mcp_can.h"
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
void setup()
{
Serial.begin(9600);
START_INIT:
if(CAN_OK == CAN.begin(CAN_250KBPS)) // init can bus : baudrate = 250k
{
Serial.println("CAN BUS Shield init ok!");
}
else
{
Serial.println("CAN BUS Shield init fail");
Serial.println("Init CAN BUS Shield again");
delay(100);
goto START_INIT;
}
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
unsigned char len = 0;
unsigned char buf[8];
if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming
{
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf
unsigned long canId = CAN.getCanId();
Serial.println("-----------------------------");
Serial.print("get data from ID: ");
Serial.println(canId, HEX);
for(int i = 0; i<len; i++) // print the data
{
Serial.print(buf[i]);
Serial.print("\t");
}
Serial.println();
// send data: id = 0x00, standart flame, data len = 8, stmp: data buf
CAN.sendMsgBuf(0xFEDF, 0, 4, stmp);
delay(100); // send data per 100ms
}
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
On the serial monitor I receive this message:
Get data from ID:18F00F52
255 255 255 255 255 127 31 31
The sensor is cold…no changes.
How can I send the sensor a start signal and how can I get the measurements?
Btw this is my first project with a CAN-bus
In the appendix ist the data sheet with the transfer protocol & receive signals of the NOx sensor.
Thanks in advance!
Conti UniNOx12V_spec_11 03 08.pdf (876 KB)