Receiving Data from IOT to esp8266 using PSoC 4200 BLE | ESP8266 Wi-Fi Module | Forum


Please consider registering


— Forum Scope —

— Match —

— Forum Options —

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

Register Lost password?
sp_Feed sp_TopicIcon
Receiving Data from IOT to esp8266 using PSoC 4200 BLE
New Member
Forum Posts: 1
sp_UserOfflineSmall Offline
September 24, 2016 - 10:56 am
sp_Permalink sp_Print

I have interfaced the ESP8266 WIFI to the PSoC4200 BLE board via UART interface.
Now I have to receive data from the IOT via a GET request.
I searched many forums but I only found solutions with Arduino, and i cant find any solution where they have interfaced it to the PSoC board.
So, can you please help me with the solution as to how can i use the esp8266 to receive the data from iot using the GET request.


Thank You



Forum Posts: 192
sp_UserOfflineSmall Offline
September 24, 2016 - 10:32 pm
sp_Permalink sp_Print

If you are just looking to GET the last datapoint on a channel, you could GET the<CHANNEL_NUMBER>/fields/<FIELD_NUMBER>/last.json , for example.

If you are looking to do more than just read the last value, you may be interested in learning more about the TalkBack app on ThingSpeak. 


Forum Posts: 12
sp_UserOfflineSmall Offline
September 28, 2016 - 1:25 pm
sp_Permalink sp_Print sp_EditHistory



I am not sure what you are looking for. If you are just looking for the format of the GET request t fetch a channel feed, Vinod's answer should help you. For more documentation on this you can visit: GET a Channel Feed, Get a Channel Field Feed. Else, if you are looking for a generic C program and not an Arduino sketch to send a GET request to fetch data from a channel field feed, you can use the following program as a starting point. 

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>

void error(const char *msg) { perror(msg); exit(0); }

int main(int argc, char** argv)


/* Send data to ThingSpeak*/
int portno = 80;
char *host = "";

struct hostent *server;
struct sockaddr_in serv_addr;
int sockfd, bytes;

/* Message to send to send to server. Note change the channel number, field number and read API key to that of your channel */
char *message = "GET /channels/<channelnumber>/fields/<fieldnumber>.json?api_key=<readAPIkey>&results=1 HTTP/1.0


//Buffer to receive the response
char response[4096];

// Create the socket
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) error("ERROR opening socket");

// Look for the ip address
server = gethostbyname(host);
if (server == NULL) error("ERROR, no such host");

// Set the struct settings
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(portno);

// Connect the socket to the server
if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");

// Send the request
bytes = write(sockfd, message, strlen(message));

// Receive the response
bytes = read(sockfd, response, 4096);

//close the socket

// View the response
", response);
return 0;


The C program shows how to create a socket to connect to ThingSpeak, lookup the IP address for ThingSpeak, connect the socket to ThingSpeak, send the GET request, receive the channel field data and close the socket. You can make this more complicated by checking the number of bytes read and reading more if the buffer was full but this is just a simple and direct way. Hope this helps.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:







Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565


Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee