ESP NOW provided sensor datas to ESP32 and Matlab serial communication
조회 수: 25 (최근 30일)
이전 댓글 표시
Nagy
2022년 10월 27일
답변: Manjunatha Vankadari Gopalakrishna
2022년 11월 3일
Hello,
I have a project in which im gathering RSSI values with different technologies, like UWB, 433 MHz radio signals and also ESP NOW protocol RSSI values. All my gathered datas are sent to an ESP32 via ESP NOW protocol and i'd like to send these datas towards my PC via serial communication, or anyting that could work. I tried to read the serial port many different ways and always the same error appears. I dont get any error messages, the datas simply dont arrive at the port, or the Matlab cant read them. The interesting part is, that sometimes a few data arreives at the port and i can read them, but this is a very rare event. In addition, my Matlab code works fine with simple Serial.print arduino codes without ESP NOW parts, the problem only appears if there is an ESP NOW receiving part in my code. I dont really know what the problem could be, but it seems to me like a data conversion issue, but dont know. I hope someone has already faced an issue like this and could help me solve this. If someone knows a solution in which there isnt any ESP NOW sending part and serial communication, just a ThingSpeak or a Webserver solution to send float datas, that could help me a lot too.
Here is my Matlab code:
clear all;
if ~isempty(instrfind)
fclose(instrfind);
delete(instrfind);
end
delete(instrfind({'Port'},{'COM3'}));
esp = serialport('COM3',9600,'DataBits',8,'StopBits',1,'Parity','none');
fopen(esp);
disp(esp);
% 30 másodperces várakozási idő beállítva, ennyi időt vár a kód 2 adat
% beérkezés között mielőtt hibát okoz.
esp.Timeout=30;
values=zeros();
% folyamatos futást tesz lehetővé, az i nullázása csak tesztelés
% valamiért minden 151. beérkezett érték helyére NaN-t ír
for i=1:80
a=esp.readline;
% hogyha nem akar működni így sem, akkor meg kell próbálni stringé
% alakítani az elküldendő adatokat az arduino IDE-ben, ha úgy sem, akkor
% byte-ba vagy bitbe
values(i,1)=str2double(a);
disp(values(i,1));
end
csvwrite('testfle.csv',values);
i=0;
댓글 수: 0
채택된 답변
Christopher Stapels
2022년 10월 31일
You can only update every 15 seconds with a free license, but you can use the bulk update endpoint to get a higher density of points. Here is some sample code for the bulk update. The allotments for the camput wide license with respect to ThingSpeak are described here.
Here is a bridge solution for ESP now and WiFi.
추가 답변 (2개)
Manjunatha Vankadari Gopalakrishna
2022년 11월 3일
Hi,
With the latest version of MATLAB, you can use the arduino command to connect to ESP32 boards.
Please refer to the following links, this will help you in your workflow,
https://in.mathworks.com/help/supportpkg/arduinoio/ug/configure-setup-for-esp32-hardware.html
https://in.mathworks.com/help/supportpkg/arduinoio/ug/connect-to-arduino-hardware.html
Thanks,
Manjunatha
댓글 수: 0
Christopher Stapels
2022년 10월 29일
Are you able to run a WiFi client at the same time as the ESP NOW? You could connect to a WiFi network to send the values to ThingSpeak and then switch back to the NOW communication.
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
참고 항목
카테고리
Help Center 및 File Exchange에서 WiFi에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!