• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EV1527 based contact and motion sensors
#1
I bought some cheap door sensors with a EV1527 chipset in it. There are no jumpers to set ID. Instead of jumpers, the first 20 bits are sued to identify the device. Due to the high amount of (preset) ID's, chances are quite small to get duplicate ID's. This post if for information, next post some questions.

[Image: Door-Sensor.jpg]

[Image: Motion-Sensor.jpg]

EV1527 Datasheet: http://www.solidremote.com/imgcdn/solidr...asheet.pdf

Sensor 1

Code:
--[RESULTS]--

hardware:       433gpio
pulse:          3
rawlen:         50
binlen:         12
pulselen:       253

Raw code:
253 759 759 253 759 253 759 253 253 759 253 759 253 759 253 759 253 759 253 759 759 253 253 759 253 759 759 253 759 253 759 253 253 759 253 759 759 253 253 759 759 253 253 759 253 759 759 253 253 8602
Binary code:
001111001110

--[RESULTS]--

hardware:       433gpio
pulse:          4
rawlen:         50
binlen:         12
pulselen:       253

Raw code:
253 759 1012 253 759 253 759 253 253 759 253 759 253 759 253 759 253 759 253 759 759 253 253 759 253 759 759 253 759 253 759 253 253 759 253 759 759 253 253 759 759 253 253 759 253 759 1012 253 253 8602
Binary code:
001111001110

Real binary code for sensor 1 should be grouped in ID and state:
Code:
10001111110110001101 0110

Sensor 2

Code:
--[RESULTS]--

hardware:       433gpio
pulse:          3
rawlen:         50
binlen:         12
pulselen:       258

Raw code:
774 258 258 774 258 774 258 774 258 774 774 258 774 258 258 774 258 774 774 258 774 258 258 774 774 258 258 774 774 258 774 258 258 774 258 774 774 258 258 774 774 258 258 774 258 774 774 258 258 8772
Binary code:
110101101110

--[RESULTS]--

hardware:       433gpio
pulse:          3
rawlen:         50
binlen:         12
pulselen:       258

Raw code:
774 258 258 774 258 774 258 774 258 774 774 258 774 258 258 774 258 774 774 258 774 258 258 774 774 258 258 774 774 258 774 258 258 774 258 774 774 258 258 774 774 258 258 774 258 774 774 258 258 8772
Binary code:
110101101110

Real binary code for sensor 2 should be grouped in ID and state:
Code:
01111001100101001101 0110

pilight-receive sensor 1


Code:
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 2
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 3
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 4
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 5
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 6
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 7
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 8
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 9
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 10
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 11
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 12
}
{
        "code": {
                "id": "C11",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 13
}
{
        "code": {
                "id": "F15",
                "unit": 21,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "F15",
                "unit": 23,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}

pilight-receive sensor 2

Code:
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 2
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 3
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 2
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 3
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 4
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 5
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 6
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 7
}
{
        "code": {
                "id": "C3",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 8
}
{
        "code": {
                "id": "F7",
                "unit": 15,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "F15",
                "unit": 31,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}
{
        "code": {
                "id": "F15",
                "unit": 31,
                "state": "off"
        },
        "origin": "receiver",
        "protocol": "rev_switch",
        "uuid": "0362-00-00-62-000300",
        "repeats": 1
}





Proposed protocol settings

Code:
    protocol_plslen_add(sensor_1527, 256);
    sensor_1527->devtype = SWITCH;
    sensor_1527->hwtype = RF433;
    sensor_1527->pulse = 3;
    sensor_1527->rawlen = 50;
    sensor_1527->binlen = 24;

- Is the binlen correct? The protocol sens a one bit footer which can be ignored.
- How to handle the massive amount of repeats?
 
Reply
#2
- binlen should be the same as in elro and similar.
- repeats are not an issue.
 
Reply
#3
Thanks! First version of protocol is ready. Now I would like to add the earlier proposed resetswitch function.

Code:
void sensor1527ResetSwitch(JsonNode *code) {
     int id =-1;
     int resetdelay =-1;
    unsigned int unsignedresetdelay;
    
     json_find_number(code, "id", &id);
     json_find_number(code, "resetdelay", &resetdelay);
        
     if (delay > 0) {
         unsignedresetdelay = (int)resetdelay;
         sleep(unsignedresetdelay);
         sensor_1527->message = json_mkobject();
         json_append_member(sensor_1527->message, "id", json_mknumber(id));
         json_append_member(sensor_1527->message, "state", json_mkstring("off"));
     }
}

To fix the signed to unsigned int converion warning, I would like to add this on line 1403 of json.c:

Code:
unisgned int json_find_unsignednumber(JsonNode *object, const char *name, unsigned int *out) {
    JsonNode *node = json_find_member(object, name);
    if (node && node->tag == JSON_NUMBER) {
        *out = node->number_;
        return 0;
    }
    return 1;
}

Whats the opinion of the experts on this?
 
Reply
#4
Why don't you use the normal ints?
 
Reply
#5
Both sleep() and usleep() require an insigned int, probably to make sure the (mili)seconds specified are not negative.
 
Reply
#6
Then cast these int's in the sleep functions.
 
Reply
#7
Thanks, was casting in the wrong way. This is compiling OK, but the switch isn't being reset. I guess I'm overlooking something quite simple:

Code:
void sensor1527ParseCode(void) {
    int i = 0, x = 0;
    int id;
    int state;

    for(i=1;i<sensor_1527->rawlen-1;i+=2) {
        sensor_1527->binary[x++] = sensor_1527->code[i];
    }

    id = binToDecRev(sensor_1527->binary, 0, 19);
    state = binToDecRev(sensor_1527->binary, 20, 23);

    if(state == 6){
        sensor_1527->message = json_mkobject();
        json_append_member(sensor_1527->message, "id", json_mknumber(id));
        json_append_member(sensor_1527->message, "state", json_mkstring("on"));
        sensor_1527->switchReset=&sensor1527SwitchReset;
    }     
}

void sensor1527SwitchReset(JsonNode *code) {
    int id =-1;
    int resetdelay =-1;
        
    json_find_number(code, "id", &id);
    json_find_number(code, "resetdelay", &resetdelay);
        
    if (resetdelay > 0) {
        sleep((unsigned int)(resetdelay));
        sensor_1527->message = json_mkobject();
        json_append_member(sensor_1527->message, "id", json_mknumber(id));
        json_append_member(sensor_1527->message, "state", json_mkstring("off"));
    }
}
 
Reply
#8
Ehm, the actual function not being called...
 
Reply
#9
Thought this was enough:

Code:
sensor_1527->switchReset=&sensor1527SwitchReset;

Will try fiddling out something else.
 
Reply
#10
Took a while, but I think I have a working protocol which also can be controlled by pilight-send. I have left out Autoreset, that will be done trough pimatic/shell script.

One question remaining, do you want open/close or on/off?

Two observations:

- Quite often I cannot control the switch/senor with the web gui, I see the same behaviour with a generic_switch. I guess this is known?

- I'm pretty sure that the binlen should be 24, but setting that did not work. Leaving the binlen out of the .c makes it work. However, it gives me the feeling that pilight (and pilight-debug)handles rf traffic better when the rf protocol uses 4 pulses to set in total 12 bits instead of rf protocols that use 2 pulses to set in total 24 bits.
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Recommondation for contact sensors MorfelPi 0 125 04-07-2019, 12:54 AM
Last Post: MorfelPi
  Charts for temperature sensors? Dergo 3 789 01-01-2018, 08:13 PM
Last Post: curlymo
  Motion Sensors... (KAKU, Trust...), what now? haboku 1 612 09-27-2017, 02:26 PM
Last Post: pilino1234
  EV1527 Problem Alex 6 1,950 04-30-2017, 06:25 PM
Last Post: Alex
  first contact JoeC. 7 2,230 08-10-2016, 07:06 PM
Last Post: JoeC.
  How to integrate sensors and actors on a non Rpi system? schorsch 3 1,333 05-06-2016, 05:54 PM
Last Post: Niek
  EV1527 Screen Partovic 2 1,903 12-14-2015, 10:31 PM
Last Post: Partovic
Question 433 Temp/Humi Sensors laubi 6 3,898 10-17-2015, 07:35 PM
Last Post: miguipda
Question Generic Webcam and motion-jpeg mjpeg danieljo 2 1,788 07-17-2015, 02:37 PM
Last Post: danieljo
  Alarm - burglary notice - motion detection IDEA's creamers 8 4,270 10-13-2014, 02:50 PM
Last Post: picasso

Forum Jump:


Browsing: 1 Guest(s)