element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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
Internet of Things
  • Technologies
  • More
Internet of Things
Blog ESP8266 Wi-Fi  + Arduino upload to Xively and ThingsSpeak
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Internet of Things requires membership for participation - click to join
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: janisalnis
  • Date Created: 19 Nov 2014 7:56 AM Date Created
  • Views 9439 views
  • Likes 8 likes
  • Comments 11 comments
  • internet_of_things
Related
Recommended

ESP8266 Wi-Fi  + Arduino upload to Xively and ThingsSpeak

janisalnis
janisalnis
19 Nov 2014

In 2014 might have started a revolution in the Internet of Things. New ESP8266 Wi-Fi modules are tiny, cost less than 5 USD and take care about Wi-Fi connection and encription in Access Point mode and in client mode.  Communication to the module is via simple serial RX and TX lines using "AT" type commands and data. ESP8266 is intended for use in smart power plugs, mesh networks, IP cameras, wireless sensors, wearable electronics, etc.

It is based on 32-bit processor Tensilica’s L106 Diamond series. Boots from external flash chip.

 

image

 

image

 

Some links:

  • Specifications, schematics: http://www.mikrocontroller.net/attachment/231858/0A-ESP8266_Specifications_v4.pdf
  • Can be programmed from Arduino IDE https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon
  • Wi07c - ElectroDragon
  • https://nurdspace.nl/ESP8266
  • wireless:esp8266    [Boxtec Playground]
  • Range tests >300m, 4km with dish UBIQUII M2 dish
    http://www.element14.com/community/people/Problemchild/blog/2014/09/29/esp8266-wifi-rangedistance-tests
  • Schematics ESP8266 WiFi Serial Module Costs Just $5
  • https://www.youtube.com/watch?v=9QZkCQSHnko
  • http://scargill.wordpress.com/2014/09/27/investigating-the-esp8266-serial-killing/
  • A very good tutorial about upload to thingsspeak.com and firmware upload
    http://www.instructables.com/id/ESP8266-Wifi-Temperature-Logger/?ALLSTEPS
  • GCC toolchain, 10bit ADC(not useful when RF running) https://github.com/esp8266/esp8266-wiki/wiki
  • Cloud updating your Wi07C ESP8266 http://blog.electrodragon.com/cloud-updating-your-wi07c-esp8266-now/
  • Interfacing with Teensy http://kaspars.net/blog/electronics/esp8266-teensy-arduino

 

ESP8266 control from a PC via USB-serial

 

As a first step it is a good idea to check that the module works using RX TX lines from an USB-serial adapter.

 

  • USB-serial with a CP2102 chip could not supply enough current and I used an external 3.3V LDO regulator on a SD card board that I just had around.
  • ESP8266_RST needs to be connected to 3.3V. It can also be used to reset the module any time.
  • Connection speed is 115200 bps. USBserial transmitting signal went directly to ESP8266, no problem that it has 5V peak.
  • CH_PD is enable pin and should be at VCC.  To reset module pull RST low. To upload new firmware pull GPIO2 low.

 

image

 

Connect to COM port via a serial console like Putty or on Arduino IDE at 115200 and send a command AT. Responce should be OK. Blue onboard LED should blink shortly.

If get responce busy p... you need to pull reset connection low. Better to connect reset to VCC (directly or via  resistor).

 

ESP8266 happily accepts data at 5 V (datasheet says inputs are 5V tolerant). ESP8266 power supply remains at 3.3 Volts.

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.

 

CommandResponseDescription

AT+RST

ets Jan  8 2013,rst cause:4, boot mode:(3,7)    wdt reset  load 0x40100000, len 24444, room 16    tail 12  chksum 0xe0  ho 0 tail 12 room 4  load 0x3ffe8000, len 3168, room 12    tail 4 chksum 0x93 load 0x3ffe8c60, len 4956, room 4  tail 8  chksum 0xbd  csum 0xbd  ready

Reset

AT+CWMODE=1

OKWi-Fi client

AT+CWJAP="OpenWrt",""

OKConnect to my Wi-Fi router. I have no passowrd.

AT+CIFSR

192.168.1.200Ask what IP address it got. ESP8266  is pingable from a PC.

