lou yu in Discussions
최근 활동: 2021년 6월 14일

Hi, I am currently trying to use my FPGA to retrieve data from my Thingspeak LED status graph. Previously, I tried this with my Mode NCU. As I gave "1" to one of the fields in my LED status channel, my LED will light up. It was successfully done. Now, I want to try with FPGA (To be specific, it is Digilent's Zybo Z720 board). I have learnt that I need to use Pmod ESP32 to achieve this function. Previously, I used the AT commands to send my data from sensor to Thingspeak channel. Here is the code: void receiveData(XTime time){ XTime tEnd, tCur; u8 recv_buffer=0; u32 num_received=0; XTime_GetTime(&tCur); tEnd = tCur + (time * COUNTS_PER_SECOND); do { num_received = ESP32_Recv(&ESP32, &recv_buffer,1); if(num_received >0){ num_received = ESP32_Recv(&ESP32, &recv_buffer,1); xil_printf("%c", recv_buffer); } if(tCur == tCur + COUNTS_PER_SECOND){ countdown = countdown -1; } else XTime_GetTime(&tCur); } while (tCur < tEnd); } void setWifiMode(void){ u8 tx[]="AT+CWMODE=3\r\n"; u32 num = strlen((char *) tx); xil_printf((char *) tx); ESP32_SendBuffer(&ESP32, tx, num); usleep(100); receiveData(3); } void connectWifi(void){ u8 tx[] = "AT+CWJAP=\"________\",\"_____________\"\r\n"; u32 num = strlen((char *) tx); xil_printf((char *) tx); ESP32_SendBuffer(&ESP32, tx, num); usleep(100); receiveData(30); } void establishConnection(void){ u8 tx[] = "AT+CIPSTART=\"TCP\",\"api.thingspeak.com\",80\r\n"; u32 num = strlen((char *) tx); xil_printf((char *) tx); ESP32_SendBuffer(&ESP32, tx, num); receiveData(10); } void cipsend(float temp, u16 co2, u8 light, float humidity){ u8 command[150]; u8 finalcmd[50]; //field1 Ph field2 Temp field3 co2 field4 humidity field5 light sprintf((char*)command, "GET http://api.thingspeak.com/update?api_key=____________&field1=0&field2=%d.%02d&field3=%d&field4=%d.%02d&field5=%d\r\n" ,(int) temp_degc,((int) (temp_degc * 100)) % 100,co2,(int) hum_perrh,((int) (hum_perrh * 100)) % 100,light); u32 length = strlen((char*)command); sprintf((char*)finalcmd, "AT+CIPSEND=%d\r\n", (int)length); u32 cmdlength =strlen((char*)finalcmd); xil_printf("Length %d\r\n", length); xil_printf((char *)finalcmd); ESP32_SendBuffer(&ESP32, finalcmd, cmdlength); sleep(1); xil_printf((char *)command); ESP32_SendBuffer(&ESP32, command, length); receiveData(4); } Now, I am a bit confusing with the reverse part (receiving data from Thingspeak). Should I use the same AT command like AT+CIPSEND, or change the AT command. Or should I need to do something like Json Parsing. I appreciate your favourable response. Thanks Luke Read the data from Thingspeak and Achieve IoT Function. I'm not a big fan of the AT command set. Its really versatile, but fairly difficult to read. You can definitely use AT commands to read data from ThingSpeak, though you will have to modify the format a bit (see the <https://www.mathworks.com/help/thingspeak/readdata.html Read Data> API) but I think it would be much easier to speak over a serial connection to the ESP32, then have the ESP use the ThingSpeak library to process incoming commands from the FPGA. Sorry for late reply. I used the *AT+CIPSEND* and *GET https://api.thingspeak.com/channels/xxxxxxx/fields/1.json?api_key=xxxxxxx&results=2* to get the IPD response as followed: if true % code AT+CWJAP="ssid","password" AT+CWJAP="ssid","password" WIFI DISCONNECT WIFI CONNECTED WIFI GOT IP OK Wifi Done AT+CIPSTART="TCP","api.thingspeak.com",80 AT+CIPSTART="TCP","api.thingspeak.com",80 CONNECT OK Length 99 AT+CIPSEND=99 GET https://api.thingspeak.com/channels/xxxxxxx/fields/1.json?api_keyxxxxxxxxxxx&results=2 TCPED9 Recv 99 bytes SEND OK +IPD,265:{"channel": {"id":xxxxxx, "name":"xxxxx", "latitude":"0.0", "longitude":"0.0", "field1":"Field Label 1", "created_at":"2021-06-09T02:13:29Z", "updated_at":"2021-06-09T02:13:29Z", "last_entry_id":1}, "feeds": [{"created_at":"2021-06-10T01:54:48Z", "entry_id":1,"field1":"1"}]} CLOSED end Now, I want to Json Parse the IPD response in C, and I don't know how to achieve it. btw, i know how to parse the normal java script Thanks There are a whole bunch of JSON libraries for C at <https://www.json.org/json-en.html json.org> at the bottom. On my devices, I generally use <https://arduinojson.org/ arduinoJson> since I write in the Arduino IDE a lot. Hi, Mr Christopher. Now, I change my GET<link> function so that I can receive the data in the +IPD format (after setting AT+CIPSEND) and do not need to worry about Json Parsing. You can see my serial terminal below. I wonder how to extract the data from the +IPD response so that I can use the latest entry data to control the relay with Xilinx Vitis. I don't know if you have touched on Xilinx Vitis or FPGA things cuz i am using Xilinx Vitis software to do this task. I also found some tutorial about achieving this task with Arduino but doesn't help for my project. If you know how to do IoT control in xilinx system, that will be great! Thanks in advance. <</matlabcentral/discussions/uploaded_files/5390/data>> fpga
Vertical Farm in MATLAB Answers
최근 활동: 2020년 11월 27일

As the title says Im trying to upload data with HTTP GET method and I followed the api documentation properly This is a snipper of my code where the data is being sent as well as the output I receive IMG It works when in browser but not when I do it through my board

ThingSpeak 정보

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.