• 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


[Solved] receiver questions
#11
I will get a receiver that should be supported today, will try with this one.
Maybe I could also write some programm to analyze the output of the extracted one because it looked really low noise (was extracted from a ELRO wall outlet switch)

Hm ok I now remember reading the mode documentation before so GPIO is the only way to go for me (except kernel module which as I understood is not ready yet)
 
Reply
#12
pilight-raw just passes through all output.
 
Reply
#13
Ok and what is the output? Pulse length? Have not looked at the code yet.
 
Reply
#14
Got another receiver from a colleague yesterday. Doesn't work Crying

Same behaviour, output on pilight-raw (even noisier than the two receivers I had before) but nothing on pilight-debug...

I start to suspect it is a software issue. I have a second raspberry lying around, I hope I find the time to make a clean raspian installation on it and only install pilight for verification.
 
Reply
#15
thex, could you try to run pilight-debug right after a reboot without first starting the pilight-raw?
 
Reply
#16
I will try, already have some Idea what could go wrong, there is some other programm which is automatically started which uses the GPIOs, will try disabeling it first before setting up the new pi.
(I always stopped it before trying pilight stuff but still it was starting on startup)
 
Reply
#17
It's WORKING now. It really was the program that automatically started on startup. It really didn't do much but register a gpio (not the one used by pilight) for an interrupt and then does something in the callback, I wrote it myself.
Maybe there is a way to programmatically find out if there is some issue so that the daemon could warn that there is something else interfering with the gpios?
Maybe also some bug in wiringPi?
 
Reply
#18
Can you post the interfering program?
 
Reply
#19
Sure, here it is.

Basically it is a small C program derived from wiringpi ISR example which sends a simple push message over pushover API as soon as the Interrupt is triggered. There is also some code to debounce the input.

I had it autostart via init.d as a service, just like pilight.

Code:
/*
* isr.c:
*    Wait for Interrupt test program - ISR method
*
*    How to test:
*      Use the SoC's pull-up and pull down resistors that are avalable
*    on input pins. So compile & run this program (via sudo), then
*    in another terminal:
*        gpio mode 0 up
*        gpio mode 0 down
*    at which point it should trigger an interrupt. Toggle the pin
*    up/down to generate more interrupts to test.
*
* Copyright (c) 2013 Gordon Henderson.
***********************************************************************
* This file is part of wiringPi:
*    https://projects.drogon.net/raspberry-pi/wiringpi/
*
*    wiringPi is free software: you can redistribute it and/or modify
*    it under the terms of the GNU Lesser General Public License as published by
*    the Free Software Foundation, either version 3 of the License, or
*    (at your option) any later version.
*
*    wiringPi is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU Lesser General Public License for more details.
*
*    You should have received a copy of the GNU Lesser General Public License
*    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
***********************************************************************
*/

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <wiringPi.h>
#include <stdbool.h>
#include <sys/time.h>

#include <curl/curl.h>
//#include <curl/types.h>
#include <curl/easy.h>

// globalCounter:
//    Global variable to count interrupts
//    Should be declared volatile to make sure the compiler doesn't cache it.

static volatile bool doorbell_rung;

static const char* PUSH_URL = "https://api.pushover.net/1/messages.json";
static const char* PUSH_TOKEN = "xxxxxxxxxxxxxxxxxx";
static const char* PUSH_USER = "xxxxxxxxxxxxxxxxxx";
static const char* PUSH_TITLE = "Door";
static const char* PUSH_MESSAGE = "rung at ";
static const char* PUSH_MESSAGE_URL = "http://xkcd.com";
static const char* PUSH_MESSAGE_URL_TITLE = "open door";



/*
*********************************************************************************
* function prototypes to define later:
*********************************************************************************
*/
char *curl_request(char *url, char* params);
size_t static string_write_callback(void *buffer,
                        size_t size,
                        size_t nmemb,
                        void *userp);


/*
*********************************************************************************
* Interrupts:
*********************************************************************************
*/

void doorbellInterrupt (void) {
    static struct timeval last_ring_time = {.tv_sec=0, .tv_usec=0};
    struct timeval current_ring_time;
    
    gettimeofday(&current_ring_time, NULL);
    if((current_ring_time.tv_sec > last_ring_time.tv_sec)
        ||((last_ring_time.tv_usec - current_ring_time.tv_usec) >= 500000)
    )
    {
        doorbell_rung = true;
    }
    else
    {
        printf ("don't ring that fast!\n") ; fflush (stdout) ;
    }
    last_ring_time = current_ring_time;
}



