Introduction: Control an Arduino Project Through a Customisable Android / Iphone App With Blynk and Wemos D1: THE 2016 SUPER NOOB FRIENDLY WAY

Picture of Control an Arduino Project Through a Customisable Android / Iphone App With Blynk and Wemos D1: THE 2016 SUPER NOOB FRIENDLY WAY

The aim of this instructable is to teach you how to create wifi connected arduino projects the simplest and fastest way possible. If you want to make an arduino project that you can control from your smartphone and that only costed 4 eurs in hardware, then this project is for you! Do not rely on older instructables that use outdated arduino shields and complicated programs, bootloaders, outdated versions of the esp8266 etc. In 2016 it is possible to setup an arduino / wifi project with a fancy app that you can sell in only a matter of minutes! Interested? Ready? Great! then follow the steps below and your arduino project will be controlled through your smartphone or tablet in no time!

UPTDATE: If you want to control AC 100 to 250 Volts applications with this setup, check out my other instructable!
https://www.instructables.com/id/How-to-Hack-Your-Hot-Girlfriends-Nightlight-With-Y/

Step 1: Getting the Right Arduino Board for the Job

Picture of Getting the Right Arduino Board for the Job

If you want to make an arduino project that is connected to the internet over wifi, you need a board that can connect to wifi. It's that simple. The arduino uno, nano, micro, mega... cannot connect to wifi without the addition of expensive and outdated shields. So save yourself a lot of time and money and don't to this unless you have a good reason to. I learned the hard way... ESP8266 boards are great but often do not support arduino out of the box. A lot of headache is often involved in getting these to work with arduino and their size makes them hard to work with.

Instead get a wemos D1 or Wemos mini board from www.wemos.cc. The wemos D1 is a clone of the arduino uno but uses the esp8266 chip, features full wifi capabilities out of the box and costs only $4,00. Thats right, four dollars for a microprocessor that connects to wifi! It features all the things you know and love about the uno like: digital pins, analog pins, vin, GND, 3,3 v output, power supply connector, 5V output and a fast and easy micro usb connector to upload your sketches.

If you need a smaller board, go for the new wemos mini.

Step 2: Set Up Your Wemos Board and Get the Right Files for the Arduino IDE

Picture of Set Up Your Wemos Board and Get the Right Files for the Arduino IDE

1. Install latest version of arduino IDE www.arduino.cc

2. follow the steps on the wemos site to configure your arduino IDE to support wemos boards: http://www.wemos.cc/wiki/doku.php?id=en:arduino_g...

I strongly recommond following the "Installing with Boards Manager" method

3. download the wemos D1 example sketches

from https://github.com/wemos/D1_mini_Examples/archive/...

4. Unzip the downloaded file
5. Copy all files in your arduino examples directory: (usually C:\Program Files (x86)\Arduino\examples)
6. open arduino IDE, select file - examples - D1 mini examples - basics - blink
7. under tools, select your wemos board and the right com port (this is the usb port you are using, usually only one option will be available)
8. upload your sketch, if your board's led blinks, you did good, if not, you missed one of the above steps.

Step 3: Creating Your Android / Iphone App With Blynk

Picture of Creating Your Android / Iphone App With Blynk

To make our app we will be using blynk. Blynk is a simple tool that allows you to create apps on your phone and share those apps with other people. www.blynk.cc. It is a drag and drop system so no programming language is required and it takes direct control of your arduino's pins. It started as a kickstarter in 2015 but quicly grew to be a professional and highly useful tool. the best part: your app will be created in just one minute and will be fully customisable! Join the blynk forums if you need help or want to contribute.

1. download the latest blynk library from http://www.blynk.cc/getting-started/, unzip and copy it to your arduino library directory (usually: C:\Program Files (x86)\Arduino\libraries).