AT+CIPMUX=0

Set the single connection mode

AT+CIPSTART="TCP","220.181.111.85",80"

Ok LinkedStart a TCP socket

AT+CIPSEND=22 GET / HTTP/1.0\r\n\r\n

1234567890123456789012

SEND OK UnlinkSend 22 bytes of data
AT+CIPCLOSEClose connection

AT+GMR

00160901Firmware version

AT+CIPSTO

Timeout value

AT+CWLAP

+CWLAP:(0,"OpenWrt",-51)

+CWLAP:(0,"PC_Network",-93)

List APs around

+ CWLAP: <ecn>, <ssid>, <rssi> [, <mode>] 

ecn: 1 WEP

2 WPA_PSK

3 WPA2_PSK

4 WPA_WPA2_PSK

AT+CWJAP?

+CWJAP:"yourWiFinetworkid"

To check if it has joined the network.

 

 

 

Firmware update

 

Original firmware of ESP8266 supports only 115200 bps and has to be updated to be used with Arduino SoftwareSerial working at max 9600 bps

Main (hardware) serial of Arduino is very convenient to use for programming and debug use.

 

Firmware update is described by Electrodragon and adds some new functionality. Flashing utility can only use USBserial port  COM1-COM6. I had to tweak that number in Windows device manager. Fig. 1.

During update GPIO2 (or 0) needs to be connected to GND. v9.22: single file upload to 0x00000. v9.25: needs two files. First file is transfered at 115200 to adress 0x00000. After first flashed file changed speed to 9600 and flashed the second file at address  0x40000. It took me a couple of hours to learn updating for the first time with intermediate bricking. But updating was well worth it.

Commands: Test inquiry range: AT+CIOBAUD=?  Check current baudrate: AT+CIOBAUD?    Set:  AT+CIOBAUD=9600

imageimageimageimageimage

 

 

 

ESP8266 + Arduino + Xively upload

 


image

 

  • 5V  from USB-serial is connected  to the 3.3V LDO regulator (LM1117 with blocking capacitors) that supplies both Arduino and ESP8266.
  • I use Arduino Pro.Mini328p without onboard USB because it is possible then  to power Arduino from external 3.3V.
  • Arduino hardware serial is connected to USB-serial adapter for programming and debugging and software serial is connected to ESP8266.
  • ESP_RST should be pulled up. It has to be activated if the module returns busy p...  message.
  • I implemented power down mode by controling  CH-PD pin. See notes about consumption below.

 

 

Power consumption

 

I connected a multimeter in a 3.3V line. While Wi-Fi is working the multimeter is jumping between 25 and 75 mA. When in power-down mode (CH-PD low) current drops to 0.3 mA. This is drawn by the red LED. After removing the red onboard LED, the ESP8266 board current consumption is only 16 uA. That is amazingly low. Arduino current consumption is not measured.

 

 

Xively upload

 

Code for Arduino 1.02 is attached at the end of this blogpost.  For simplicity some random data are uploaded. Uploading to Xively works fine on long term without freezing. Live link is https://xively.com/feeds/1784300880

image

 

When the program works it provides following debug information over USB-serial:

 

AT+RST

OK

[System Ready, Vendor:www.ai-thinker.com]

Connecting to AP

AT+CIFSR

192.168.1.200

 

AT+CIPSTART="TCP","64.94.18.120",80

Linked!

 

AT+CIPSEND=319

PUT /v2/feeds/1784300880 HTTP/1.1

User-Agent: ESP8266

Host: atomar.de

Content-Type: application/json

Content-Length: 136

X-ApiKey: qpLG77lHBQVhhJlJ5yAhOAin_CggAaW5tnTVnyGj09k

 

{"version":"1.0.0", "datastreams": [{"id": "temperature", "current_value": "4.19  "}, {"id": "humidity", "current_value": "53.33  "}]}

success X-Request-Id

955e9a9c4584286436fd227153f12bdede7c8801

 

sleeping...

 

 

Major programming complication with Xively is that it is difficult to prepare json data for upload. One needs to insert data into special place into json and count the length of message.

I don't understand why HTTP GET method can not be used for sending data. Something like this http://xively.com/?key=xxxxxxxxxxxx&datastream=temperature&value=20.0

