09-09-2015 10:38 AM
Hello to all the users,
I'm new here. What I'm trying to achieve is to graph in real time data from two accelerometers connected to an arduino uno. The problem is that I am not receiving anything if I connect the sensors, but it works if I leave the analog inputs of my Uno floating. This is the code:
float Sensore1, Sensore2; // Variabili che contengono i campioni da inviare a LabVIEW void setup() { Serial.begin(115200); // Imposto il baudrate a 115200 while( !Serial.available() ) ; // Inizia il loop quando LabVIEW invia una lettera per avviare la lettura dei sensori } void loop() { //Dati da inviare a LabVIEW Sensore1 = (analogRead(A0) ) * 5.0 / 1024; // Dati rilevati dal primo sensore Sensore2 = (analogRead(A1) ) * 5.0 / 1024; // Dati rilevati dal secondo sensore Serial.print("a"); // Stringa appesa al valore del primo sensore per effettuare il riconoscimento da LabVIEW Serial.println(Sensore1); // Scrivi sul monitor seriale i campioni relativi al primo sensore delay(3); Serial.print("b"); // Stringa appesa al valore del secondo sensore per effettuare il riconoscimento da LabVIEW Serial.println(Sensore2); // Scrivi sul monitor seriale i campioni relativi al secondo sensore delay(3); }
09-09-2015 01:11 PM
If arduino is giving data when nothing is connected, then code is fine, look at connections.
"Not receiving anything" - does it mean com port communication fails or it is giving the same data as without sensors?
Does ADC work? check with 1.5 V battery.
Is it bipolar adc (can it measure both positive and negative voltage)?
09-10-2015 02:48 AM - edited 09-10-2015 02:49 AM
"not receiving anything" means that in LabVIEW I'm getting loads of zeros for both sensors, while if I check the serial monitor from the Arduino IDE I can see that it's correctly sending data.
The ADC can convert only positive values from 0 to +5 V, but I am not giving any negative voltage to it.
09-10-2015 05:05 AM
@Andrew92 wrote:
while if I check the serial monitor from the Arduino IDE I can see that it's correctly sending data.
Could you give us a screen shot or something to show what the stream looks like? My guess is that you need to format your data into a human readable string first.