CC1101 async. mode

Zum Empfang / Senden und analysieren diverser Funkprotokolle im 433/868Mhz Band brauchte ich eine geeignete Hardware.
Da noch diverse ESP8266 und CC1101 Funkmodule vorhanden waren, wurden diese genutzt.
Der asynchronous transparent mode ist nötig, um an die Rohdaten des empfangenen Signals zu kommen. Der CC1101 ist somit nicht für das Packethandling (Länge, Preamble, Sync etc.) zuständig, sondern er leitet die Daten einfach nur durch oder sendet die anliegenden Daten direkt aus.

Die eigentliche Datenverarbeitung muss also im ESP geschehen. So lassen sich eigene / herstellerspezifische Protokolle selber implementieren.

Um den Transceiver am ESP nutzen zu können verwende ich diese Library
Sketches schreibe ich in der Arduino IDE.
Man muss in der cc1101.h Datei die Register des Moduls konfigurieren um den asynchronous Mode nutzen zu können.

Pin GDO0 ist TX Input, GDO2 ist RX Output.

Maßgeblich sind folgende Register zu nennen:

#define CC1101_DEFVAL_IOCFG2 0x0D // GDO2 Output Pin Configuration / TX #define CC1101_DEFVAL_IOCFG1 0x2E // GDO1 Output Pin Configuration #define CC1101_DEFVAL_IOCFG0 0x2D // GDO0 Output Pin Configuration / RX


Schaltplan:

CC1101 to ESP schematic

So sieht das ganze im Moment als Versuchsaufbau aus. Das ESP dev.Board ist ein „Witty-Cloud Modul“.

CC1101 und ESP 12F Versuchsaufbau.