/*
*********************************************************************************
* main
*********************************************************************************
*/

int main (void)
{

  wiringPiSetup () ;

  wiringPiISR (0, INT_EDGE_RISING, &doorbellInterrupt) ;
  
  printf ("doorbell up and running ... \n") ; fflush (stdout) ;

  for (;;)
  {
      sleep(1);
      
      if(doorbell_rung)
      {
          //doorbell interrupt got triggered
          
          //reset interrupt flag
          doorbell_rung = false;
          
          //get the time to display in message
        time_t current_time;
        time(&current_time);
        char* current_time_char = ctime(&current_time);
                  
          printf ("ring... (%s)\n",current_time_char) ; fflush (stdout);
          
          //make curl request
          char *params = NULL;
          asprintf(&params,"token=%s"
                          "&user=%s"
                          "&title=%s"
                          "&message=%s%s"
                          "&url=%s"
                          "&url_title=%s"
                          , PUSH_TOKEN
                          , PUSH_USER
                          , PUSH_TITLE
                          , PUSH_MESSAGE, current_time_char
                          , PUSH_MESSAGE_URL
                          , PUSH_MESSAGE_URL_TITLE
                          );
        char *content = NULL;

        content = curl_request(PUSH_URL,params);

        printf("%s\n", content); fflush (stdout);
          
          //also activate hardware bell
          //wiringPi          
      }
    //printf ("Waiting ... ") ; fflush (stdout) ;
    //for (;;)
    //{
        //waiting for an interrupt
    //  if (interrupt_happened)
    // break ;
    //}
  }

  return 0 ;
}

/*
*********************************************************************************
* curl stuff
*********************************************************************************
*/

char *curl_request(char *url, char* params)
{
    /* keeps the handle to the curl object */
    CURL *curl_handle = NULL;
    /* to keep the response */
    char *response = NULL;

    /* initializing curl and setting the url */
    curl_handle = curl_easy_init();
    curl_easy_setopt(curl_handle, CURLOPT_URL, url);
    curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);

    /* follow locations specified by the response header */
    curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);

    /* setting a callback function to return the data */
    curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, string_write_callback);

    /* passing the pointer to the response as the callback parameter */
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &response);
    
    // add the parameters
    curl_easy_setopt(curl_handle, CURLOPT_POSTFIELDS, params);

    /* perform the request */
    curl_easy_perform(curl_handle);

    /* cleaning all curl stuff */
    curl_easy_cleanup(curl_handle);

    return response;
}

/* the function to invoke as the data recieved */
size_t static string_write_callback(void *buffer,
                        size_t size,
                        size_t nmemb,
                        void *userp)
{
    char **response_ptr =  (char**)userp;

    /* assuming the response is a string */
    *response_ptr = strndup(buffer, (size_t)(size *nmemb));

}
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Approved Sender and Receiver Kit curlymo 74 113,483 11-16-2022, 09:11 AM
Last Post: aseratis
  ESP8266 with 433 MhZ Transceiver/Receiver as Remote for Raspberry Tueftler1983 2 3,610 05-12-2019, 06:31 PM
Last Post: bitboy
  Filter kit in 315 receiver? ceandre 1 2,267 04-14-2017, 10:10 PM
Last Post: wo_rasp
  Low Pass Filter and Receiver in Series? re-post Gustavo Woltmann 1 2,476 03-08-2017, 05:25 PM
Last Post: pilino1234
  Looking for 868mhz receiver curlymo 24 30,218 12-07-2016, 02:51 PM
Last Post: rorie
  Low Pass Filter and Receiver in Series? Hauke 3 4,851 08-30-2016, 08:25 AM
Last Post: wo_rasp
  433 Receiver shielding satsatt 2 5,351 07-13-2016, 07:12 PM
Last Post: HazelMiki
  433mhz receiver for window shutters stratege-0815 0 2,233 02-18-2016, 12:14 PM
Last Post: stratege-0815
  433mhz USB Sender/Receiver raws99 8 12,375 11-17-2015, 11:29 PM
Last Post: curlymo
  433 Mhz receiver mike 9 9,443 09-30-2015, 04:01 PM
Last Post: lxz

Forum Jump:


Browsing: 1 Guest(s)