ESP NOW provided sensor datas to ESP32 and Matlab serial communication

25 次查看(过去 30 天)
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;

采纳的回答

Christopher Stapels
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.

更多回答(2 个)

Manjunatha Vankadari Gopalakrishna
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

Christopher Stapels
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.
  1 个评论
Nagy
Nagy 2022-10-29
On the same device ESP NOW communication and WiFi connection doesnt work, now im trying to bridge this problem with an external ESP32 which communicates with that ESP32 via serial, and then it sends the values to a webserver or something, then maybe i could reach them with my PC. I tried also ThingSpeak with a test code, but the channel updated only by every 15 or 20 seconds. Maybe its a limit for average users and only vip users can reach higher refresh rate? I have only a university student license for matlab.

请先登录,再进行评论。

社区

更多回答在  ThingSpeak Community

类别

Help CenterFile Exchange 中查找有关 WiFi 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by