Components
A short foreword that will remain valid for all the other projects: it is my intention, all where possible, to make the projects of Super Smart Home fully functional and install them in the home where I live. According to the availability of the components, the first node I started to develop is the door opener.
As shown in the above images I bought on Amazon en electromechanical door opener. It has the characteristics I need: strong and robust it is durable, can be operated by the outside with a conventional key too, and from the internal side, the opener button is mechanic. It works with 12V 2A and has an internal solenoid response time of 100 ms.
The impulse to the solenoid should be sent by a relay, so I decided that I will use an ESP8266 relay by Digispace (see the image below). It was also the first time I approached the ESP8266 features and programming, a good opportunity to learn something new.
Developing on the ESP8266-01
The ESP8266-01 is one of the smaller boards of the ESP family with only four GPIO pins (two of them are also used for serial TTL connection) but has a lot of powerful features on the WiFi side, as well as a considerable amount of memory. Thanks to the effort of the ESP8266 developer group and the popularity of the Arduino IDE it is possible to develop C software on this platform after installing the IDE extra component with the board manager (more details can be found on the ESP8266/Arduino GitHub repository). The issue I met was to find the right way to wire the microcontroller so it can be programmed with the Arduino IDE and a USB adapter on the computer.
To make a long story short, during the first week of tests I have found a series of issues that made me crazy (maybe more crazy!); the real problem is that you can find on the Internet an incredible quantity of different wiring schemes, circuits suggestions all partially working but not in a fully trustable way. After a first phase trying to keep my learning curve as short as possible, due to the few available time, below I list the most common issues experienced and in some cases the reason why:
- It is not possible to program the ESP8266-connected to the software serial. It works while using the AT commands but not for programming. The reason is that the software serial works at low speeds (the suggested speed is 9600 bps). Good for communicating but impossible to use for programming, where the requested speed is 115Kbps.
- Someone suggests so use a couple of resistors to step-down the signal voltage of the serial between the 5V TTL of the popular FTDI USB to Serial adapter and the 3V3 absolutely needed by the ESP board to avoid to damage it permanently. Actually it is not sufficient, it is a crap solution and this method works only sometimes. If choosing this way it is needed a real step-down adapter based on a chip or using a couple of NPN transistors.
- Someone suggests put the chip-enable pin to 3V3 and someone else to put to GND
- Someone advice to use a pulling resistor while others avoid it
- Someone ask to pull down or up the signals with a resistor
and more.
A Simple Programmer Board
Without pretending to find the definitive solution, I have developed a small prototype programmer (it can be done more and more better) that works, accordingly to the specifications of the ESP8266-01 datasheet when it is set in programming mode.
Thanks to the USB to serial adapter from the Cypress PSoC 4 board it was possible to ignore the problem of the signal levels compatibility so only the USB 5V power line has been reduced with an LM1085, the last I have found here around.
The advantage of the LM1085 is that it already provides a regulated 3V3 voltage so no extra trimmer is needed. If I need other regulators for this project I will use one of the LM350 regulators that need a bit more complex circuit design. After excluding most of the suggestions found on the Internet I have designed the wiring scheme for the programming setup of the ESP8266-01 based on the datasheet details (attached to this post).
Tested on different machines the final version of the programmer worked fine. The below image shows the simple circuit I have used.
In the original circuit, I left the reset pin floating; as the reset is needed to reprogram the board I have added the temporary switch you see in the circuit.
As I tried to reset the ESP the USB was stopped working as it was identifying the reset button as a short circuit. an overcharge. After further investigations, thanks to the help of Jan Cumps and the time he spent with remotely a resistor before the GND solved definitely the problem.
Below: the first version of the ESP8266
Testing the ESP8266-01
The first tests have been done using the bench power supply but I needed a more flexible method to follow the development lifecycle of the ESP, also considering that I plan to use more than one of them in the project nodes. As the Raspberry Pi 4B will be used as the desktop station to control the nodes and both signals and power voltage of the Pi works at 3V3 I decided to make a prototype Pi Shield for efficiently test the board, including the serial communication. Changing a while the programmer circuit I made the scheme shown below:
Note that the reset button does not need any resistor but – again after a long series of tests with Jan Cumps – I have added a jumper to enable or disable the serial connection between the Pi and the ESP, as well as a power switch. The creation of the prototype shield based on this circuit worked well but due to a latch-up condition on the Raspberry Pi, it is not possible hot powering the shield. Despite this detail, the ESP8266 can communicate with the Raspberry Pi Serial and is powered without difficulty.
The right procedure to plug and remove the board from the shield is the following:
To Remove the ESP8266
- Power off the switch on the shield
- Optionally disable the Serial Pi Tx signal (suggested)
- Remove the ESP8266
To Insert the ESP8266
- Shutdown the Raspberry Pi
- Insert the ESP8266 board
- Power on the board and also the Raspberry Pi will power on.
The Software
Modifying the classic Blink Led sketch for the ESP8266 I have tested the relay with a 100 ms pulse every 3 seconds.
/** * @file BlinkLED.ino * */ void setup() { pinMode(0, OUTPUT); } void loop() { digitalWrite(0, HIGH); delay(3000); digitalWrite(0, LOW); delay(100); }
As the source above emits the pulse on the GPIO 0 connected to the relè I have used this to test the relay and door opening solenoid.
In the next episode, we will see the integration of the door opener WiFi activated and the set up of the Raspberry Pi Control Center Desktop. Stay in touch!
Full Content
Already Posted (until now)
Super Smart Home #1 The project
Super Smart Home #2 The Door Opener
Super Smart Home #3 Designing the Control Center
Super Smart Home #4 Activating the Door Opener
Super Smart Home #5 Connecting the First Node to the Control Center
Super Smart Home #6 PSoC6 On the Cloud
Super Smart Home #7 From AWS IoT Core to AWS SiteWise
Super Smart Home #8 The Kitchen Node: Parts, Design and Components
Super Smart Home #9 The Kitchen Node: Circuit and Software
Super Smart Home #10 Building IoT nodes with PSoC6-WiFi-Bt and Mbed OS
Super Smart Home #11 Project Summary, Highlights, and More...
Super Smart Home #12 PSoC6 Local Node: Application Skeleton
Super Smart Home #13 PSoC6 Protection Case
Sources, Circuits, and Documentation
All the software sources, scripts, circuits schematics, and more are available as Open Source material on the SuperSmartHome GitHub repository.
The video episodes of this challenge are repurposed on the blog posts of the site we-are-borg.com
Thanks to
Element14, AWS, and Cypress, main sponsors
Elegoo for 3D printers ad printing material
Digitspace for sensors, actuators, and boards
The friends and community members Jan Cumps and shabaz always available with advice and suggestions.
Top Comments