ESP NOW provided sensor datas to ESP32 and Matlab serial communication

30 views (last 30 days)
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;

Accepted Answer

Christopher Stapels
Christopher Stapels on 31 Oct 2022
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.

More Answers (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 on 29 Oct 2022
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 Comment
Nagy
Nagy on 29 Oct 2022
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.

Sign in to comment.

Communities

More Answers in the  ThingSpeak Community

Community Treasure Hunt

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

Start Hunting!