How to read field data from a particular channel in thingspeak? | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
How to read field data from a particular channel in thingspeak?
No permission to create posts
June 5, 2018
5:03 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

I have
1> ESP8266
2>Arduino UNO
I have successfully connected my ESP8266 module to wifi through AT command.
I have also connected my arduino to api.thingspeak.com.
i have successfully upload sensor data into thingspeak channel using AT command from serial monitor in arduino.
But now I want to read the same sensor data from thingspeak using AT command.
Is it possible to read those sensor data back from thingspeak to serial monitor of arduino?
Can you please suggest me something.

June 5, 2018
9:32 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

In my opinion it is much easier to program the ESP directly with the Arduino IDE. The AT commands are much harder to follow.
There is an example in the doc showing you how to use the ESP8266 to read ThingSpeak data using the ThingSpeak communication library.
https://www.mathworks.com/help/thingspeak/read-and-post-temperature-data.html

There are many other examples for both Arduino and ESP8266 at
https://www.mathworks.com/help/thingspeak/examples.html

If you absolutely need to use the AT command set, you should be able to just change the write addresses to read addresses and then parse the answer. See the read data page for the proper REST call to substitute.
https://www.mathworks.com/help/thingspeak/readdata.html

The example below does not use the ThingSpeak Library, so it shows how to get the read response and put it to the serial monitor. You could use these methods with your AT commands if you need to.
https://www.mathworks.com/help/thingspeak/MoistureMonitor.html

June 6, 2018
1:57 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Thank you so much and I will try it Laugh

June 6, 2018
12:26 pm
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

I have tried this one https://www.mathworks.com/help/thingspeak/read-and-post-temperature-data.html,
In this link nodemcu is there but I want arduino.Cry
but not able to add esp8266wifi.h library into code.
Whenever I am searching this library in include library option in arduino IDE, I am not able to find this library.
Another thing I have only arduino and esp8266 wifi module.
My arduino doesnot contain any ethernet or wifi shield.
Could you please help me out?

June 6, 2018
3:42 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Did you follow step 3 in the section "Program your esp8266"?

Add the ESP8266 Board Package.

Under File > Preferences, enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs.

Choose Tools > Boards > Board Manager. Enter ESP8266 in the search bar and install the package.

You need this step to see the library. You can do almost anything you wanted to do with the Arduino on the ESP. The ESP has built in WiFi. Depending on what model of ESP you have, you will have digital GPIO, and if you have eps8266-12, you will also have an analog pin with an ADC. The esp8266 generally has only 3.3 V though. It also has fewer GPIO in general.

Can you describe your project?

June 7, 2018
12:40 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

This error I am getting when I am uploading the code to arduino:
I am using the linlk https://www.mathworks.com/help/thingspeak/read-and-post-temperature-data.html,

esptool v0.4.13 - (c) 2014 Ch. Klippel
setting board to ck
setting baudrate from 115200 to 115200
setting port from /dev/ttyUSB0 to /dev/ttyACM0
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
opening port /dev/ttyACM0 at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
resetting board
An error occurred while uploading the sketch
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed

June 7, 2018
3:09 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Are you using the Arduino IDE to upload code to an esp8266-01?
The esptool sounds familiar, is this output coming from the programming window in the Arduino IDE or from another interface?

June 8, 2018
5:06 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Yes,it is coming from programming window in the Arduino IDE.
What happen anything wrong I have done.Cry

June 10, 2018
1:55 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Were you able to install the add the esp board package as I described above?

Are you using an esp8266-01 (the little 6 -pin version) or some other board such as NODE MCU?

Make sure you are in bootloader or programming mode. If it is a board link a node MCE, hold the program button down while pressing the reset. If it s the 8266-01, make sure the appropriate pin is held low during power on. (it might be gpio-02, or 00)

Also double check all your other connections. Have faith, I'm sure we will get it shortly!

June 11, 2018
1:12 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