2. Download blynk app for android or iphone ( it's in the apple / google play store for free) and make your first app. go to settings and chose esp8266.

3. under "settings" in the app you will find "auth token" email this to yourself, you will need it later (see image above)

4. open arduino IDE
5. under file, examples, choose blynk, "esp8266 standalone"

6. in the sketch, add the auth token from step 3 where it says auth token. SSID is geek language for the name of your wifi connection and password is the password to your wifi network. Fill these three in in the sketch in their respective places (see picture). There is no need to further edit the sketch. Just with this code you will have full control over all your board's pins through the app.Take my word for it, it will be great!

Step 4: TEST Your Blynk App!

Picture of TEST Your Blynk App!

1. Add an led to GND and pin 13 on your wemos board
(I want to mention that the proper way to do this, is with a resistor between pin 13 and the LED. Your LED will not live a very long life without)
2. in the app on your phone or tablet, add a slider connected to pin gpO14.
(notice that the pins on the board are not the same as the pins in the app. For a full overview, consult the diagram above, Also notice that I/O pins on wemos boards are 3,3 volt, not 5 volt like on the arduino uno. Do not send 5 volts through them!)
3. hit the play button in the top right corner of your blynk app. CONGRATULATIONS !!!!
YOU NOW MADE A FULLY SMARTPHONE CONTROLLED ELECTRONICS PROJECT !!!!
move the slider to the right to make the led go brighter, to the left for dimmer.




Happy Hacking!

Step 5: Some Important Remarks

- DISCLAIMER: I am not associated with Blynk or wemos. I created this guide because I struggled for a long time to make wifi enabled arduino projects and wanted to give back to the community.

Any comments, remarks and questions are welcome. I am entering this instructables in some contests so if you liked it, please help me win. Every vote means a lot! ;)

https://www.instructables.com/contest/fsl2016/

https://www.instructables.com/contest/arduinoallthe...

- As mentionned before in step 4 the pins of the board do not match the app, check the wemos site for the pin layout of your specific board. It is likely that in the near future blynk will add wemos support ofcourse, then select your board in app and the pins will match. For the wemos D1 layout, check the previous step in this instructable.

- 3.3 v is all the i/o pins of wemos support. You will break your board if you send more through it. A simple resistor or voltage divider circuit can help you if you were to be stuck with 5v input that needed converting.

- The wemos only has one analog pin. If you need a lot more, this guide might not be for you.

I will try to answer to any questions and comments, this was my first instructable so please educate me if you believe I could improve certain aspects in the future.


HAPPY HACKING!

Comments

Kunal Gehlot (author)2017-08-17

How can I control an Arduino Uno with D1 mini via a mobile phone? basically like an RC car.

kimliv (author)2016-09-25

I have a question. When I setup all like it is written here and I juse the slide controle for one output pin I get at the ull slide (255) only a Voltage of 0,82V at the output. At 124 I get 0,47V. I expect values in between 0 and 3.3V. Where is my mistake?

Thank you in advanced.

ckotelmach (author)kimliv2017-03-05

Wemos D1 operates on a PWM range of 0-1024

tunaip made it! (author)2017-02-10

Excellent. Great option for simple IoT projects that do not require much customization.

BillD120 made it! (author)2017-01-14

Hi, Thnx for a good, simple tutorial! Got me up and running on Blynk after a lot of false starts. Some comments and tips I learnt along the way

1. Your WeMos link is out of date - I found this instructable very useful to help set up the Arduino IDE to see the WeMos D1(R1) board - https://www.instructables.com/id/Programming-the-We...

2. ALWAYS (I mean ALWAYS!) update to the latest libraries, files, tools, versions of apps or hardware that you are using. I updated last week and it didn't work . . . new Blynk libraries had been released . . . ALWAYS check and update if required.

3. Blynk is straightforward however . . . each new Blynk project creates a new, unique authentication token - even in the same app on the same device (I started with your Slider, then created a Button project - it didn't work - after a while I noticed the auth token was different - makes sense but something to be aware of.)

4. WeMosoutputs are 3.3v - this will drive an LED but not a basic 5v relay module. if you want to control a relay to switch a mains powered device you'll need a 3.3.v-5v level converter - plenty available on the internet for $1 ea or so.

5. The Serial Monitor is invaluable as a troubleshooting tool. After a rest it displays the connection status - for the WeMos, WiFi and Blynk cloud connection. Very useful to determine where a fault may lie.

6. Thnx again! billd

1.

Grayst0ne made it! (author)2016-12-10

This is exactly what I was looking for. Thanks so much for posting this project. Worked like a charm.

luooove (author)2016-11-24

really great job!

AndrejR10 (author)2016-08-30

One important step is missing. You have to sellect Wemos D1 under Tools/Boards in Arduino application and change Upload speed to 115200. If you do not have it listed, you have to install it using Boards manager:

1. Install Arduino 1.6.7 from the Arduino website.

2. Start Arduino and open Preferences window.

3. Enter
http://arduino.esp8266.com/stable/package_esp8266c...

into Additional Boards Manager URLs field. You can add multiple URLs, separating them with commas.

4. Open Tools→Board:xxx→Boards Manager and install esp8266 by ESP8266 Community (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
(steps copied from http://www.wemos.cc/tutorial/get_started_in_arduino.html)

Mark Weir (author)2016-07-21

Hi Ruben,

I have installed the Blynk library and can see it in the IDE list but there are no examples for Blynk in my list. What have I done wrong here?

Cheers

Mark

Oliberserk (author)2016-06-07

Hey Ruben! Looks pretty nice and inspiring (as well as your other instructables). :-) I was wondering if it is possible to make some sort of wireless sensor out of the WeMos D1 mini (adding some shields, obviously). Thinking about checking temperature, moisture and acidity of my composting bins and reading the values on my smartphone... Any suggestion would be VERY appreciated ;-)

Btw, thats a really cool idea :)

Hey, thanks!

My bins are in a shack (pretty cold up here in Finland, so I don't want my compost to freeze) with electric power available, so maybe it's wiser to find some solution that's not depending upon batteries. Thanks for the advice ;-) I ordere a WeMos D1 mini, an OLED and the DHT22 for the start. Hope I can get something working with that... If it's OK, I'll shout for help if I'm stuck... ;-)

Hey again,

I am in Norway, so I totally get what you are talking about. Check out my other instructable: https://www.instructables.com/id/How-to-Hack-Your-H...

I added a new step today explaining how to best use the DHT22, it s all the way at the bottom. I also explain in detail how to use power from the wall outlet to power your wemos. YOu need an ac to dc converter. Links are included. Wall power is def the way to go for permanent sensors. Shout out if you need more ;)

PS: Vote for my other instructable in the link if you find it helpful pls ;)

hey there,

Thanks for the kind feedback!
The wemos when connected to wifi drains up to 200 ma. therefore it is unwise to run it completely wireless on a battery for a long time. A car battery however would do the trick if thats an option?

NigelB13 (author)2016-05-29

Well thank goodness for you! Well done and thank you very much indeed Ruben for making this introduction to the Wemos d1 r2 board as painless and user-friendly as possible. So painless and user-friendly in fact, that even I managed to get it working on the very 20th or-so attempt! ;) Brilliant! Well done!

Thanks for the kind feedback! 20 aint so shabby ;). Dont forget to check out the sequel to this instructable on my profile ;)

Thanks for your kind feedback!
My next instructable is the sequel to this one.

https://www.instructables.com/id/How-to-Hack-Your-H...

Check it out, vote if you like it ;)

BilalB20 (author)2016-06-04

HEy Ruben March Speybrouck I need u'r help in a project... Please Reply

what do you need help with ? :)

CarlS61 (author)2016-05-02

This is absolutely fantastic! Thank you very much for your clear and easy to follow instructions. I got my D1 Saturday and followed your lead...it works great. The only bump in the road was the fact that my board shows no pin 13; it is D5. I've got all kinds of ideas now. Thanks again Ruben...You're the MAN!!!

Hey Carl,

Your kind words finally got me to sit down and write the follow up instructable to this one. Thank you for inspiring me and giving me the motivation to spend my time usefully. Please check it out and tell me what you think! It is the next step in learning IOT.

https://www.instructables.com/id/How-to-Hack-Your-Hot-Girlfriends-Nightlight-With-Y/


PS: I ll fix the remarks you made on the pins

bo_peterson made it! (author)2016-03-16

Thank you for easy to follow tutorial!

Happy you enjoyed it, stayed tund for more :)

doity (author)2016-03-05

thanks for this clear instruction so far but uploading the blink sketch says

warning: espcomm_sync failed
error: espcomm_open failed

Can you tell me what is wrong?

Is the Wemos D1mini I used not OK?

Sorry for the late response. Ihave had this error occur because:

Cable was bad
Choose the wrong port in arduino ide
The wemos D1 is not selected under board manager
Your speed is wrong as allready pointed out.

If none of this helps, reinstall wemos on arduino ide before proceeding

bo_peterson (author)doity2016-03-16

I had the same problem but changed Tools->Upload speed to 115200 and then it worked

Gusgonnet (author)2016-04-06

Ruben, you rock!

this is a nice project and at that cost I have to try it soon.

Question: do you know if it's possible to flash the wemo via wifi or this is done only via USB?

thank you

Hey,

thanks for the kind words.
Only through usb 8to my best knowledge)

Gusgonnet (author)Gusgonnet2016-04-06

I think I got my answer: Yes you can flash it via OTA.

source: http://www.wemos.cc./Products/d1_mini.html and http://www.wemos.cc./Products/d1_r2.html they both say:

You can also program it using OTA.

