Checking the modules

It can be really frustrating when you put everything together in a nice casing, with all wires cut to the desired length, and you discover problems... So I suggest to test all modules separate and together before wiring if permanent. Use a breadboard and some Dupont cables to wire it up, and use the test programs to make sure everything works fine.

Checking the ESP8266

After wiring it up, use the next program when connected to your computer. Your serial monitor should tell you the results of an attempt to connect to your WIFI network.

Arduino Code:
  1. void setup() {
  2. Serial.begin(9600); //<--This is the connection with your computer.
  3. Serial1.begin(115200); //<--This is the connection speed with your ESP.
  5. // WiFi SSID and Password
  6. String SSIDstring = ("#####"); //Replace ##### with your network name / SSID
  7. String PASSstring = ("#############"); //Replace ########### with the password of your network
  9. useESP("AT+RST\r\n", 2000);
  10. useESP("AT+CWMODE=1\r\n", 2000);
  11. useESP("AT+CWLAP\r\n", 8000);
  12. useESP("AT+CWJAP=\"" + SSIDstring + "\",\"" + PASSstring +"\"", 6000);
  13. useESP("AT+CIPSTATUS\r\n", 2000);
  14. useESP("AT+CIPMUX=1\r\n", 1000);
  15. useESP("AT+CIPSERVER=1,80\r\n", 1000);
  16. useESP("AT+CIFSR\r\n", 1000);
  17. }
  19. void loop() {
  20. }
  22. String useESP(String command, const int timeout) {
  23. String response = "";
  24. Serial.println("==================================================");
  25. Serial.println("The Arduino sends the next command to the ESP8266:");
  26. Serial.println(command);
  28. Serial1.print(command); //<-- This is the real command to send to the ESP
  30. Serial.println("..................................................");
  31. Serial.println("Waiting for response...");
  32. long int time = millis();
  33. while( (time + timeout) > millis()) {
  34. while(Serial1.available()) {
  35. char c =;
  36. response += c;
  37. }
  38. }
  39. Serial.print(response);
  40. return response;
  41. }

The program communicates using serial 1 (TX1 and RX1) with the ESP8266. The program will show you the given command, and the response of the ESP8266.

Under normal circumstances, you should see the reset (RST) command, after which the ESP generates a summary. You also see a list of networks in your area, and the program tries to connect to your network. If that is possible, it will show you the given IP address. (a reference of usable commands can be found here)

When it does not connect, you still will get output on your monitor. (Otherwise your Arduino cannot communicate with your computer). If there is no response from your ESP8266 at all:

  • No response at all can also be a result from a wrong baud-rate of your serial connection with the computer. (duh....) Both on 9600?
  • Try a different power supply. On the web you can find problems with unstable power. You can also test with a power bank (has a USB connector itself!), a cellphone charger (idem) or even battery packs. (When you feed the Arduino 5 V through USB of a 5V line, it generates 3.3 for the ESP itself)
  • An unstable kind of power can be solved with the use of a capacitor between 3.3V and ground. When there is a (little) noise on the power lines, most modules will work, but not the ESP8266. Even when its power led is on.

When there is response, but totally unreadable, too short or the word "busy..":

  • Try another bitrate (baud) for the communication on Serial1 (= with the ESP). Maybe your version of firmware has a different baud rate.
  • Shut down the power for some time. Every time you reset your Arduino / upload a new program, the ESP does not reset by itself. (it remains powered)  In some cases, it is waiting for something (like a close command or a website to send of a given number of characters) and shall not take new orders before the current task has been finished.

Testing the FS1000a

To test the FS1000a, we need 3 more things:

  • Some device or switch which uses the 433 MHz protocol for input. A big part of our project are the wireless switches, and our project is going to replace it's remote controls.
  • We need the remote controls itself, to learn the code to be broadcasted.
  • Therefor, we also need the 433 MHz receiver, but as we bought the RX and TX as a set...

080408 to arduinoAttach the receiver to 5V and ground, and connect one of the middle two data-pins to Arduino pin 2. You will nead an extra library if for your Arduino, so make sure RC-Switch is installed (of not, get it!).

The library of RC-Switch can handle the protocol we need. But not all power outlet sockets use the same protocol. It will be possible that you need another library of other hardware for your wireless switches, but the "klikaanklikuit" devices over here work.

Once you've setup the breadboard. just start the "ReceiveDemo_Advanced" script on your IDE. (Examples > RC-Switch > ReceiveDemo_Advanced)

Now you can use one of your remotes (maybe disable the receivers before...) and take a look at the information on your serial monitor:

Text Code:
Decimal: 3700159 (24Bit) Binary: ‭001110000111010110111111‬ Tri-State: not applicable PulseLength: 306 microseconds Protocol: 1   Raw data: 9536,268,900,280,912,840,320,864,308,868,304,280,896,292,884,284,880,308,872,884,288,876,300,864,332,268,900,848,320,272,908,848,336,840,324,860,312,276,908,264,908,852,328,844,100,16,92,444,512,

