Author Topic: HOW-TO: Add WiFi to your arduino projects with ESP8266  (Read 13811 times)

0 Members and 1 Guest are viewing this topic.

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
HOW-TO: Add WiFi to your arduino projects with ESP8266
« on: August 05, 2015, 12:22:38 PM »
Option 1: Using the ESP8266 as transparent seraial bridge

What you need:
- Arduino
- ESP8266 module (e.g. ESP-01)
- FTDI with 3.3V
- computer/notebook with WiFi


That’s it!
The ESP should now connect to your network. You can find its IP e.g. with AutoScan-Network.

Connect your ESP to your Arduino (RX <-> TX, TX <->RX)
CAUTION: The ESP module works with 3.3V while most Arduinos work on 5V! Since the ESP module draws a lot of current, you will probably not be able to power it by your arduino. (The RX/TX pins seem to be 5V tolerant and I connect them directly to my (5V) arduino, try at own risk.)

You can now send messages to the serial port of your arduino with the VC action TCP.Single.WriteLn! You need to add the IP of your ESP and use port 23. Make sure to append \x0A to every message!

Have fun!
« Last Edit: August 09, 2015, 06:55:38 PM by Dave »

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #1 on: August 05, 2015, 12:23:03 PM »
Option 2: ESP as stand alone chip. Programming the ESP with Arduino IDE

What you need:
- ESP8266 module (e.g. ESP-12)
- FTDI with 3.3 V


Note 1: Some libraries might not work!
Note 2: Pin numbers match GPIO numbers!

You can find a simple sketch with an web server to toggle an LED here:
http://www.esp8266.com/viewtopic.php?f=29&t=3787
« Last Edit: August 09, 2015, 03:22:14 PM by Dave »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #2 on: August 05, 2015, 12:49:04 PM »
 ::bow  Great work Dave!
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #3 on: August 05, 2015, 12:55:02 PM »
I'm looking forward to seeing "Option 2" !
« Last Edit: August 05, 2015, 10:54:42 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #4 on: August 05, 2015, 12:58:43 PM »
You can now send messages to the serial port of your arduino with the VC action TCP.Single.WriteLn! You need to add the IP of your ESP and use port 23. Make sure to append \x0A to every message!

What about receiving messages back from the Arduino?  We previously used an event generated by the serial port.  Will we now get a TCP event?  In order to do this, we would need to use TCP.Client instead of TCP.Single?

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #5 on: August 05, 2015, 01:06:20 PM »
What about receiving messages back from the Arduino? 

I did not try this. I will report back as soon as possible. Or maybe Kalle could try it, since I'm not at home the next few day?
« Last Edit: August 05, 2015, 10:54:11 PM by jitterjames »

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
***********  get excited and make things  **********

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #7 on: August 09, 2015, 03:25:44 PM »
Option 2 is now available!  :)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #8 on: August 09, 2015, 05:11:31 PM »
Awesome.  Looks pretty straightforward.

Thanks Dave!  :hugs

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #9 on: August 09, 2015, 05:37:31 PM »
So for option2, we don't need to flash the firmware first?  Does that mean then that we do not connect GPIO0 to ground?

Or are we effectively flashing the unit every time we program it from the Arduino IDE?
« Last Edit: August 09, 2015, 05:41:54 PM by jitterjames »

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: HOW-TO: Add WiFI to your arduino projects with ESP8266
« Reply #10 on: August 09, 2015, 06:54:45 PM »
We are flashing the firmware every time we upload a new sketch, so you have to connect GPIO0 to GND first (before powering the module)!

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: HOW-TO: Add WiFi to your arduino projects with ESP8266
« Reply #11 on: August 28, 2015, 04:12:33 AM »
Now it looks like the MySensors stuff is ported to the ESP8266  :yay

http://forum.mysensors.org/topic/1870/esp8266-wifi-gateway-port-for-mysensors/1
***********  get excited and make things  **********

mexicanto

  • Contributor
  • ***
  • Posts: 55
  • Karma: 1
    • View Profile
Re: HOW-TO: Add WiFi to your arduino projects with ESP8266
« Reply #12 on: December 29, 2015, 09:59:23 AM »
Hello Dave,

By any chance, do you have an example/code that you can share ?

I refer to the option 1, esp8266 + arduino (the mini pro 3.3v)

I am trying to turn on/off a led, reading an analog value and trigger an event with a push button

Any help will be greatly appreciated
« Last Edit: December 29, 2015, 10:05:12 AM by mexicanto »

Dave

  • $upporter
  • Sr. Member
  • *****
  • Posts: 139
  • Karma: 31
    • View Profile
Re: HOW-TO: Add WiFi to your arduino projects with ESP8266
« Reply #13 on: December 29, 2015, 04:41:31 PM »
Hi mexicanto,
sorry, I don't have any example code. What you want to do should be possible in theory, but I never tried sending messages from arduino to VC using the serial bridge method. I don't use this method anymore at all. As long as you only need one analog input I would recommend using method 2 e.g. with a nodemcu board.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: HOW-TO: Add WiFi to your arduino projects with ESP8266
« Reply #14 on: December 29, 2015, 04:53:25 PM »
***********  get excited and make things  **********