-->
Page 1 of 1

Compatibility Arduino sketch for ESP8266

PostPosted: Tue Aug 07, 2018 10:09 am
by Jan Kratzer
Hi there,

I got a sketch for controlling my somfy devices via rc module. However, the sketch is not compatible with ESP8266 ( controlling the GPIO state ... DDRD / PORTD incompatibility).
Can anyone of you help me rewriting this for ESP?

Help is very much appreciated !


Code: Select all #define PORT_TX 5 //5 of PORTD = DigitalPin 5
 DDRD |= 1<<PORT_TX; // Pin 5 an output
 PORTD &= !(1<<PORT_TX); // Pin 5 LOW


void SendCommand(byte *frame, byte sync) {
  if(sync == 2) { // Only with the first frame.
  //Wake-up pulse & Silence
    PORTD |= 1<<PORT_TX;
    delayMicroseconds(9415);
    PORTD &= !(1<<PORT_TX);
    delayMicroseconds(89565);
  }

// Hardware sync: two sync for the first frame, seven for the following ones.
  for (int i = 0; i < sync; i++) {
    PORTD |= 1<<PORT_TX;
    delayMicroseconds(4*SYMBOL);
    PORTD &= !(1<<PORT_TX);
    delayMicroseconds(4*SYMBOL);
  }

// Software sync
  PORTD |= 1<<PORT_TX;
  delayMicroseconds(4550);
  PORTD &= !(1<<PORT_TX);
  delayMicroseconds(SYMBOL);
 
 
//Data: bits are sent one by one, starting with the MSB.
  for(byte i = 0; i < 56; i++) {
    if(((frame[i/8] >> (7 - (i%8))) & 1) == 1) {
      PORTD &= !(1<<PORT_TX);
      delayMicroseconds(SYMBOL);
      PORTD ^= 1<<5;
      delayMicroseconds(SYMBOL);
    }
    else {
      PORTD |= (1<<PORT_TX);
      delayMicroseconds(SYMBOL);
      PORTD ^= 1<<5;
      delayMicroseconds(SYMBOL);
    }
  }
 
  PORTD &= !(1<<PORT_TX);
  delayMicroseconds(30415); // Inter-frame silence
}

Re: Compatibility Arduino sketch for ESP8266

PostPosted: Tue Aug 09, 2022 1:37 am
by MarcRem
Hello Jan,
Ive the same problem as you've described in your topic.
Do you've already a solution?
Please, let me know.
Thanks in advance

Re: Compatibility Arduino sketch for ESP8266

PostPosted: Tue Aug 23, 2022 5:43 am
by MasterIphone
I also have same problem.
Forum is died?