6 Kommentare

  • Hi!

    Do you have a working arduino sketch of a cc1101 receiving (433Mhz) raw data in async mode?

    I can’t manage to get it to work!

    / Alexander

    • You can easily modify this code:

      */

      // connect data pin of rx433 module to a pin that can handle hardware interrupts
      // with an Arduino UNO this is digital I/O pin 2 or 3 only
      #define RX433DATAPIN 2

      // hardware interrupt connected to the pin
      // with Arduino UNO interrupt-0 belongs to pin-2, interrupt-1 to pin-3
      #define RX433INTERRUPT 0

      // Set speed of serial in Arduino IDE to the following value
      #define SERIALSPEED 115200

      // Now make some suggestions about pulse lengths that may be detected
      // minimum duration (microseconds) of the start pulse
      #define MINSTARTPULSE 740

      // minimum duration (microseconds) of a short bit pulse
      #define MINBITPULSE 250

      // minimum duration (microseconds) of a HIGH pulse between valid bits
      #define MINHITIME 50

      // variance between pulses that should have the same duration
      #define PULSEVARIANCE 250

      // minimum count of data bit pulses following the start pulse
      #define MINPULSECOUNT 40

      // maximum count of data bit pulses following the start pulse
      #define MAXPULSECOUNT 70

      // buffer sizes for buffering pulses in the interrupt handler
      #define PBSIZE 216

      void setup()
      {
      Serial.begin(115200);
      Serial.println();
      Serial.println("Start!");
      pinMode(RX433DATAPIN, INPUT);
      attachInterrupt(RX433INTERRUPT, rx433Handler, CHANGE);
      }

      volatile unsigned int pulsbuf[PBSIZE]; // ring buffer storing LOW pulse lengths
      volatile unsigned int hibuf[PBSIZE]; // ring buffer storing HIGH pulse lengths
      unsigned int validpulsbuf[MAXPULSECOUNT]; // linear buffer storing valid LOW pulses
      unsigned int validhibuf[MAXPULSECOUNT]; // linear buffer storing valid HIGH pulses

      volatile byte pbread,pbwrite; // read and write index into ring buffer

      void rx433Handler()
      {
      static long rx433LineUp, rx433LineDown;
      long LowVal, HighVal;
      int rx433State = digitalRead(RX433DATAPIN); // current pin state
      if (rx433State) // pin is now HIGH
      {
      rx433LineUp=micros(); // line went HIGH after being LOW at this time
      LowVal=rx433LineUp - rx433LineDown; // calculate the LOW pulse time
      if (LowVal>MINBITPULSE)
      { // store pulse in ring buffer only if duration is longer than MINBITPULSE
      // To be able to store startpulses of more than Maxint duration, we dont't store the actual time,
      // but we store MINSTARTPULSE+LowVal/10, be sure to calculate back showing the startpulse length!
      if (LowVal>MINSTARTPULSE) LowVal=MINSTARTPULSE+LowVal/10; // we will store this as unsigned int, so do range checking

      pulsbuf[pbwrite]=LowVal; // store the LOW pulse length
      pbwrite++; // advance write pointer in ringbuffer
      if (pbwrite>=PBSIZE) pbwrite=0; // ring buffer is at its end
      }
      }
      else
      {
      rx433LineDown=micros(); // line went LOW after being HIGH
      HighVal=rx433LineDown - rx433LineUp; // calculate the HIGH pulse time
      if (HighVal>31999) HighVal=31999; // we will store this as unsigned int
      hibuf[pbwrite]=HighVal; // store the HIGH pulse length
      }
      }

      boolean counting;
      byte i,counter;
      int startBitDurationL,startBitDurationH,shortBitDuration,longBitDuration;

      void showBuffer()
      // this function will show the results on the serial monitor
      // output will be shown if more bits than MINPULSECOUNT have been collected
      {
      long sum;
      int avg;
      sum=0;
      if (counter>=MINPULSECOUNT)
      { // only show buffer contents if it has enough bits in it
      Serial.println();
      Serial.print("Start Bit L: "); Serial.print((startBitDurationL-MINSTARTPULSE)*10L);
      Serial.print(" H: ");Serial.println(startBitDurationH);
      Serial.print("Data Bits: ");Serial.println(counter);
      Serial.print("L: ");
      for (i=0;i=PBSIZE) pbread=0;
      sei(); // Interrupts on again
      if (lowtime>MINSTARTPULSE) // we found a valid startbit!
      {
      if (counting) showBuffer(); // new buffer starts while old is still counting, show it first
      startBitDurationL=lowtime;
      startBitDurationH=hitime;
      counting=true; // then start collecting bits
      counter=0; // no data bits yet
      }
      else if (counting && (counter==0)) // we now see the first data bit
      { // this may be a 0-bit or a 1-bit, so make some assumption about max/min lengths of data bits that will follow
      shortBitDuration=lowtime/2;
      if (shortBitDurationshortBitDuration)&&(lowtime

      I used it, with my cc1101 wiring for decoding jarolift messages.

  • Hi Steffen,

    der Sketch ausschnitt von Dir ist leider abgeschnitten.
    Könntest DU den bitte vervollständigen oder evtl sogar zum Download anbieten ?

    Ich habe hier ein Funklichtschalter (livolo) auf 433mhz und da möchte ich die SIgnale mir anschauen.
    sduino mit fhem kann dieses leider nicht, da habe ich am laufen.

    Es gibt eine Lösung auf Arduino Nano mit RX/TX Module.
    Aber der ESP mit CC1101 wäre viel schicker 😉

    Wäre cool von Dir.

    Danke und Gruß Andreas

  • Hallo,
    ich wäre auch an dem Gesamtcode interessiert.

    Gruss – Pewei

  • Ich bin auch daran interessiert, den vollständigen Code zu sehen. Vor allem, wenn die Möglichkeit besteht, die gespeicherten Rohdaten zu senden.
    Ich habe ein automatisiertes Garagentor, das ich vom Smartphone aus steuern möchte, ich möchte nicht die Zeit damit verbringen, das Übertragungsprotokoll zu analysieren und anzuwenden, es wäre toll, das Signal direkt kopieren zu können.

  • Thorsten Lutz

    Hallo,

    Ich wäre auch sehr sehr am Code Interessiert könntest Du Ihn bitte freigeben

Schreibe einen Kommentar zu Thorsten Lutz Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert