element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Part 3.3: Arduino Uno + ESP8266 + Eclipse Ponte HTTP Bridge = MQTT Magic
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: pmohan
  • Date Created: 28 Dec 2014 5:00 AM Date Created
  • Views 2864 views
  • Likes 5 likes
  • Comments 10 comments
  • RoadTest
  • infineon
  • mqtt
  • yun
  • rest
  • wifi_christmas_tree
  • iot_holidaylights
  • infineon_led_shield
  • httpclient
  • esp8266
  • http
  • uno
  • arduino
Related
Recommended

Part 3.3: Arduino Uno + ESP8266 + Eclipse Ponte HTTP Bridge = MQTT Magic

pmohan
pmohan
28 Dec 2014

In my last two posts i covered how i setup the Eclipse Ponte Bridge locally and how my Arduino Yun with an Infineon Shield was reading from a MQTT topic from it using HTTPClient

 

In this post i will cover how i used Arduino Uno with an ESP8266 to publish a MQTT message with RGB values.


Arduino Uno + ESP8266


image


I ordered the ESP8266 during this road test because my initial plans of using an Arduino Uno with a CC3200 Simple Link Launchpad didn't work out very well. For $7 it provides bang for the buck as long as you tolerate the initial getting to know you phase. Most of the frustration is because of the different versions and the lack of official documentation. That though seem to be improving of late as the firmware seem to have stabilized somewhat and an updated SDKs seem to have been released this month.

 

I was lucky in that the ESP8266 i got already had the latest firmware and i had the version v0.91 board.  I didn't have to update the firmware. The following is the pin definition of my ESP8266:

image

 

I tried initially to try to use the UNO as a FTDI driver by connecting the ESP8266 to Uno with level shifters. But that didn't work. No response at all from the ESP8266. Then i bought a FTDI breakout board with a 3.3v output and i was able to talk to ESP8266 using CoolTerm (Except for the Arduino, i am using all these different tools for the first time. That added to frustration levels sometimes. But it was well worth it as it helped me learn so many new things). Once i become comfortable with the AT commands, i hooked the ESP8266 back to Arduino Uno using level shifters.

 

Again nothing from Uno.

 

One of the major misconceptions out there seem to be around using level shifters. Every one (including much respected AdaFruit) keeps saying you need to use level shifter to connect the RX pin of the ESP8266 to Uno's TX pin since uno operates at 5V. But the data sheet i found here says this in page 15.

All digital IO pins are protected from over-voltage with a snap-back circuit connected between the pad and ground. The snap back voltage is typically about 6V, and the holding voltage is 5.8V. This provides protection from over-voltages and ESD. The output devices are also protected from reversed voltages with diodes.

 

I am not an electrical or electronics engineer. But that statement seemed to me that it might be OK to connect the ESP8266 directly to my Uno. So i just did that and it worked. (It would be interesting to hear from the engineers in this Element 14 community about that particular statement above)

 

Following is the wiring i did:

 

1. Arduino 3.3v power to bread board red power rail

2. Arduino Ground to bread board ground (black rail)

3. ESP8266 Ground to bread board ground (black rail)

