Hardware:
--Arduino Due (genuine)
--Seeed HM330X sensor board for PM2.5
Seems to be straightforward, but nooooooo.....!
When I ran the supplied Example sketch, I get this error (which I cannot interpret)
(I just downloaded the Seeed/Grove HM330X Library today, which includes the problematic Example,
/*
* basic_demo.ino
* Example for Seeed PM2.5 Sensor(HM300)
*
* Copyright (c) 2018 Seeed Technology Co., Ltd.
* Website : www.seeed.cc
* Author : downey
* Create Time: August 2018
* Change Log :
*
* The MIT License (MIT)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "Seeed_HM330X.h"
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL_OUTPUT SerialUSB
#else
#define SERIAL_OUTPUT Serial
#endif
HM330X sensor;
u8 buf[30];
const char *str[]={"sensor num: ","PM1.0 concentration(CF=1,Standard particulate matter,unit:ug/m3): ",
"PM2.5 concentration(CF=1,Standard particulate matter,unit:ug/m3): ",
"PM10 concentration(CF=1,Standard particulate matter,unit:ug/m3): ",
"PM1.0 concentration(Atmospheric environment,unit:ug/m3): ",
"PM2.5 concentration(Atmospheric environment,unit:ug/m3): ",
"PM10 concentration(Atmospheric environment,unit:ug/m3): ",
};
HM330XErrorCode print_result(const char* str,u16 value)
{
if(NULL==str)
return ERROR_PARAM;
SERIAL_OUTPUT.print(str);
SERIAL_OUTPUT.println(value);
return NO_ERROR;
}
/*parse buf with 29 u8-data*/
HM330XErrorCode parse_result(u8 *data)
{
u16 value=0;
if(NULL==data)
return ERROR_PARAM;
for(int i=1;i<8;i++)
{
value = (u16)data[i*2]<<8|data[i*2+1];
print_result(str[i-1],value);
}
return NO_ERROR;
}
HM330XErrorCode parse_result_value(u8 *data)
{
if(NULL==data)
return ERROR_PARAM;
for(int i=0;i<28;i++)
{
SERIAL_OUTPUT.print(data[i],HEX);
SERIAL_OUTPUT.print(" ");
if((0==(i)%5)||(0==i))
{
SERIAL_OUTPUT.println(" ");
}
}
u8 sum=0;
for(int i=0;i<28;i++)
{
sum+=data[i];
}
if(sum!=data[28])
{
SERIAL_OUTPUT.println("wrong checkSum!!!!");
}
SERIAL_OUTPUT.println(" ");
SERIAL_OUTPUT.println(" ");
return NO_ERROR;
}
/*30s*/
void setup()
{
SERIAL_OUTPUT.begin(115200);
delay(100);
SERIAL_OUTPUT.println("Serial start");
if(sensor.init())
{
SERIAL_OUTPUT.println("HM330X init failed!!!");
while(1);
}
}
void loop()
{
if(sensor.read_sensor_value(buf,29))
{
SERIAL_OUTPUT.println("HM330X read result failed!!!");
}
parse_result_value(buf);
parse_result(buf);
SERIAL_OUTPUT.println(" ");
SERIAL_OUTPUT.println(" ");
SERIAL_OUTPUT.println(" ");
delay(5000);
}
*In file included from /tmp/.arduinoIDE-unsaved20241120-5918-11vhycz.0p09/basic_demo/basic_demo.ino:32:0:*
*/home/mikegee/Arduino/libraries/Grove_-_Laser_PM2.5_Sensor_HM3301/Seeed_HM330X.h:77:58: error: 'u32' has not been declared*
* HM330XErrorCode IIC_read_bytes(u8 start_reg,u8 *data,u32 data_len);*
* ^*
*/home/mikegee/Arduino/libraries/Grove_-_Laser_PM2.5_Sensor_HM3301/Seeed_HM330X.h:91:48: error: 'u32' has not been declared*
* HM330XErrorCode read_sensor_value(u8 *data,u32 data_len);*
* ^*
*/tmp/.arduinoIDE-unsaved20241120-5918-11vhycz.0p09/basic_demo/basic_demo.ino:43:1: error: declaration does not declare anything [-fpermissive]*
* *
* ^*
*exit status 1*
*Compilation error: declaration does not declare anything [-fpermissive]*
