I'm using the zmod4410, I can read out sensor tracking number, sensor trimming data, sensor pid, but when I read results, use the following function:
void read_and_verify(zmod4xxx_dev_t* sensor, uint8_t* result, char const* id) { /* Verify completion of measurement sequence. */ ret = zmod4xxx_read_status(sensor, &zmod4xxx_status); if (ret) { HAL_HandleError(ret, "Reading sensor status"); } /* Check if measurement is running. */ if (zmod4xxx_status & STATUS_SEQUENCER_RUNNING_MASK) { /* Check if reset during measurement occured. For more information, * read the Programming Manual, section "Error Codes". */ ret = zmod4xxx_check_error_event(sensor); switch (ret) { case ERROR_POR_EVENT: HAL_HandleError(ret, "Reading result: Unexpected sensor reset!"); break; case ZMOD4XXX_OK: HAL_HandleError(ret, "Reading result: Wrong sensor setup!"); break; default: HAL_HandleError(ret, "Reading result: Unknown error!"); break; } } /* Read sensor ADC output. */ ret = zmod4xxx_read_adc_result(sensor, result); if (ret) { HAL_HandleError(ret, "Reading ADC results"); }
/* Check validity of the ADC results. * - ERROR_POR_EVENT: An unexpected reset appeared * - ERROR_ACCESS_CONFLICT: ADC data was read while the sensor was running * For additional information refer to section "Error Codes" in * Programming Manual. */ ret = zmod4xxx_check_error_event(sensor); if (ret) { HAL_HandleError(ret, "Reading ADC result status"); }}
The return value of zmod4xxx_check_error_event is -7 wich means ERROR_POR_EVENT and results are all 0.
I'm using the example Renesas-ZMOD4410-IAQ_2nd_Gen-Firmware-4.2.0.zip which from renesas official website.
We built 4 prototypes and all of them turned out to be this phenomenon.
My MCU is ERF32BG21.
Is there any Renesas counting support, and may I ask why this is happening?
Hello sir,
Thanks for reaching out Renesas Engineering Community.
The specific error occurs when you have an unexpected power on reset on the sensor.
If you also check the error codes in the programming manual you will see that:
So you have to check in your connections either if the power supply is stable on the sensor or either if the reset pin gets low level in your circuit for some reason. Please note that the reset pin of the sensor in active low.
Can you please provide a schematic of your connections?
Do you have a custom board created? Are you using any jumpers for your connections? Are you sure that maybe any jumper was not disconnected?
Please provide us:
1. Your connections
2. Which specific library are you using?
3.Some sample code to check if the sequence of the provided functions is correct as recommended also in the Programming Manual.
(https://www.renesas.com/en/document/mas/zmod4410-programming-manual-read-me?r=454426&check_logged_in=1)
Best Regards,
IK
Now I can read values by read_and_verify now.
I‘m using lib_iaq_2nd_gen.a
Here is my data reading function:
void zmod4410_read_callback(sl_simple_timer_t *timer, void *data)
{
int i;
char buf[150];
uint8_t data_buf[ZMOD4XXX_LEN_PID];
uint16_t pid = 0;
int sum_adc_results = 0;
static uint8_t step = 0;
static uint32_t timestamp = 0;
if(zmod4401_init_done){
if(step == 0){
step = 1;
timestamp = my_sys_tick_in_ms;
ret = zmod4xxx_start_measurement(&dev);
if (ret) {
HAL_HandleError ( ret, "starting ZMOD4410 measurement" );
}else{
sprintf(buf,"Start zmod4410 meas ok");
dbg_through_ble2(buf,strlen(buf));
}
if(step == 1 && (my_sys_tick_in_ms - timestamp > 3000)){
step = 0;
read_and_verify(&dev, adc_result, "ZMOD4410");
for(i=0; i<ZMOD4410_ADC_DATA_LEN; i++){
sum_adc_results += adc_result[i];
/* Calculate algorithm results. */
ret = calc_iaq_2nd_gen(&algo_handle, &dev, NULL, &algo_input, &algo_results);
// printf(" EtOH = %8.3f ppm\n", algo_results.etoh);
// printf(" TVOC = %8.3f mg/m3\n", algo_results.tvoc);
// printf(" eCO2 = %8.0f ppm\n", algo_results.eco2);
// printf(" IAQ = %8.1f\n", algo_results.iaq);
// printf(" Rel IAQ = %8.1f\n", algo_results.rel_iaq);
sprintf(buf,"(sum=%d)EtOH*1000=%dppm,TVOC*1000=%dmg/m3",
sum_adc_results, (int)(algo_results.etoh*1000),(int)(algo_results.tvoc*1000));
/* Check validity of the algorithm results. */
switch (ret) {
case IAQ_2ND_GEN_STABILIZATION:
/* The sensor should run for at least 60 cycles to stabilize.
* Algorithm results obtained during this period SHOULD NOT be
* considered as valid outputs! */
sprintf(buf,"Warm-Up!\n");
break;
case IAQ_2ND_GEN_OK:
sprintf(buf,"Valid\n");
/* Notification from Sensor self-check. For more information, read the
* Datasheet, section "Conditioning, Sensor Self-Check Status, and
* Stability". */
case IAQ_2ND_GEN_DAMAGE:
sprintf(buf,"IAQ_2ND_GEN_DAMAGE");
/* Exit program due to unexpected error. */
default:
HAL_HandleError(ret, "Algorithm calculation");
Currently the raw values are read (sum_adc_results is about 4000+ in air and put above alcohol gas, this value gets smaller to 2000+), but when I call calc_iaq_2nd_gen, its return value is always IAQ_2ND_GEN_DAMAGE.
What are the normal values of TVOC and EtOH that zmod4410 reads in air (currently my call to calc_iaq_2nd_gen returns TVOC all the time at 0.015mg/m3 and EtOH all the time at 0.008)?
And where can I get the register manual for the ZMOD4410?
I‘m missing the key line: