I tried to modify it so it worked in my 2.0 config, but got lots of compile errors

when compiling i got no errors or warnings. but when uploading to my uno i got:
Code: Select all
Using library MySensors at version 2.0.0 in folder: C:\Users\remco\Documents\Arduino\libraries\MySensors
Using library SPI at version 1.0 in folder: C:\Users\remco\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.6.13\libraries\SPI
Using library IRLib-master in folder: C:\Users\remco\Documents\Arduino\libraries\IRLib-master (legacy)
Sketch uses 15,090 bytes (46%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,195 bytes (58%) of dynamic memory, leaving 853 bytes for local variables. Maximum is 2,048 bytes.
Invalid library found in C:\Users\remco\Documents\Arduino\libraries\IRSensor: C:\Users\remco\Documents\Arduino\libraries\IRSensor
Invalid library found in C:\Users\remco\Documents\Arduino\libraries\IRSensor: C:\Users\remco\Documents\Arduino\libraries\IRSensor
[\code]
[quote="gizmocuz"]some heads up:
in the latest beta i implemented the mysensors S_IR_RECEIVE and S_IR_SEND
going to make two posts
Post 1:
When playing with the IR sample, i noticed that 99% of my remote buttons where not recognized, i only received pulsed, instead of a code
So.... i look at the IR library, and it has a nice example to make a 32bit hash of the received IR pulses.
This proves to be working very good ! ;)
I made a new sketch, that is using this hash code, and send it to domoticz (S_IR_RECEIVE)
A new switch (type mdremote) is created, and you can use this for example as the activation code of a scene
Next, when setting the type of the switch to 'push on' (as it is only received) you can also push the button in domoticz, and it will send the code to the sketch (S_IR_SEND)
you can do what you want with it
The sketch is:
[code]/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <[email protected]>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik EKblad
*
* DESCRIPTION
* Example sketch showing how to control ir devices
* An IR LED must be connected to Arduino PWM pin 3.
* An optional ir receiver can be connected to PWM pin 8.
* All receied ir signals will be sent to gateway device stored in VAR_1.
* When binary light on is clicked - sketch will send volume up ir command
* When binary light off is clicked - sketch will send volume down ir command
* http://www.mysensors.org/build/ir
*/
#include <MySensor.h>
#include <SPI.h>
#include <IRLib.h>
int RECV_PIN = 8;
#define CHILD_1 3 // childId
IRsend irsend;
IRrecv irrecv(RECV_PIN);
IRdecode decoder;
IRdecodeHash Hash_Decoder;
//As some remotes could have different hashes for the same button (when they are not good received or other reasons)
//we only let the following hashes go through
#define MYCODES_LENGTH 2
const unsigned long myHashes[MYCODES_LENGTH]={
0x0BE3BB37, //volume up
0xD4D9F2A7, //volume down
};
//decode_results results;
MySensor gw;
MyMessage msgir(CHILD_1, V_IR_RECEIVE);
void setup()
{
irrecv.enableIRIn(); // Start the ir receiver
gw.begin(incomingMessage,254);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("IR Sensor", "1.1");
// Register a sensors to gw. Use binary light for test purposes.
gw.present(CHILD_1, S_IR);
Serial.println("Ready to receive...");
}
void loop()
{
gw.process();
if (irrecv.GetResults(&decoder)) {
Hash_Decoder.copyBuf(&decoder);//copy the results to the hash decoder
//decoder.decode();
//decoder.DumpResults();
Hash_Decoder.decode();
if (!FindHashInOurTable(Hash_Decoder.hash)) {
Serial.print("Unknown IR hash received: ");
Serial.println(Hash_Decoder.hash, HEX);
}
else
{
Serial.print("Known IR hash received: ");
Serial.println(Hash_Decoder.hash, HEX);
gw.send(msgir.set(Hash_Decoder.hash));
}
delay(1000);
irrecv.resume();
/*
char buffer[10];
sprintf(buffer, "%08lx", decoder.value);
// Send ir result to gw
Serial.println(buffer);
//gw.send(msg.set(buffer));
*/
}
}
bool FindHashInOurTable(const unsigned long hash)
{
for (int ii=0; ii<MYCODES_LENGTH; ii++)
{
if (myHashes[ii]==hash)
return true;
}
return false;
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_IR_SEND) {
unsigned long ir_code=(unsigned long)message.getLong();
Serial.print("Gateway received code: ");
Serial.println(ir_code, HEX);
//irsend.send(NEC, ir_code, 32); // Vol up yamaha ysp-900
//irrecv.enableIRIn();
}
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
/*void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
}
*/