My goal is to "switch" a Sonoff Basic (board RF R2 Power) from an Arduino Nano (which is connected to a few sensors). Based on this video, I found which pin to use on the Sonoff. After a test, this is working by connecting KEY and GND very briefly. I used the white cable you can see on this picture. It is always +3.3 V (from KEY) but when you shorten KEY to GROUND for a sec it switches on release.

Sonoff Basic (board RF R2 Power)

Now, I am working on how to "replace" the white cable with the Arduino it-self. I used the following diagram with R1 = 50Ω.



  • How can I calculate value for R1 because 50 is a guess from what I found over the web.


  • The Sonoff Basic does NOT start if it boots after the Arduino. No green LED. It works fine if the Sonoff boots first, then the Arduino right after.

Any idea what is the cause and how to solve this ?

This is the code I use on the Arduino Nano to test the whole thing. Basically it changes de Sonoff switch position every 4 seconds.

void setup() {
  pinMode(3, OUTPUT); //Pin 3 triggers camera via optop-isolator
  digitalWrite(3, LOW);

void loop() {
    digitalWrite(3, LOW);
    digitalWrite(3, HIGH);

Thanks for your help !

  • \$\begingroup\$ Do you have a schematic of the key circuit as used on the board or maybe a data sheet that explains what ought to be done rather than guessing. \$\endgroup\$
    – Andy aka
    Apr 23, 2020 at 12:20
  • \$\begingroup\$ If i understand correctly from this web site the breakout I am trying to "hack" should be used with a RF module which is not included on my model. \$\endgroup\$
    – Thomas
    Apr 23, 2020 at 12:38
  • \$\begingroup\$ Pretty sure you need to use an output on the Nano and swap sides on your opto-isolator, otherwise what it looks like you are trying to do is use the Key to drive an input on the Nano. As your question asks, it's the other way around... \$\endgroup\$
    – Ron Beyer
    Apr 23, 2020 at 13:33
  • \$\begingroup\$ Thanks Ron, I just realized my error. I fixed my post. How can I confirm it can work with Opto and not a relay ? Thanks \$\endgroup\$
    – Thomas
    Apr 23, 2020 at 15:16
  • \$\begingroup\$ I updated the question with my actual wiring and the new boot order problem. \$\endgroup\$
    – Thomas
    Apr 23, 2020 at 22:46

1 Answer 1


This problem has been solved by adding a PULL DOWN resistor to ensure default state LOW on the Arduino side (add a 10k resistor from PIN 1 to GND).

I used this article to understand.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.