- Mon Jul 23, 2018 10:36 pm
#199800
Hi, I am working on a project where I would like to read multiple TFMini sensors using an Arduino Uno. I am trying to accomplish this by using multiple software serial objects in my code like so:
What might be causing this error?
It doesn't happen when I run my patch with only one mini. It seems that doing the software serial transaction with one TFMini then with another would logically work fine, since it's just switching back and forth between two pairs of digital pins sending a message and doing a read, but perhaps there's something in the TFMini library that works differently than this. Thanks!
Code: Select all
And using SoftwareSerial.listen() to switch between the two in my main loop like so:
#include <TFMini.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
SoftwareSerial mySerial2(12, 13);
TFMini tfmini;
TFMini tfmini2;
Code: Select all
I've notice this method works at first but both TFMini's have a tendency to get stuck in a hung state where they return the same value forever until power they're power cycled. This pretty much happens every time I run my patch within a few minutes of starting it. mySerial.listen();
uint16_t dist = tfmini.getDistance();
//do some LED stuff with the value
delay(10);
mySerial2.listen();
uint16_t dist = tfmini2.getDistance();
//do stuff some other LED with the other value
delay(10);
What might be causing this error?
It doesn't happen when I run my patch with only one mini. It seems that doing the software serial transaction with one TFMini then with another would logically work fine, since it's just switching back and forth between two pairs of digital pins sending a message and doing a read, but perhaps there's something in the TFMini library that works differently than this. Thanks!