http GET  is used for data retrieval from Xively. Xively has not repplied to my email about this question. Probably it is not possibleand they are too busy.

 

 

 

Xively ALERT on November 2014: Can not sign-up a new user

 

"Free Developer Sign-Up:

We currently have a waiting list for free developer account sign-ups on Xively.

If you would like to request access, please fill out the access request form and we will notify you as soon as a spot opens up."

 

Because of that had to look for an alternative IoT proivider.

 

 

 

Things Speak

 

It allows to upload IoT data, makes graphs and allows to download data or emmbed them in own website as live graph. A very nice tutorial is in Instructables:

ESP8266 Wifi Temperature Logger

 

I signed up, got a channel and a key for it:

https://thingspeak.com/channels/19501

 

Can upload data using HTTP GET where do not need to count message that significantly simplifies life compared to HTTP PUT:

https://api.thingspeak.com/update?key=X7XV2EFC3WQIBGHZ&field1=71&field2=12.34

 

Uploading from a microcontroller:

GET 184.106.153.149/update?key=X7XV2EFC3WQIBGHZ&field1=20.43

 

View data as json:

http://api.thingspeak.com/channels/19501/feed.json?key=X7XV2EFC3WQIBGHZ

Download as text csv:

http://api.thingspeak.com/channels/19501/feed.json?key=X7XV2EFC3WQIBGHZ

 

Chart API which takes the data and displays it as configurable chart:

http://community.thingspeak.com/documentation/api/#charts

 

Here is the chart:

http://api.thingspeak.com/channels/19501/charts/1

Attachments:
V0925.zip
XTCOM_UTIL.zip
EPS8266_Arduino_Xively.ino.zip
  • Sign in to reply
  • Former Member
    Former Member over 9 years ago

    Hello

     

    I’m quite new to arduino and esp8266. Currently I’m trying a simple thing – connect arduino UNO to wifi network using ESP8266 and read a webpage from the internet.

    I’m using the AT firmware on ESP8266. I can connect it to wifi and open a TCP connection to web server, pass the URL I want to receive, but I have the following problem:

     

    while (Serial.available()){

      char c = Serial.read();

      dbgSerial.write(c);

      strReceived+=c;

    }

     

    This gives me exactly what I need to my debug console – the whole HTTP response together with the content. The moment I comment out the debug output to soft serial, I only get very little data from the server. When I add a delayMicroseconds(50) after Serial.read(), I get a little more data to strReceived, but never as much as when I use the serial debug.

     

    any advice?

    AT+GMR output:

    AT version:0.21.0.0

    SDK version:0.9.5

     

     

    thank you very much

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • janisalnis
    janisalnis over 9 years ago in reply to rudraxx

    Hi!

    I wanted to try out ThingsSpeak, started to collect materials where other people succeded, but did not have time to test myself. Sorry. May be I will do it in a month or so.

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

    Hi!

    Thanks for your interest about CH_PD pin.

    I have wired it directly to Arduino. Without pulll up resistor. Below are some relevant lines from the code.

     

    #define CH_PD_PIN 4

    pinMode(CH_PD_PIN, OUTPUT);

    digitalWrite(CH_PD_PIN, 1); // bring up ESP8266 from power-down mode. It resets.

    digitalWrite(CH_PD_PIN, 0);  // activate PD power-down pin of ESP8266

     

     

    Good luck!

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

    You are the first person to mention controlling the esp8266 ch_pd power up/down via an Arduino digital port;  excuse my ignorance,but how is this done?  just by a direct connection to one of the digital ports and setting the port high/low? or do I need a pullup resistor to Vcc as well?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • rudraxx
    rudraxx over 9 years ago

    Hello,

    Great article.

     

    I am struggling with reading the last value of a channel with ThingSpeak and ESP8266. Have you been able to do that using the Arduino? I could really use some help.

    I can access the last val using my browser on my laptop, but havent been able to do that with arduino.

     

    Can you please help me out with the code for that?

    I asked on the thingspeak forum but no success.

    http://community.thingspeak.com/forum/thingspeak-api/help-with-get-command-arduino-thingspeak-esp8266/

     

    Thank you!

    Abhi

    • 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