I'm hoping to build a system that logs brain wave and GPS data to an Openlog and ideally also shows some of the output on an SPI OLED display.
The brain wave set-up is as detailed here: How to Hack Toy EEGs | Frontier Nerds
A mindflex toy with wires soldered onto ground and TX points on its circuitboard and then connected to the arduino (I'm using a nano 328) via ground and the RX pin (removed during programming).
The brain library that parses the raw data coming out of the toy is available in 2 versions: hardware serial (for the set-up described above) and also a software serial version (which I've been unable to get to work - error messages relating to the library when I try and compile the example).
I can get the hardware serial version of the library working and parsing the data to a csv style output on the serial monitor. But I'm struggling to combine this in a sketch with the GPS module.
Here's a slightly abridged version of the code:
#include <SoftwareSerial.h> //includes the software serial library
#include <TinyGPS.h> // includes the TinyGPS library
#include <Brain.h>
TinyGPS gps;
SoftwareSerial gpsmodule(3, 4);
Brain brain(Serial);
//define GPS variables
float flat, flon; // +/- latitude/longitude in degrees
unsigned long date, time, age; // what they say on the tin
long lat, lon; // +/- lat/long in 100000ths of a degree
void setup()
{
Serial.begin(9600); // serial communication between the microcontroller and the computer
gpsmodule.begin(4800); // serial communication between the gps module and the microcontroller
} //end setup
void loop()
{
getGPS(); // get some data to work with
// prints GPS coordinates to serial monitor
Serial.print(flon, 6);Serial.print(","); Serial.print(flat, 6); Serial.print(",");
if (brain.update()) {
Serial.println("brain updated");
//Serial.println(brain.readErrors());
Serial.println(brain.readCSV());
}
} //end loop.
void getGPS(){
gpsmodule.listen();
// TinyGPS code here
} //end getGPS
This will give me the GPS coordinates as expected, but none of the brain data or the Serial.println("brain updated");
Why might that part of the code not be executing?
I know that if I'm using two software serial instances I need to put [i]name[/i].listen();
before I start working with each data stream, is there something similar I need to do before if (brain.update()) {
in order to switch which one the arduino is listening to?
Thanks