I have an eeg kit and a built in visualizer code was present, so we used it. We have an esp-wroom-32 and have to upload a code though arduino IDE. What we want to do is to take all the data points which the python code is receiving and depending on the value to control a function(ex: High amplitude: LED On).
The issue is that we arent able to get the data points to arduino IDE. Could you recommned some ways of communication between the IDE and Python code.
Also they use the same port for communication
#include <synapse.h>
// #include "../synapse.h"
const int sensorPin = A0; // Analog input pin
unsigned long previousMillis = 0; // Variable to store the last time a sample was taken
unsigned long interval = 4; // Interval between samples in milliseconds (1000 ms / 250 samples). Change as per requirement
synapse exg_synapse;
void setup(){
Serial.begin(115200);
}
void loop(){
unsigned long currentMillis = millis(); // Get the current time in milliseconds
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; // Save the current time as the last time a sample was taken
float sensorValue = analogRead(sensorPin); // Read the sensor value
float filters_out = exg_synapse.apply_EEG_filters(sensorValue); // generate output after applying filters
Serial.println(filters_out);
}
}
Only one application can have the serial port open at a time. So you can either send the data from the Arduino to the serial monitor / plotter or to your python visualiser. Same for uploads; the serial monitor / plotter are under control of the IDE and the port will be closed before the upload, you will have to that yourself for the visualiser.
Extremeley sorry for being unclear.
The ESP32 is required to transmit the data from the electrodes to the laptop as it has an ADC converter(as stated on the website)
The eeg kit has electrodes and is connected to an EXG synapse, this synapse is connected to the esp32.
The IDE is used to upload a code onto the ESP32 to properly read the values.
I dont exactly require a serial monitor/plotter, I just need it to do some basic functions based on the values. Something like: Read serial monitor If val>30 digitalWrite(LED,HIGH);
Thanks for this great idea, I dont know how i never realised I could do it(probably cause I am still a beginner who is still learning lots of stuff)
Btw shd I use micropython and should i be using Thonny IDE for this project? If yes, it would be extremely helpful if you could provide alternate platforms, as previously there were a couple of issues with the Thonny IDE.
Thanks in advance
Circuit:
I think this is the confusion. The IDE is the program where you write your code on the computer. It can't analyze any data or write to any pins. It just compiles code that gets loaded onto your Arduino. All the signal processing has to happen on the Arduino in the code that is running there.
I now see that the Arduino code is intended only to read the ADC and print data on the serial port, which is usually connected to the Arduino IDE serial monitor, or to a Bluetooth module that could be connected to anything.
The "visualizer" is a separate package intended for the PC, which reads that serial data stream.
You could add functions to the ESP32 Arduino code to monitor ADC values and set ESP32 digital outputs, or do anything else you like, like displaying data on a TFT screen connected to the ESP32.