-1

I am new to the community and this is my first question. Hope it turns out to be a nice question :)

Me and my friend are preparing a senior design project on home automation. I have several things in my mind such as controlling drapes, lights, fans with an IOS application.

We started everything from scratch and came up with a great NTC controlled fan and etched it on a PCB as follows

enter image description here

However, here's our bottleneck . Although this circuit works perfectly fine and dandy, this is kind of not what we want. We want a user to control the fan, which made us realized this circuit is a total waste because it is independent of the user, turns up the fan when the temperature goes high not when the user wants it to turn up. What we really want to implement is using something that can be controlled with a phone and works as a switch.

How do you think we can do this? We have this in mind : enter image description here

We are writing an IOS app with Xcode and we use ESP8266 Wifi module to bridge our phone to a web server which makes the connection between the phone and system. Do you think we can go from here? If so, what should we do to make this system work ?

  • 1
    you can buy 4 wire 12v fans. the 4th wire accepts a logic-level PWM signal, meaning you don't need any components besides the micro, a buck (to take 12v to 3.3v), and the fan. with a cheaper fan, you use the MOSFET as described in the answer below to manage PWM. on the ESP8266, i would recommend making the PWM ultrasonic to avoid "kick noise": analogWriteFreq(19532); in setup() – dandavis Oct 08 '17 at 06:19

2 Answers2

0

Sounds like you want an ESP8266 with an API that controls a GPIO pin state. Very simple.

Phone App or Web app -> ESP8266 with route for controlling GPIO -> MOSFET

The MOSFET should be suitable for 3.3V logic. Don't forget the flyback diode on the motor.

Here's some pseudo-ish code:

espServer->on("/api/fan", HTTP_POST, [&]() {
    int pwmSpeed = server->arg("pwm").toInt()
    switchGpioState(pwmSpeed);
}
espServer->on("/get-state", HTTP_GET, [&]() {
    // Send state to browser/app
}

enter image description here

David Kerr
  • 224
  • 1
  • 10
  • I see the answer has been down-voted. An explanation as to why would be beneficial for me and others. – David Kerr Oct 07 '17 at 11:49
  • I didn't downvoted it, but your answer is generic and lacking in specific details. I built a project like that and you answer has no value at all. –  Oct 07 '17 at 13:34
  • The poster illustrated that he wanted to replace a switch with a software control. Using the ESP and a MOSFET seems like sound advice. Also added that he should use a flyback diode on his motor. – David Kerr Oct 07 '17 at 17:30
  • aside: use use MIT app inventor if you want a no-code mobile client app to control the ESP's HTTP API. – dandavis Oct 08 '17 at 06:26
  • dandavis it's a great way to do it for sure. I like making full screen web apps because I don't like installing software on my phone. – David Kerr Oct 09 '17 at 10:59
0

Take a look at MQTT. This a lightweight protocol designed for the IoT.

You will need:

  • An MQTT broker. This program is the "Post Office" for MQTT messages. Clients publish and subscribe for messages here. It run on a PC.
  • An MQTT client library for the NodeMCU or ESP8266.
  • An MQTT browser for iPhone (Android, PC, Mac, ...).

I recommend mosquitto as a broker, but you can start working with a public broker in Internet. It is free, multi-platform and can run in any old laptop.

For iPhone/Android, I use MQTT Dash as a browser.

The beauty of this alternativa: you don't have to code an app for your phone. Protocol is trivial. Setup is non-existent. Is data agnostic (you can send/receive anything, any size). It can easily interact with apps in other platforms (like databases).

The best: it works thru Internet without any extra effort.

A MQTT application

  • 1
    seems silly to go to the cloud to turn on a fan across the room, and rolling out a mqtt local install is not trivial. – dandavis Oct 08 '17 at 06:25
  • @dandavis. It costs nothing extra. The same solution that works Intranet also works Internet. That's the beauty: flexibility at no extra cost. And installing mosquitto is no more difficult than installing Arduino IDE. –  Oct 08 '17 at 09:13