Maybe I take some risk by showing you one of my codes, because everyone with an Arduino / FS1000a combination can broadcast a "3700159" code of 306 microseconds in front of my house to activate the SoundBlaster radio...

Learn all codes from your remote(s). As you can see the pair of codes (on and off for one device) are almost identical, only the "off"-code is one lower. (In my case: you can turn the SoundBlaster off with 3700158)

Now we take our breadboard again, and setup for the transmitter: de FS1000a. Wired as mentioned in the section before, you can run the next test:

Arduino Code:
  1. #include <RCSwitch.h>
  3. RCSwitch mySwitch = RCSwitch();
  4. #define pinTX 53
  5. #define pulseLength 306
  6. #define bitLength 24
  7. #define protocol 1
  9. void setup() {
  10. mySwitch.enableTransmit(pinTX);
  11. mySwitch.setPulseLength(pulseLength);
  12. mySwitch.setProtocol(protocol);
  13. }
  15. void loop() {
  16. mySwitch.send(3700159, bitLength);
  17. delay(2000);
  18. mySwitch.send(3700158, bitLength);
  19. delay(2000);
  20. }

With this script, the power outlet socket will be turned on and off every four seconds.


  • If you can receive the codes (with the RC-Switch library and the receiver) you would be able to send codes. If you can't receive, there is a possibility of the use of a protocol which cannot be handled by RC-Switch or this hardware.
  • If you can receive codes, but sending them won't let anything happen and codes seem to change often... You may deal with a system with "rolling code". As a measure of security, some devices use a system with encryption / calculated keys. As long as you cannot get your hands on their algorithm, it won't be possible to control that kind of devices.
  • When their seems to be an unpredictability in your results, there may be interfering factors or a too big distance. Remember, it is possible to add an antenna on the transmitter!

Testing the OLED I2C SSD1306 12864 LCD

The OLED is connected to two special pins: the I2C-bus. As in computers more devices can share one bus, because communication will use addresses. So you need to find the address of your screen first. That can be done with an I2C Scanner. Once you've got it, you can test your screen with the Adafruit SSD1306 library example. (Make sure you also install the Adafruit GFX library) If you'll get the warning to fix your SSD1306 library, open up the Adafruit_SSD1306.h file in your editor. The only line uncommented should be the line with your screen resolution:

Arduino Code:
  1. /*=========================================================================
  2.  SSD1306 Displays
  3.  -----------------------------------------------------------------------
  4.  The driver is used in multiple displays (128x64, 128x32, etc.).
  5.  Select the appropriate display below to create an appropriately
  6.  sized framebuffer, etc.
  7.   SSD1306_128_64 128x64 pixel display
  8.   SSD1306_128_32 128x32 pixel display
  9.   SSD1306_96_16
  10. -----------------------------------------------------------------------*/
  11. #define SSD1306_128_64 //<<-- My resolution, this line is oncommented
  12. // #define SSD1306_128_32 //<<-- Not my resolution, this line is commented
  13. // #define SSD1306_96_16 //<<-- Not my resolution, this line is commented

(Normally, this file can be found on your hard drive: users\#username#\documents\Arduino\libraries\Adafruit_SSD1306\ )



Testing the relay-bank

As you wired as mentioned before, you can use the program below to test your relays. When using for testing purposes, we do not attach the relays to outlet sockets. The relays have LED's on board, so testing is possible without the dangerous alternating current from your wall socket.


Arduino Code:
  1. void setup() {
  2. for (int i = 22; i < 36; i = i + 2){
  3. pinMode (i, OUTPUT);
  4. digitalWrite (i, HIGH);
  5. }
  6. void loop() {
  7. for (int i = 22; i < 36; i = i + 2){
  8. digitalWrite (i), LOW); //<-- Turn relay ON
  9. delay(1000);
  10. }
  12. for (int i = 22; i < 36; i = i + 2){
  13. digitalWrite (i), HIGH); //<-- Turn relay OFF
  14. delay(1000);
  15. }
  16. }

 Running these code let all relays go on and off.


  • This is the only part with both alternating current and weak current(!), and the PCB has a jumper for more safety: it is possible to operate the relays with another power supply to isolate the Arduino more. In this example we leave the jumper on JD-VCC. So make sure your jumper is at the same position.


Testing the push button

Although there is nothing spectacular about testing a pushbutton, I will test it. When having troubles with the main program, there is nothing more frustrating than "things you would expect to work, but they didn't". So use the button example in the IDE (examples > 2.0 Digital > Button) to check your connections.


Index of this article

Add comment

Security code

Powered by 2014 - All Rights Reserved.