I am using ESP8266-01.
There are 8 pins in ESP8266-01.
Tx pin of ESP8266 connected to Arduino Tx pin.
Rx pin of ESP8266 connected to Arduino Rx pin.
VCC and CH_EN pin of ESP8266 is connected to 3.3 v pin of arduino.
GND pin of ESP8266 is connected to GND of arduino.
Arduino is connected to laptop through USB port.
Is it right connection that I have done?
Then I am uploading the program through arduino IDE.

June 11, 2018
3:15 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

I am not using NODEMCUCry

June 11, 2018
4:55 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Thanks for the correction on the pin count for the -01. I typed too fast on that one.
To program the esp8266-01 you need to tie gpio-0 -pin 5- to ground (and then reset the power. ) After you program, release the hold to ground on gpio-0 and then reset.
See the schematic here for example:
https://www.allaboutcircuits.com/projects/breadboard-and-program-an-esp-01-circuit-with-the-arduino-ide/

June 12, 2018
2:38 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

So connection is like this:
1>Tx pin of ESP8266 -> Arduino Tx pin.
Rx pin of ESP8266 -> Arduino Rx pin.
VCC and CH_EN pin of ESP8266 -> 3.3 v pin of arduino.
GND and gpio-0 pin of ESP8266 is connected to GND of arduino.
Arduino board is connected to laptop through USB port.
Is this the correct connection?Laugh

June 12, 2018
2:40 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Correction:
VCC and CH_PD pin of ESP8266 -> 3.3 v pin of arduino.

June 12, 2018
8:15 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

That should work, but then remove the connection from gpio-0 after you program. Is it working? what does the Arduino programmer say now?

June 12, 2018
3:51 pm
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Thank you so much for information.
I have ordered for USB to serial converter,
once it will come I will let you know

June 12, 2018
5:39 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Do you have an Arduino? The Arduino will do the serial conversion for you, you shouldn't need any other hardware. Sorry if the schematic I referenced confused you.

June 13, 2018
2:53 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Yes I have arduino board.
My steps:
1>Select Sketch > Include Library > manage Libraries. Select ThingSpeak to add it to your sketch.
2>Under File > Preferences, enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs.
3>Choose Tools > Boards > Board Manager. Enter ESP8266 in the search bar and install the package
4>Then Tools > Boards > Generic ESP8266 module ,I am selecting.
5>Then I am compiling the code.
In compilation no error is showing.

Pin connection:
So connection is like this:
1>Tx pin of ESP8266 -> Arduino Tx pin.
2>Rx pin of ESP8266 -> Arduino Rx pin.
3>VCC and CH_EN pin of ESP8266 -> 3.3 v pin of arduino.
4>GND and gpio-0 pin of ESP8266 is connected to GND of arduino.
5>Arduino board is connected to laptop through USB port.

When I am uploading the code this error is showing:

>opening bootloader
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
resetting board
An error occurred while uploading the sketch
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
resetting board
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 41 instead of C0
trying to connect
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: 0D instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
Cry

June 13, 2018
7:32 am
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 437
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

The process you describe looks good. I remember the esp8266-01 being a bit flaky, though I am definitely able to program it consistently now. My set up uses a 2.2k pull up resistor for CH-EN (At times I would also use a pull up on the reset, but that does not always seem necessary.) Some people even put a pull up on GPIO-2, just to make the state well defined. The need for these could depend on the quality of the computer power supply. Most often my problem was a improperly connected wire, so be sure to check your connections and re check them. Make sure your version of the Arduino software is updated, and make sure you have the connection to ground on gpio-0 already established before you power on.
I remember being at wits end often, and then suddenly getting it to program, so keep plugging, and let us know.

June 14, 2018
1:07 am
Avatar
Happy

Silver
Members
Forum Posts: 13
Member Since:
June 5, 2018
sp_UserOfflineSmall Offline

Thank you so much, I will try and let you know.Laugh

No permission to create posts
Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: deekshana
35 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

JavierLecy, gwenbk2, eloisedq3, AEtedesar, RichardWosus, Kellynapse

Administrators: Hans: 387, lee: 457