avr/interrupt.h missing

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
kjetilhansen
Posts: 15
Joined: 27 Mar 2017 00:09

avr/interrupt.h missing

Post by kjetilhansen »

Hello,

I am trying to use a code that compiled fine on the ATTINY, but not on the Z-uno..

When verifying it sais interrupt.h is missing. I am using the library SoftwareSerial.h

Also, if I upload something that dont use this library it works. So I am guessing the library is the problem. I've also added the lib in the roming folder.

My code;

Code: Select all

//
//Mailbox reciver
#include <SoftwareSerial.h>



SoftwareSerial mySerial(6, 7); // RX, TX

int mail = 2;
int lowBatt = 3;
int lock = 5;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  
  pinMode(mail, OUTPUT);
  pinMode(lowBatt, OUTPUT);
  pinMode(lock, INPUT);
    
}

void loop() {
   
  if(mySerial.available() > 1){    
    int input = mySerial.parseInt();//read serial input and convert to integer (-32,768 to 32,767)    


  //
  //Mail recived one lid mode
  //
    
    if(input == 1478){//One lid mode and mailbox lid open
      digitalWrite(mail, HIGH);//Notify of recived mail
    }
    if(input == 1479){//One lid mode and mailbox lid closed
      digitalWrite(mail, LOW);//keep pin off
    }    



  //
  //Mail recived two lid mode
  //
    
    if(input == 2468){//Mail recived, two lid mode
      digitalWrite(mail, HIGH);//Notify of recived mail
    }
    if(input == 2469){//Admin lid has not been opened
      digitalWrite(mail, LOW);//keep pin off
    }    

    

  //
  //Low battery
  //
    
    if(input == 1234){//LOW BATT code
      digitalWrite(lowBatt, HIGH);//notify for low batt
    }
    if(input == 1235){//BATT OK code
      digitalWrite(lowBatt, LOW);//keep pin off
    }    
  
  }

  //
  //FIBARO send unlcok signal
  //


 if(lock == 1){//if FIBARO want to unlock
    mySerial.println(1236);//Send code for unlock    
  }
     delay(20);  

  if(lock == 0 ){//if lock pin is LOW
    mySerial.println(1237);//Send code to keep lock pin low
  }
  delay(20);


  

 


  
  mySerial.flush();//clear the serial buffer for unwanted inputs     
  
  delay(20);//delay little for better serial communication


 
}


Also, I have not added anything for the Z-wave network yet. I am trying to get my code to work with the Z-uno first. I am using HC-12 modules for wireless serial.
ondrej_bajer
Posts: 33
Joined: 17 May 2018 09:55

Re: avr/interrupt.h missing

Post by ondrej_bajer »

Hi kjetilhansen,

AFAIK, Z-UNO is based on Sigma Designs ZM5101, which is 8051 architecture, while original Arduino is based on Atmel AVR.
For a shame, standard SoftwareSerial library from arduino has a lot of AVR_specific binary code inside. Therefore, it's not portable.

How about to use hardware serial (UART)? Z-UNO has 3 serial interfaces:
USB
Serial0
Serial1
User avatar
PoltoS
Posts: 7565
Joined: 26 Jan 2011 19:36

Re: avr/interrupt.h missing

Post by PoltoS »

Indeed use hw serial for seeds above 9600. For lower we have planned to add SoftwareSerial library support in June
kjetilhansen
Posts: 15
Joined: 27 Mar 2017 00:09

Re: avr/interrupt.h missing

Post by kjetilhansen »

I am not skilled enough to do that :P


But no worries, I am making the circuit myself, so I'll just add a ATTINY85 to do the serial comm. and then give the Z-uno inputs and outputs :) I know it is overkill and somehow dumb, but it's the way I know how to do it :lol:
ondrej_bajer
Posts: 33
Joined: 17 May 2018 09:55

Re: avr/interrupt.h missing

Post by ondrej_bajer »

Believe me, it's easy.
Here's the reference: https://z-uno.z-wave.me/Reference/Serial/
Here's the example using Serial and Serial0: https://z-uno.z-wave.me/examples/rs-485/

Serial pins are:
USB port for "Serial"
TX0 RX0 for "Serial0"
TX1 RX1 for "Serial1"
Z-Uno pinout.jpg
Z-Uno pinout.jpg (86.01 KiB) Viewed 6850 times
kjetilhansen
Posts: 15
Joined: 27 Mar 2017 00:09

Re: avr/interrupt.h missing

Post by kjetilhansen »

Am I understanding the example right, when the Z-uno sends the number 1 to the UNO, the led turns on? In that case it actually looks simple! Well, it looks more complicated than the example I found, but I guess I can work with this! In my schematic I shared the RX/TX line from the HC-12, sent it to the ATTINY and the Z-Uno. So if I do not manage to get this to work the rest will.

But I will give this a go! My What I am doing is really easy, the Z-uno is only supposed to receive two inputs, and control one output. Do analog values, so this should not be this hard! I will give it a go when I get home from work. If I can get it to compile that is a step in the right direction, and I can test it as soon as the HC modules arrive! Thank you for the links ondrej :)
ondrej_bajer
Posts: 33
Joined: 17 May 2018 09:55

Re: avr/interrupt.h missing

Post by ondrej_bajer »

Basically, instead of SoftwareSerial, you can use pins TX0 + RX0 (+GND of course).
And then call the UART0 interface functions like this:
- Serial0.begin(9600);
- Serial0.print("Hello world");

BTW, if you are passing a message to ATTINY via serial interface, it's good to include some kind of "transmission control protocol". For example sending <CR><LF> at the very end of the message. ATTINY will check the receive buffer for that sequence in order to be sure that transmission is done and that a new transmission will start from scratch. Otherwise, when something bad occurs, you may want to send 1236 1237 but the ATTINY will process 3612 becease of that error.

Serial0.print("1236");
Serial0.print('\r'); //<CR> carriage return
Serial0.print('\n');//<LF> new line feed

While Serial0.println might also work for you, I prefer to add CRLF by myself.
ondrej_bajer
Posts: 33
Joined: 17 May 2018 09:55

Re: avr/interrupt.h missing

Post by ondrej_bajer »

Speaking of security, if you have good z-wave signal at the door, it would be much secure to place Z-UNO there and communicate via z-wave, avoiding HC-12 completely. But I don't know details of your project...
kjetilhansen
Posts: 15
Joined: 27 Mar 2017 00:09

Re: avr/interrupt.h missing

Post by kjetilhansen »

Thank you, I will read what you said in detail when I get home and try to figurer all this out :)

My project is kinda simple, I've just over complicated it out of this world!

Basically it notifies me of mail in my mailbox. I live in an apartment and there is 50-60 meters to the mailbox with walls. Also, to check the mailbox I have to go through another building.

So I have designed a circuit that may help me. It uses the HC-12 to give me the long range, and then the receiver takes the serial message and turns it into Z-Wave so the "smart condo" (as I call it :P ) and then sends a push message to my phone.

As I said I over complicated it was that I added a function to control a lock on the mailbox, then you can add a GPS pos with your smarthome and when you enter this area the mailbox is unlocked.I have made all the circuits, I am in the process of checking my work now. The code was also done, but since I went for the Z-uno (insted of fibaro universal sensor) I needed to re-write some code. Since the sensor only receives and not sends I can not control the lock with that unit.
Post Reply