As usual, the problem isn't a new problem, and this isn't a new solution. But I will describe it to help someone doing the same.
With this project I've made a wifi infra-red remote control for my Daikin air conditioner.
In these schema you can see all parts involved.
Some more details:
- normal air conditioner is controlled by an infra-red remote controller (top left in the pic: "classic remote");
- an ESP8266 project, closed up in a small box (top right in pic: "new ESP8266 wifi remote"), can talk with your air conditioner with infra-red communication;
- in the ESP8266 project I've added a temperature and humidity sensor to monitor in-home conditions;
- trough the router the ESP8266 box can connect to internet and talk to an app in my smartphone;
- both the classic remote control and the new ESP8266 controller talk one-way to air conditioner, it receives commands and makes a beep, but it doesn't talk back to the remote control;
- knowing the IP address of the router, I can talk to your ESP8266 through internet;
- to talk from the Internet to a device in your home wifi network, I've needed to assign a port to my ESP8266 in my router configuration;
Construction of the ESP8266 based WIFI controller
Here is the schema for the wifi controller. I've used a Wemos D1 mini because it's small and cheap, it's based on the popular ESP8266 chip and works perfectly with Arduino IDE.
So in this text the terms ESP8266 and Wemos are interchangeable.
As usual, first I've built it on a breadboard and when everything works, I began to solder.
Pin D4 is used to read temperature and humidity from DHT11 sensor.
Pin D0 is used to send signals to the infra-red led. It's connected to the base of the NPN BC547 transistor which is used as a current amplifier. The infra-red led will talk to air conditioner with impulses so we can use it to drive more current that the WeMos pin can source. A couple of resistors are used to reduce the current to the base of the transistor (1 Kohm) and to limit the current in the led (100 ohm) *.
* = a couple of lines about the values of this two resistors should be written (need help).
(The DHT11 sensor in my project is different from the one in the schema, the one I've used is a module which already contains a 10k pullup resistor, so the resistor of 1kohm between 3.3V and signal pin of DHT11 could be removed) **
** = I should better understand this point (need help)
The network rules and Internet calls
In the Setup( ) section of the code in the Wemos a wifi client that connects to the local home network is started, and the router will give a local IP address to the Wemos. In Setup( ) also a web server is started, which can answer to http calls in your local network.
Here is a drawing to understand how IPs work. Every router creates a private network.
All the local addresses have the same structure and changes only for the last number: 192.168.1.x (depending on your router you could have a different structure, such as 10.0.0.x, etc.).
The code in the Wemos defines that the Wemos can answer to these 3 commands:
server.on("/onoff", switchAcOnOff); server.on("/sensor", sensorData); server.on("/temp", temperatureSet);
So, if the IP of the...Read more »