I'm new to arduino and have been studying as much literature and tutorials as I can so bear with me...
What I'm doing is a datalogger that records to SD. (stand alone battery powered so in no way connected to a pc) This much is relatively easy.
My problems are in the following.
- I need to be able to connect via Bluetooth to laptop for retrieving the data back from the SD card. Is this possible?
- I would like to power up the data logger without it starting to record data right away but instead record data after a sensor starts sending a signal. Eg. The logger should power up when ignition is turned on but not record until the engine has started (RPM signal) This way I think, the logger would have power and be able to connect to Bluetooth for data retrieval.. (without being interrupted by trying to record data.
- I have a question using the map function. I have one sensor (gear position sensor) that has 7 different voltage readings (ALL FROM ONE SENSOR(1st through 6th gear plus neutral) How can I write the code to log the gear number instead of the voltage. I have used map to control other variables such as val = map(val,0,1024,0,100). but how do I do it for 7 different, but specific voltage, readings?
Once I have these problems sorted I'm sure there will be more,
Thanks for looking and helping! This site is awesome!
Multiple voltage readings can be done like this:
Note the use of a chain of else if () statements.
Thanks for the reply but that doesn't solve the issue. Perhaps I need to be more specific. I have a sensor which picks up gears in a transmission and spits out a specific voltage for each gear. eg. 0.6v = 1st gear, 1.0V = 2nd gear 1.5v = 3rd gear etc So I need to know how to write that in programming. Would it be something like if reading is equal to 0.6 then write 1 else if reading is 1.0 write 2 etc? does that make sense?
Also very unclear about Bluetooth. (I don't even use it in the car) once the Bluetooth is connected to the pc (from arduino) what would the code be like to read from sd card on arduino? I have no clue and cant find anything about this type of data transfer.
Thanks again to all
I have news for you. Datalogging from Arduino via bluetooth is easier and even safer than fiddle-arsing about with the blue tooth in the car.
I can't comment on the details of aquisition, but be assured that everything you outline is achievable. You already have all the threashold voltage stuff and now all you need is reading the SD card, which is much the same as writing to it.
Here is some stuff on communication that might be useful. It was written for Android but it was developed on PC and the principle is the same.
Thanks for the reply but that doesn’t solve the issue. Perhaps I need to be more specific. I have a sensor which picks up gears in a transmission and spits out a specific voltage for each gear. eg. 0.6v = 1st gear, 1.0V = 2nd gear 1.5v = 3rd gear etc So I need to know how to write that in programming. Would it be something like if reading is equal to 0.6 then write 1 else if reading is 1.0 write 2 etc? does that make sense?
Let’s start over because the answer is in the link, I will point it out in a minute. First, as an example, if I were to program for first gear simply, like:
val = analogRead(pinNum); // read the input pin
If ( val == 0.6 ) serial.print ("1st gear!") ;
You will find that the program will not work, or will work most erratically because 0.6Volts is an absolute and the world is not perfect! What if you received 0.598 Volts? Or, 0.602 Volts? What you must do is bracket each value with a range.
The next problem is scaling of the voltage in the uC. You wrote:
I have one sensor (gear position sensor) that has 7 different voltage readings (ALL FROM ONE SENSOR(1st through 6th gear plus neutral) < … >
eg. 0.6v = 1st gear, 1.0V = 2nd gear 1.5v = 3rd gear etc
The incremental voltages are not linear. So you must check each range. ASSUMING that the 6th gear puts out 4.75V, you could write (pseudo-code):
If ( val > 0.4 && val < 0.8 ) serial.print ("1st gear!") ;
If ( val >= 0.8 && val < 1.3 ) serial.print ("2nd gear!") ;
If ( val > = 1.3 && val < 1.7 ) serial.print ("3rd gear!") ;
If ( val >= 4.5 && val < 5.0 ) serial.print ("6th gear!") ;
BUT the ADC in the uC DOES NOT indicate voltage but an increment from 0 to 1023 which represents a proportional voltage. This is the number that you really should be using in your compares - or, use a factor you create to multiply the ADC reading by to relate to voltage and check as shown above. There are numerous tutorials on how to work with and scale ADC.
thank you both very very much!!
Again this site...and those on it...are AWESOME!
I'm really starting to like arduino and the things we can do!