Jump to content

helloworld1029

Members
  • Posts

    16
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

helloworld1029's Achievements

Member

Member (2/4)

1

Reputation

  1. Hi, I am using Pmod ESP32 and figure out the possibilities to receive data from Thingspeak. Based on my research, I found this link may help me to get Thingspeak data via using AT command. The link is here: https://allaboutfpga.com/remote-monitoring-and-control-of-home-appliances-from-cloud-using-edge-artix-7-fpga-board/ Remote Monitoring and control of Home appliances from cloud using EDGE Artix 7 FPGA board (allaboutfpga.com). This picture (picture is from the link above) tells me what AT command I should use for receiving data from Thingspeak Cloud. I used the above-mentioned AT comments like "AT+CIPSEND=69" and "GET /channels/xxxxxxx/fields/1.json?results=1" to do the job. But I can't get the result I want. I expect there will be +IPD, <num of bits>:data rather than "Send OK" and "Recv xx bytes". These are the code: #include "xil_cache.h" #include "xparameters.h" #include "stdio.h" #include "xparameters.h" #include "xuartps.h" #include "xtime_l.h" #include "xgpiops.h" extern "C"{ #include "PmodESP32.h" } /******************************************************************************/ /* */ /* Defines */ /* */ /******************************************************************************/ #define HOST_UART_DEVICE_ID XPAR_PS7_UART_1_DEVICE_ID #define HostUart XUartPs #define HostUart_Config XUartPs_Config #define HostUart_CfgInitialize XUartPs_CfgInitialize #define HostUart_LookupConfig XUartPs_LookupConfig #define HostUart_Recv XUartPs_Recv #define HostUartConfig_GetBaseAddr(CfgPtr) (CfgPtr->BaseAddress) #define PMODESP32_UART_BASEADDR XPAR_PMODESP32_0_AXI_LITE_UART_BASEADDR #define PMODESP32_GPIO_BASEADDR XPAR_PMODESP32_0_AXI_LITE_GPIO_BASEADDR #define COUNTS_PER_SECOND (XPAR_CPU_CORTEXA9_CORE_CLOCK_FREQ_HZ /2) #define TIMER_FREQ_HZ 100000000 #define MAX_WIDTH 320 #define MAX_HEIGHT 240 #define MAX_BUTTON 16 /******************************************************************************/ /* */ /* Function Declarations */ /* */ /******************************************************************************/ void EnableCaches(); void DisableCaches(); void startup(); void receiveData(XTime time); void setWifiMode(void); void connectWifi(void); void establishConnection(void); void cipsend(void); /******************************************************************************/ /* */ /* Variables */ /* */ /******************************************************************************/ HostUart myHostUart; XGpioPs_Config *ConfigPtr; XGpioPs output; XTime TimeStart; XTime TimeEnd; PmodESP32 ESP32; int countdown =60; char counter[20]; int main() { EnableCaches(); startup(); setWifiMode(); xil_printf("Init Started\n\r"); connectWifi(); xil_printf("Wifi Done\n\r"); // sleep(2); XTime_GetTime(&TimeStart); TimeEnd = TimeStart + ((XTime)COUNTS_PER_SECOND); establishConnection(); cipsend(); DisableCaches(); return 0; } void startup(){ //Init ESP32 HostUart_Config *CfgPtr; ESP32_Initialize(&ESP32, PMODESP32_UART_BASEADDR, PMODESP32_GPIO_BASEADDR); CfgPtr = HostUart_LookupConfig(HOST_UART_DEVICE_ID); HostUart_CfgInitialize(&myHostUart, CfgPtr, HostUartConfig_GetBaseAddr(CfgPtr)); } 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=\"SSID\",\"Password\"\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(void){ u8 command[150]; u8 finalcmd[50]; sprintf((char*)command, "GET https://api.thingspeak.com/channels/"ThingSpeak_Channel_Num"/fields/1.json?results=1" ); 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(10); } void EnableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheEnable(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheEnable(); #endif #endif } void DisableCaches() { #ifdef __MICROBLAZE__ #ifdef XPAR_MICROBLAZE_USE_ICACHE Xil_ICacheDisable(); #endif #ifdef XPAR_MICROBLAZE_USE_DCACHE Xil_DCacheDisable(); #endif #endif } Here is the result from Vitis Serial Terminal. No IPD response and Json Script included. AT+CWMODE=3 AT+CWMODE=3 OK Init Started 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 71 AT+CIPSEND=71 GET https://api.thingspeak.com/channels/xxxxxxx/fields/1.json?results=1TCPED7 Recv 71 bytes SEND OK CLOSED Meanwhile, I tried the AT command in the Arduino and ESP01S. I can receive the IPD command and Java Script like following: 19:19:52.989 -> AT+CWMODE=3 19:19:52.989 -> 19:19:52.989 -> OK 19:20:02.336 -> AT+CWJAP="ssid","password" 19:20:02.336 -> WIFI DISCONNECT 19:20:04.486 -> WIFI CONNECTED 19:20:05.468 -> WIFI GOT IP 19:20:07.338 -> 19:20:07.338 -> OK 19:20:16.096 -> AT+CIPSTART="TCP","184.106.153.149",80 19:20:16.331 -> CONNECT 19:20:16.331 -> 19:20:16.331 -> OK 19:20:23.943 -> AT+CIPSEND=69 19:20:23.943 -> 19:20:23.943 -> OK 19:20:23.943 -> > fields/1.json?results=1 19:20:39.376 -> busy s... 19:20:39.376 -> 19:20:39.376 -> Recv 69 bytes 19:20:39.611 -> 19:20:39.611 -> SEND OK 19:20:40.207 -> 19:20:40.207 -> +IPD,296:{"channel": {"id":xxxxxxx,"name":"xxxxxxx","latitude":"0.0","longitude":"0.0","field1":"led1","field2":"led2","field3":"led3", "created_at":"2021-04-30T00:36:29Z","updated_at":"2021-04-30T00:37:05Z","last_entry_id":18}, "feeds":[{"created_at":"2021-06-07T11:13:39Z","entry_id":18,"field1":"0"}]}CLOSED For updating data from Zybo board to Thingspeak, I can receive the IPD command like following: AT+CIPSTART="TCP","api.thingspeak.com",80 AT+CIPSTART="TCP","api.thingspeak.com",80 CONNECT OK Length 135 AT+CIPSEND=135 GET http://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxxxx &field1=0.64&field2=29.84&field3=488&field4=47.47&field5=139&field6=6.31 TCPED15 Recv 135 bytes SEND OK +IPD,3:420CLOSED Can anyone tell me how can allow Pmod ESP32 to receive the Java Script like how Arduino does. Thanks
  2. @dpaul thx for ur answer I have achieved to upload the data collected from pmod sensors to thingspeak. but i am just struggling with using pmod esp32 to retrieve data/ achieve iot control. i have achieved this with node mcu (made by esp32), now i want the pmod esp32 to do the same.
  3. @abalkonis Thanks for your question. I did not manually include anything. Most code are copied from other online sources and done by "trial and error". Also, I am using Vitis instead of SDK. Here is my define code #define HOST_UART_DEVICE_ID XPAR_PS7_UART_1_DEVICE_ID #define HostUart XUartPs #define HostUart_Config XUartPs_Config #define HostUart_CfgInitialize XUartPs_CfgInitialize #define HostUart_LookupConfig XUartPs_LookupConfig #define HostUart_Recv XUartPs_Recv #define HostUartConfig_GetBaseAddr(CfgPtr) (CfgPtr->BaseAddress) #define PMODESP32_UART_BASEADDR XPAR_PMODESP32_0_AXI_LITE_UART_BASEADDR #define PMODESP32_GPIO_BASEADDR XPAR_PMODESP32_0_AXI_LITE_GPIO_BASEADDR #define COUNTS_PER_SECOND (XPAR_CPU_CORTEXA9_CORE_CLOCK_FREQ_HZ /2) #define TIMER_FREQ_HZ 100000000 #define MAX_WIDTH 320 #define MAX_HEIGHT 240 #define MAX_BUTTON 16 To be more specific, please refer to the txt i have sent at first message. Thanks so much. Btw, are u going to send the data to Thingspeak?
  4. @abalkonis I did not draw a complicated connection in the block design. But sth must be careful is you have to connect the esp32 into 100Mhz. Regarding to the Vitis code, I looked for the AT command that allows me to send the data to thingspeak. (Ref Link: https://allaboutfpga.com/remote-monitoring-and-control-of-home-appliances-from-cloud-using-edge-artix-7-fpga-board/) Then, I used this link https://github.com/mitchellorsucci/ArtyS7PmodESP32 as a reference to recode. But I failed to receive the data from Thingspeak with Pmod ESP32. I am currently using the Zybo Z720, I don't know what board and what processor you use. Maybe the discrepancy between my board and your board results in the occurrence of your issue. I think this can help you. Anyway, the code above can help you to build connection between thingspeak to pmod esp32. Thanks
  5. Hello everyone, Is it possible for the Zybo z720 with Pmod ESP32 to achieve the smart home control system like Arduino? Something like this Thanks
  6. Previously I have asked this question in the forum, however, my explanation was not so clear and may result in confusion. Hence, I decided to rephrase my question in this new post. Currently, I have been researching on how to allow my Zybo z720 board to receive data from Thingspeak channel through using Pmod ESP32 and control the status of the LED according to the data of Thingspeak. I have already known how to send the data (collected from ALS, AQS and HYGRO) from the zybo board to Thingspeak by using the AT command. I will show the code below. 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=\"xxxxx\",\"xxxxxx"\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=xxxxxxxxxxxxx&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); } Beforehand, I have tried this project with the NodeMCU since I thought the code I used for NodeMCU should be similar to ESP32. It worked perfectly. As I changed the thingspeak data link and updated the data, I can see my LED light up or light off. However, while I analysed the NodeMCU code, it does not use AT command and it also does not have any relationship with the code I used for sending data to Thingspeak. So, do I need to use the same AT command, or I need to use something like Json parsing to accomplish that? I will show all my work I have done below. Thanks Cpp Code Update 1.txt Arduino IoT Control.txt
  7. Hi to everyone. I have successfully tried to use Pmod ESP32 to upload the other Pmod sensors data into the Thingspeak and used GPIO inside the zybo board to control the LED when some Pmod sensor value is too high or too low. Now, my supervisor asked me and my team to do IoT control. For example, an user pressed the button in the webpage or mobile app, the LED which connected to zybo board can turn on or turn off. My teammate now can send the 1 or 0 data to Thingspeak. Now, I want to use my Zybo baord to receive the Thingspeak data that my teammate has made. I have been searching some tutorials on the website but they all that Arduino based project. Here is the resource I found: And below are what I have tired to create. Here is the block diagram and Vitis code I have write Here are my questions For Zybo baord to achieve the IoT control, should I modify the code I have written, or modify the arduino code shown in the Youtube video above. And how can I integrate together? I think I need to change/modify this part of code (this code is to send the data to thingspeak) in order to allow the zybo to receive the data from thingspeak and achieve the IoT control. But I am not sure. 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=\"xxxxxxxxxxx\",\"xxxxxxxxxxxxxxx\"\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=CE8VFL1E8ZJNGZM8&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); } Thanks helloworld1029. Cpp Code Update 1.txt
  8. Hi to everyone here. I am constantly searching on connect two Pmods into one port. I have tried on "IOXP method" and "Daisy Chain Method", but I failed to achieve these two. After that, I found this post to tell me how to connect my two Pmods into one port. The link is here: I followed the post instruction carefully. And I successfully create the Vivado Block Design, as well as generate the bistream. I wrote my C code based on the demo code of Pmod AQS and Pmod ALS. Here is the block diagram and the xdc file After exporting to Vitis, I can successfully build my code. But the Vitis Serial Terminal said "Init Started" only, I think the new code failed to initialize two Pmods. I will place my code below. I also tried to place two different Pmod into two different ports, it works smoothly as the real data can be seen in the Vitis serial terminal. I wish anyone can help to troubleshoot my code and correct me if one of my step is wrongly done. Thanks in advance. Combine Test Code.txt
  9. @artvvb Thanks so much, I think I have managed to solve this issue, since I can see the real-time voltage value when I insert the measuring sensor into the solution.
  10. Thanks you and I will follow your guidance. I think I have used the AXI Interconnect interface for my block design. The block diagram can be seen from the question portion. With this diagram and code from other resources, I can make use of xadc to sense the die temperature and voltage monitor with in the Zybo Z720 board. I also set up the channel for vaux 14, which is connected to AD14/JA1/JA7 of the port in another block design. But i am not so sure if the external source really can connect to the FPGA. I will show you the new block design, Vitis C code, and result in Vitis serial terminal below. By the way, is it possible to use Pmod AD1 to read the analog data from my sensor. I was thinking of alternative way of doing, and then I came across this link, which tells me to use Zedboard to acquire data from DF Robot Sensor. But I not sure if it works for Zybo as well. I am thinking I can use this Pmod AD1 to get the voltage of the sensor, and then getting real data through setting up formula based on the sensor' technical specification. Vitis Code XADC with AXI Interconnect.txt
  11. @artvvb Thanks for your answer. I am sorry to say that I cannot use Cora Z7 for my project since Cora Z7 does not have enough port for me to add in more Pmod sensor. I think I also make a mistake that using AXI to control the analog input. I should instantiate the xadc first. Thus, I found another resource on how to read analog input in Zybo board. The link is here. https://cdn.instructables.com/ORIG/FRT/SYN1/IWMMH04D/FRTSYN1IWMMH04D.pdf For this pdf, I can successfully create a instantiation file through customizing the xadc wizard. The verilog code for Instantiation is placed at below. However, I don't quite understand how to manipulate the instantiation code with the wrapper. Also, I am confusing with the DCLK as well. The tutorial said "add a clock port as an 1 bit output from processor", but I cannot find the clock port in the vivado 2019.2. XADC instantiation.txt
  12. For my project, I was asked to use the xadc portion of the zybo board to read the data from the DFRobot Gravity Analog Electrical Conductivity (EC) Sensor. The link of the sensor is here: https://www.dfrobot.com/product-1123.html Just to give a summary on this product, it has the supply voltage of 3V to 5V and output voltage of 0V to 3.4V. I have asked this question before, maybe due to the unclarity of the question, nobody has answered me. The link is here: I have been trying to learn the basics of xadc and attempted some project. I created one project which allows me to read the data from ZYBO's internal temperature, voltage and the external analog input source (if that is correct) The block design, the code, the zipped vitis file and the outcome are below. Additionally, I have tried the sensor in my Arduino. The detail will be shown below as well. Here are some areas of concern. 1) I knew that for zybo xadc, it only supports the supple voltage up to 1V ONLY but my sensor output voltage can go up to 3.4V. I am worried if I straightly connect my analog input of the sensor into the zybo xadc output at port A. The Zybo Board may be damaged. So is there a way to minimise the output voltage so that the analog input can successfully insert into the zybo without damaging the board. I am thinking of using 2.2K ohm and 4.7K ohm resistor in series to solve the issue but I am not certain about that. 2) If the zybo can configure the DF Robot Gravity EC sensor smoothly through using resistors or other means, how can I ensure the result is accurate? Also, how should I transfer my code in Arduino into the Vitis Code. Do I need to change my Arduino code by a lot in order to allow the Vitis to understand. Thanks in advance helloworld1029 xadc_code (1).txt Electrical Conductivity Code For Arduino.txt workspace_sensor.zip
  13. @JColvinRegarding to two solutions, I would like to clarify somethings. First, for the first solution, if I only leave the AXI IIC inside the block design, how should I connect to port JC ( I tried in my way, u can see in the pic below). Also, where can I find the resource on how to write the C or Cpp code for the i2c communication between the AXI IIC , HYGRO and AQS? For second solution, I don't fully understand your explanation. If not wrong, you mean that I don't use the AXI IIC and use two Pmod IP Core instead. I am not sure that I connect one of the Pmod into connector JC, or I do not connect to any port in Vivado Block Design, and specifying the connection of port through write C code in Vitis IDE. I am just not so sure. And could you further explain this portion, I really don't quite understand that. "It'll then be much easier to adjust or copy over as appropriate the existing libraries/functions so that they both work on the I2C module that the Xilinx tools think is directly connected to the Pmod port. I'd probably do this by porting over the further downstream Pmod library functions into the libraries of the directly connected module, and then adjusting the main.c function as appropriate to talk to the different modules as the design requires." Here is the block designs I did based on my understanding of your comment. I connect the IIC of the AXI IIC to custom. And change the variable name in JC port. In addition, I have tired with the connection between one port and one Pmod and run my program in my ZYbo z720 with the help of demo code. Thanks helloworld1029
  14. Previously, in this forum, I knew that I can use daisy chain method to allow my PMOD HYGRO and PMOD AQS to be connected into the same port. I started with my new vivado block design. Since I don't have much knowledge about IIC parallel communication, when I transfer my block design file to Vitis IDE, it doesn't show the data from PMOD HYGRO. I want to know if any part of my block design and C code in the Vitis wrong. Also, can anyone tell me how the I2C parallel communication transfer works? Thanks
×
×
  • Create New...