4. ESP8266 CH_PD to bread board red power rail ( This is the reset pin. I was not brave enough to connect it to Uno's reset pin. So every time i loaded my sketch, i had to pull this out and push it back in. A veritable stress test i would say.)

5. ESP8266 TX to Arduino Uno Digital Pin# 2 ( i will be using software serial library to designate this pin as RX for arduino)

6. ESP8266 RX to Arduino Uno Digital Pin#3 ( designated as TX pin using software serial library)

7. ESP8266 Vcc to bread board power rail


That's all. I have been using this setup for a few days now. It has gone through couple of power surges (too much bad weather with lightning here) and still working.


The Software (ESP8266RESTHelper Library)


As i mentioned in the beginning i have already set up Ponte MQTT/HTTP/Coap Bridge locally. ESP8266 has a TCP stack that can be accessed via AT commands. So all i had to do is prepare the proper AT commands for the ESP8266 and make it send PUT requests to the Ponte HTTP bridge for publishing MQTT topics. Other clients whether they use MQTT libraries or HTTP GET (see here) were able to receive the messages.


Since i started working on the AT commands i ended up creating a helper library to do http GET and POST as well.  The ESP8266RESTHelper library is available here at Github. If you are interested take a look and use it as you see fit. Please note apart from the sendMQTTMessage other functionalities are not fully tested. But it might give you a starting point.


Here is the sketch that's running on my Arduino Uno. Visit the Github library to see the API and the AT command sequence.

#include <SoftwareSerial.h>
#include "ESP8266RESTHelper.h"
ESP8266RESTHelper esp8266=ESP8266RESTHelper();
void setup() {
  esp8266.begin();
}
void loop() {
  //Send Red -- topic name starts with "/resources/" because the Ponte http bridge expects PUTS to be sent that way. The actual topic for clients is just "FromArduinoUnoESP/RGB"
  esp8266.sendMQTTMessage("192.168.1.217",6000,"/resources/FromArduinoUnoESP/RGB","255,0,0");
  delay(2000);
]  //send Green
  esp8266.sendMQTTMessage("192.168.1.217",6000,"/resources/FromArduinoUnoESP/RGB","0,255,0");
  delay(2000);
  //Send blue
  esp8266.sendMQTTMessage("192.168.1.217",6000,"/resources/FromArduinoUnoESP/RGB","0,0,255");
  delay(2000);
}

 

Here is a video of the Arduino Uno with ESP8266 sending MQTT messages and the Arduino Yun receiving the mqtt messages and changing the led strip using httpclient(explained in this blog entry) (note that blue led on the ESP8266 go on and off when TCP send happens)

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Updates:

1. Software Serial Library:  (Thanks to a question from Wes in the comments)

I am using Arduino Ide version 1.5.8 beta..This includes a SoftwareSerial Library as part of the core ide libraries..

 

Arduino - Software

 

If you need the Github location for the core libraries, its here:

https://github.com/arduino/Arduino/tree/ide-1.5.x/hardware/arduino/avr/libraries

 

2. My ESPRESTHelper library is using String object.. i have come to realize String is not the ideal thing to use. I am running into weird memory issues once the code becomes bigger and the dynamic memory becomes full. It is ok for simple proof of concepts. I will update the library soon to remove Strings from it.

  • Sign in to reply

Top Comments

  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago +1
    For Most things ESP8266, you should have a look here, My Friend Pete has been putting in extensive research and working with the LUA on chip developer to get this chip singing https://www.facebook.com…
  • imraninsider
    imraninsider over 6 years ago

    where are you giving the network SSID  and PASSWARD...???

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Hi,

    I am using arduino 1.6.1 with arduino uno .I connected esp8266 directly with arduino uno.No external power supply for esp8266.The above code is working but most of the time the wifi module ,esp8266 remains idle.

    Rejini

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to Robert Peter Oakes

    Thanks!  Unfortunately, I can't access Facebook, I am in China now.

     

    I am using 1.0.6 Arduino, the log I got was:

     

    Debed...

    checking..

    ESP 8266 is not available..

    Debug Serial Port opened...

    checking..

    ESP 8266 is not available..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Robert Peter Oakes
    Robert Peter Oakes over 10 years ago

    For Most things ESP8266, you should have a look here, My Friend Pete has been putting in extensive research and working with the LUA on chip developer to get this chip singing

     

    https://www.facebook.com/esp8266wifi

     

    Peter

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago

    Hi,

     

    I am using your code and lib, but it doesn't work here.

     

    I put : #define _DEBUG 1  in ESP8266RESTHelper.cpp, but I still can't see any log in serial monitor.

     

    I am using 1.6 anduino IDE with Arduino UNO.

     

    Thanks,

    Peter

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube