Z-uno and Wire.h - maybe there is some problem?

Discussions about Z-Way software and Z-Wave technology in general
Post Reply
Miklux
Posts: 31
Joined: 01 Oct 2018 17:02

Z-uno and Wire.h - maybe there is some problem?

Post by Miklux »

Hi all,

I'm trying to realize a VOC and CO2 sensor using the Z-uno and a chip that works with I2C.
But when I try to compile I receive errors.
I'm using the Arduino IDE V 1.6.5 and this is my sketch:

Code: Select all

// VOC & CO2 Sensor
// Based on MiCS-VZ-89TE

#include "Wire.h"

ZUNO_SETUP_CHANNELS(ZUNO_SENSOR_MULTILEVEL_CO2_LEVEL(getterCO2));
   
ZUNO_SETUP_ASSOCIATIONS(ZUNO_ASSOCIATION_GROUP_SET_VALUE); // to control other devices

#define MICS_VZ_89TE_ADDR 0x70 //0x70 default I2C address
#define MICS_VZ_89TE_ADDR_CMD_GETSTATUS 0x0C  // This command is used to read the VZ89 status coded with 6 bytes:
#define MICS_VZ_89TE_DATE_CODE 0x0D

float co2;
float voc;
float reactivity;
float statusS;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Wire.begin();
  //mics1.begin();
}

void loop() {


  readSensor();
  delay(500);
  Serial.print("CO2: ");
  Serial.println(co2);
  Serial.print("VOC: ");
  Serial.println(voc);
  //Serial.print("Reactivity: ");
  //Serial.println(mics1.reactivity);

  // send report to controller (Life Line group)
  zunoSendReport(1);
}


float getterCO2() {
  return co2;
}


void readData(byte reg, uint8_t data1[]) {
    uint8_t i =0;
    Wire.beginTransmission((uint8_t)MICS_VZ_89TE_ADDR);
    Wire.write((uint8_t)reg); //This send the command to get data
    Wire.write(0x0);
    Wire.write(0x0);
    Wire.write(0x0);
    Wire.write(0x0);
    Wire.write(0x0);
    Wire.endTransmission();
    
    Wire.beginTransmission(0xE1);
    Wire.endTransmission();
    
    Wire.requestFrom((uint8_t)MICS_VZ_89TE_ADDR, (byte)7);
    for (i==0; i<7; i++) {
      data1[i] = Wire.read();
    }

}


void readSensor(void) {
    static uint8_t data2[7];
    readData(MICS_VZ_89TE_ADDR_CMD_GETSTATUS, data2);
    
    statusS = data2[5];
    
    co2 = (data2[1] - 13) * (1600.0 / 229) + 400; // ppm: 400 .. 2000
    voc = (data2[0] - 13) * (1000.0/229); // ppb: 0 .. 1000
    reactivity = (data2[4]+(256*data2[3])+(65536*data2[2]));

}

The following are the errors:

Code: Select all

************* Building Arduino Sketch *************
	C:\Users\Michele\AppData\Local\Temp\build5438819384211814526.tmp/z-wave_VOC_CO2.cpp
	***************************************************

Preprocessing file: Custom.c with SDCPP... 