MarkF126 (author)2016-02-20

How much RAM is available for a sketch?

using the wemos D1 board:

The sketch used 219 018 bytes ( 20%) program storage. Maximum capacity is 1,044,464 bytes.
Global variables use 34 480 bytes ( 42 %) of the dynamic memory. Remain 47 440 bytes for local variables. Maximum is 81,920 bytes.

ngadhno (author)2016-02-14

Ruben, thank you very much for sharing this project with us.

My pleasure ;)

dick55 (author)2016-01-30

I have been using the small NodeMCU board (version 1.0 with an 8266-12E) . This is already supported on the Arduino IDE and is again available quickly from several US suppliers on ebay (a BIG advantage). It comes with Lua firmware, but i have never used it. Just hook its USB port to your PC, fire up Arduino and go to it. Is there any advantage to the Wemos D1? It is a nice looking board, but it seems to duplicate the functions of the NodeMCU in a larger package.

Hey there,

Thanks for reading! I have not used the board you mention.
The reason I recommend the Wemos D1 is because I feel it is very beginner friendly. Just like the Uno it features pins that directly accept jumper wire making it a great choice for experimenting. It also has a full on dc jack. It looks like the D1 board could take more abuse than smaller counterparts (I have not managed to break it is all I can say) and I like that there is a simple instruction on how to get started with arduino on their homepage www.wemos.cc. These simple guides were really lacking with other products and resellers and are what convinced me. It simply worked for me, whereas other esp8622 products often left me with a feeling of "where the ***** do I begin to get this working" when they would arrive from China.

Regarding size, I believe the wemos mini is even smaller than the NodeMCU board. The difference cannot be big. The price is the same.

A major advantage on the wemos line for me is that they feature 5v outputs. This allows you to work with 5v sensors like RTC's or IR sensors without adding hardware. Correct me if I am wrong but your board does not feature a 5v output I believe? only 3,3v?

Finally I was pleased to receive my products with free shipping from their official aliexpress store after only 2 weeks in Belgium. At €4 a board for the mini I didn't think that was to bad.

You are obviously not a beginner though so for you I would recommend using the board you allready have. Like you said the difference is not large and the price from China is about €4 for both products and about €8 for the D1 (which in my opinion is worth it because it's dupont female headers make it easiers to tinker with.

Hope this helped :)



You are obviously very pleased with the wemos board and I'm glad to hear it. You are definitely a good spokesman for the product and as a result I will get one to try out. They are certainly cheap enough, and like I said it is a very nice looking board.

You are right, the only time that 5V is available as a supply output on the NodeMCU's Vin pin is when the input voltage is 5V (e.g. from the USB connection). I have one hooked up with a 5V RTC but I am using a 5V "wall wart" supply to get away from batteries in in an outdoor system (lawn sprinkler control with WiFi data reporting).

As far as ease of getting started, nothing could be easier than a NodeMCU board. As I said, just plug in to usb and start programming on Arduino IDE (no board installation required, it's already there). However, for either wemos or NodeMCU the hard part is learning WiFi programming; I'm still struggling with it. The Arduino examples are helpful and Sparkfun has a good tutorial for their Thing board.which is worth looking at.

I am not associated with Wemos but I think you will enjoy your purchase. Anoter advantage I just discovered about the D1 is that it can be powered by up to 24V.
Regarding your RTC, Blynk is about to launch RTC support, so soon you will not need it anymore. (but I agree it's nice to have the option for offline use)

Wifi programming is indeed a topic on it's own. If you know good tutorials, please share them with me here or in a pm? ;)

For now I have been using Blynk so I would not have to deal with programming directly but I am planning on making my own apps at some point.

ChongkaiJ (author)2016-01-25

Just voted for you. I was so confused how to get started after first seeing this board, until I see this post! I'm trying to DIY an automatic curtain controller, this will definitely help me! Thanks for sharing.

I was pretty confused myself at first.
So I'm happy this guide was able to help you! ;)

If you have some time, do post your automatic curtain controller on instructables, it sounds really interesting!

Ruben Marc Speybrouck (author)2016-01-18

Happy you guys enjoyed my instructable!
If you'd like you can vote for this instructable here in these two links:
Every vote is really appreciated ;)

https://www.instructables.com/contest/fsl2016/

https://www.instructables.com/contest/arduinoallthe...

KingEli (author)2016-01-18

Wow, nicely explained!! Finally a decent tutorial for this on the internet!

DIY Hacks and How Tos (author)2016-01-18

Awesome Arduino controller.