Preprocessing file: Print.cpp with SDCPP... 
Compiling Print_sdcpp_.cpp ...
Preprocessing file: Stream.cpp with SDCPP... 
Compiling Stream_sdcpp_.cpp ...
Preprocessing file: Wire.cpp with SDCPP... 
Compiling Wire_sdcpp_.cpp ...
Preprocessing file: HLCore.cpp with SDCPP... 
Compiling HLCore_sdcpp_.cpp ...
Preprocessing file: HardwareSerial.cpp with SDCPP... 
Compiling HardwareSerial_sdcpp_.cpp ...
Preprocessing file: z-wave_VOC_CO2.cpp with SDCPP... 
Compiling z-wave_VOC_CO2_sdcpp_.cpp ...
z-wave_VOC_CO2.ino:64:11:warning:equality comparison result unused
Preprocessing file: Print.cpp with SDCPP... 
Compiling Print_sdcpp_.cpp ...
Preprocessing file: Stream.cpp with SDCPP... 
Compiling Stream_sdcpp_.cpp ...
Preprocessing file: Wire.cpp with SDCPP... 
Compiling Wire_sdcpp_.cpp ...
Preprocessing file: HLCore.cpp with SDCPP... 
Compiling HLCore_sdcpp_.cpp ...
Preprocessing file: HardwareSerial.cpp with SDCPP... 
Compiling HardwareSerial_sdcpp_.cpp ...
Preprocessing file: z-wave_VOC_CO2.cpp with SDCPP... 
Compiling z-wave_VOC_CO2_sdcpp_.cpp ...
z-wave_VOC_CO2.ino:64:11:warning:equality comparison result unusedCompiling file "LLCore_arduino.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "LLCore_arduino.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "LLCore_arduino.rel" "LLCore_arduino".asm
Compiling file "Print_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "Print_ucxx.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "Print_ucxx.rel" "Print_ucxx".asm
Compiling file "Stream_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "Stream_ucxx.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "Stream_ucxx.rel" "Stream_ucxx".asm
Compiling file "Wire_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "Wire_ucxx.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "Wire_ucxx.rel" "Wire_ucxx".asm
Wire_ucxx.c:1317: warning 85: in function __cxx__TwoWire__method__endTransmission_0105 unreferenced function argument : 'stop'
Wire_ucxx.c:1361: warning 84: 'auto' variable 'ret' may be used before initialization
Compiling file "HLCore_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "HLCore_ucxx.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "HLCore_ucxx.rel" "HLCore_ucxx".asm
HLCore_ucxx.c:562: warning 85: in function delayLoops unreferenced function argument : 'v'
Compiling file "HardwareSerial_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "HardwareSerial_ucxx.c" 
sdcc: Generating code...
sdcc: Calling assembler...
sdcc: sdas8051.exe -plosgffw "HardwareSerial_ucxx.rel" "HardwareSerial_ucxx".asm
Compiling file "z-wave_VOC_CO2_ucxx.c" by means of SDCC...
sdcc: Calling preprocessor...
sdcc: sdcpp.exe -nostdinc -Wall -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_MODEL_LARGE -D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_5_0 -DSDCC=350 -D__SDCC_REVISION=9253 -D__SDCC_mcs51 -D__STDC_NO_COMPLEX__ -D__STDC_NO_THREADS__ -D__STDC_NO_ATOMICS__ -D__STDC_NO_VLA__ -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include\mcs51" -isystem "C:\Users\Michele\AppData\Roaming\Arduino15\packages\Z-Uno\tools\zuno_toolchain\00.08.70\zuno_toolchain/sdcc/\bin\..\include"  "z-wave_VOC_CO2_ucxx.c" 
sdcc: Generating code...
sdcpp.exe: fatal error: when writing output to : Broken pipe
z-wave_VOC_CO2_ucxx.c:580: syntax error: token -> 'data1' ; column 40
Error. SDCC returned: 1

Errore durante la compilazione
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Z-uno and Wire.h - maybe there is some problem?

Post by PoltoS »

Use uint8_t * data1 instead as the argument
Miklux
Posts: 31
Joined: 01 Oct 2018 17:02

Re: Z-uno and Wire.h - maybe there is some problem?

Post by Miklux »

Ok, thank you , I'm trying it just now.
Miklux
Posts: 31
Joined: 01 Oct 2018 17:02

Re: Z-uno and Wire.h - maybe there is some problem?

Post by Miklux »

I try and it compile well, but after do this I have a great problem: the board doesn't start.
I don't know what is the problem: the two leds don't flashes, also if i try to press the association button.
it seems that the device doesn't start...

If I press the reset button the led flash but not more.

It seems the device is dead...

Could you help me please?
Thank you in advance
Mik
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: Z-uno and Wire.h - maybe there is some problem?

Post by PoltoS »

Try rescue mode first. Keep BTN pressed and click RST. Does it start to blink green?
Miklux
Posts: 31
Joined: 01 Oct 2018 17:02

Re: Z-uno and Wire.h - maybe there is some problem?

Post by Miklux »

Hi! I tryied and the green led is blinking!
Now I'm thinking to upload again the bootloader.

Thank you very much,
Mik
PoltoS wrote:
18 Jan 2019 00:42
Try rescue mode first. Keep BTN pressed and click RST. Does it start to blink green?
Post Reply