Show Posts
|
|
Pages: [1] 2 3 ... 26
|
|
1
|
Using Arduino / Sensors / Re: How to measure new snow amount
|
on: December 30, 2012, 06:52:00 pm
|
|
Hello from Antarctica,
One of my experiments here is to measure the snow thickness. I am not so interestingv on accuracy, but just only to have an idea about the range.
I (and a lot of people around the world) use an array of temperature sensors at different elevations (eg., 2.5, 5, 10, 20, 40, 80, and 160 cm above the surface). The idea is the sensors register variable temperatures depending of the weather. When snowfall occurs and cover the lower sensor, the temperature it register is stable comprared with the temperature registered by the sensor located above it. And the same with the snowfall continue covereing the next sensors.
The resolution of this method depends of the distance between the sensors in the array. It is a low cost and low maintenance requirements method. If you are interested i can provide you some papers describing the method.
Cheers.
BTW, Happy New Year! madepablo
|
|
|
|
|
3
|
International / Software / Re: contador de eventos externos (timer/counter)
|
on: June 25, 2012, 12:20:32 am
|
|
Pues si, parece que hay varios... el caso es que los pins 2, 3, 18 y 19 tienen esta funcionalidad, así como el 20 y el 21, aunque estos también son los pins para la comunicación (pins SDA, SCL). Pero bueno, también tienen la funcionalidad de acuerdo con el esquema que nos acabas de pasar.
Así que parece confirmado
|
|
|
|
|
4
|
International / Software / Re: contador de eventos externos (timer/counter)
|
on: June 21, 2012, 02:22:48 pm
|
Mirando en la web de Arduino, en la descripción de la placa mega dice esto: External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details. Copiado de aquí: http://arduino.cc/en/Main/ArduinoBoardMega¿alguien con una de esta placas mega puede confirmar que es cierto que todos estos pins funcionan como interruptores?
|
|
|
|
|
5
|
International / Software / Re: Arduino BASIC o PASCAL
|
on: June 21, 2012, 02:18:39 pm
|
Hola Caligulaarduino, Bueno, yo n puedo contestarte directamente a tu pregunta, porque no se si se puede hacer lo que dices. Sólo comentarte que te resulte "pesado" programar para Arduino. En realidad es C, pero se parece mucho a Pascal. Yo de chavalillo programaba en BASIC y luego me pasé al PASCAL. Ahora estoy programando una pliacación para PC que permite comunicarse con mi arduino. El caso es que tienen muchos comandos y estructuras muy parecidas, tanto que como estaba modificando el sketch a medida que iba creando la aplicación en PASCAL, confundía uno lenguaje con otro... pero a lo mejor son percepciones mías que no soy un experto en nada... Pero en cualquier caso, te voy una pista, aunque no se si es la solución. En el programa Lazarus (PASCAL), un programador visual open source, tiene componentes que permiten visualizar distintos tipos de lenguaje.. entre ellos C. Nunca los he probado, así que no se si sólo visualiza o si te permite compilar a partir de él algo que puedas luego volcar en la plaza arduino. Pero bueno, ahí tienes una pista para ir investigando. Esto es Lazarus: http://www.lazarus.freepascal.org/Suerte!
|
|
|
|
|
6
|
International / Español / Re: interrupción puerto serie
|
on: June 14, 2012, 05:29:45 am
|
|
@Jorgepl,
Gracias!. La verdad es que vi ese ejemplo hace ya tiempo, pero ahora que lo necesitaba ni me acordaba de él... Muchísimas gracias! Lo he probado y me funciona, así que voy a ver si puedo ir adaptando mi código para que cuadre en ese esquema lógico...
Muchas gracias!
|
|
|
|
|
7
|
International / Español / Re: interrupción puerto serie
|
on: June 13, 2012, 10:11:32 am
|
Yo estoy metido en un asunto parecido, pero complicado por el hecho de que el arduino está durmiendo. Se despierta una vez cada hora para tomar datos con distintos sensores y grabarlo en una SD antes de volver a dormirse. Estoy desarrollando un programa en pascal (Lazarus) que permite ponectarse con el arduino (via puerto serie o bluetooth), para pedirle que mida en ese momento, configurar la hora de un RTC o volcar los datos de su tarjeta SD. En funcionamiento normal no hay problema, pero durmiendo es otra cosa... y encima usando el mismo interruptor para las alarmar y el puerto serie... Esta es la duda que he planteado en el foro en inglés... http://arduino.cc/forum/index.php/topic,109723.0.htmlPero exploraré también la opción de usar milis para el tiempo de espera desde que recibe la interrupción hasta que decide qué tarea hacer. Gracias por las ideas chicos!
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: Question about sleeping and loop
|
on: June 13, 2012, 09:31:32 am
|
Ok. Thanks PeterH, I will try somethig like this (in pseudo-code): Libraries, constants and variables go here
setup configure everything
Loop{ sleep() }
sleep(){ active interrupt go to sleep here is sleeping until to receive an alarm or to receive data from the serial port get up() stop the interrupt Listen the serial port() }
get up(){ do nothing }
listen the serial port(){ for (int i=o; int<5000; i++){ (about 5 seconds?) c = Serial.read(); } if chart starts by "M": do measurements from all sensors and show it in the serial port if chart starts by "T": adjust the RTC time and date If chart starts by "D": dump file stored in the SD card and send it by the serial port in any other case, measure from all sensor, show result in the serial port, and save the data into an SD card. }
Then, i must send a byte by the serial port to wake arduino up, and then i have 5 seconds to send the command to request to arduino do develop a specific task. If in that time does not receive news (bytes) from the serial port then, comes to measure and sleep again... I will try and report here the results. Thanks again!
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Re: Question about sleeping and loop
|
on: June 13, 2012, 02:34:16 am
|
okay, i made it simpler... I have this pseu-docode: Libraries, constants and variables go here
setup configure everything
Loop{ sleep() }
sleep(){ active interrupt go to sleep here is sleeping until to receive an alarm or to receive data from the serial port get up() stop the interrupt tasks() }
get up(){ copy what receives from serial to a char variable }
tasks(){ if chart starts by "M": do measurements from all sensors and show it in the serial port if chart starts by "T": adjust the RTC time and date If chart starts by "D": dump file stored in the SD card and send it by the serial port in any other case, measure from all sensor, show result in the serial port, and save the data into an SD card. }
Here goes the other processes to do M, T and D tasks
So, the question is if this configuration (where the processes that read what arrive through the serial port and to decide what task must be done are located) is correct.
|
|
|
|
|
10
|
Using Arduino / Programming Questions / Question about sleeping and loop
|
on: June 12, 2012, 01:27:25 pm
|
Hi folks, I have a head pain due to something that i try to solve. Let me explain the case. I have my arduino sleeping. It gets up thanks to the alarm from a RTC. Then, it measure by different sensors, save the data into a SD card, and come back to sleep again. It works perfect. Now, I also want to control my devide sending commands by the serial port (in fact by a bluetooth). So, i connected the Rx pin to the Int0 (the same where is connected the alarm, because i use the other one to do other things. The problem is that i am doing something wrong because in all cases i send a command, it made the default task, like if didn´t read anything by the serial port, and just only receiving the interrupt... I changed the position of the routine what reads the serial port and decide what task to develop... but i didn´t see where is the problem. Did you see where is the problem? or what i am doing wrong? [code] // Here goes all the call to libraries, constant and variables. I removed in order to save space in this forum
void setup(){ // Inicializacion RTC RTC.start(); // Configuración de la alarma RTC.enable_interrupt(); RTC.setSeconds(55); RTC.setMinutes(59); RTC.setAlarmRepeat(EVERY_HOUR); RTC.writeAlarm(); pinMode(alarma, INPUT); // Receptor de alarmas digitalWrite(alarma, HIGH); // Configuración de pins pinMode(power, OUTPUT); // Alimentacion de sensores // Inicializacion del puerto serie Serial.begin(115200); // Inicia comunicaciones // Comprobación de la tarjeta SD pinMode(10, OUTPUT); // Configuración de la librería SD if (!SD.begin(chipSelect)) { Serial.println("WProblemas con la tarjeta de memoria SD"); } else { Serial.println("WTarjeta de memoria SD preparada"); } }
void loop(){ // Fin de la medición, Inicio del letargo Dormir(); }
// Función tras despertar void Despertar(){ c = Serial.read() ; }
// Realizar las mediciones de los sensores void Mediciones(){ // Inicialización de sensores sensors.begin(); // Inicia el sensor de temperatura DS18B20 sensors2.begin(); // Alimentación de sensores digitalWrite(power, HIGH); delay(5000); // Inicio de la medición de parámetros ambientales tiempo(); // Toma la hora delay(20); readVcc(); // Lee el voltaje interior delay(20); midebateria(); // Mide el voltaje de entrada delay(20); readTemp(); // Mide la temperatura interna delay(20); midegotas(); // Mide la intensidad de lluvia (disdrómetro) delay(20); temperatura(); // Mide la temperatura exterior (DS18B20) delay(20); sueloH(); // Mide la humedad del suelo delay(20); suelotemp(); // Mide la temperatura del suelo delay (20); temphumroc(); // Lee temperatura y humedad (SH15) y calcula el punto de rocío delay (20); luminosidad(); // Mide la luminosidad (LDR) delay (20); radiacion(); // Mide la radiación luminosa, irradiancia (TSL235R) delay(20); velocidadviento(); // Mide la velocidad del viento (QRD1114) // Grabación de los resultados grabar(); // Graba los datos en formato ascii en un soporte microSD delay(5000); contador = contador + 1; // Actualiza el contador de medidas digitalWrite(power, LOW); delay(500); }
// Configuración del estado de letargo void Dormir(){ attachInterrupt(0, Despertar, FALLING); set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); RTC.enable_interrupt(); sleep_mode(); // -->FASE DE LETARGO DEL DISPOSITIVO<-- sleep_disable(); RTC.disable_interrupt(); detachInterrupt(0); Leermensaje(); }
// Procesar mensaje del puerto serie void Leermensaje() { if(Serial.available() >= 0 ){ //char c = Serial.read() ; if ( c == 'T' ) { setuptime(); } else if ( c == 'D'){ DescargaDatos();; } else { Mediciones(); } } }
// Actualizar la hora del RTC a través del puerto serie void setuptime(){ int pctime = 0; for(int i=0; i < TIME_MSG_LEN -1; i++){ char c = Serial.read(); if( c >= '0' && c <= '9'){ pctime = (10 * pctime) + (c - '0') ; // convert digits to a number } } RTC.writeTime(pctime); // Sync clock to the time received on serial port Serial.print('T'); Serial.print(pctime); delay(1000); }
// Volcado de datos en el puerto serie void DescargaDatos(){ Serial.println("WTarjeta SD inicializada"); File dataFile = SD.open("datos.csv"); //Serial.println(dataFile.size()); if (dataFile) { Serial.println("WIniciando la descarga de datos"); while (dataFile.position() < dataFile.size()) { Serial.write(dataFile.read()); } dataFile.close(); Serial.println("@"); delay(1000); Serial.println("WDescarga completa"); } else { Serial.println("WError al abrir datos.csv"); } }
// Lee el Reloj de Tiempo Real (DS1337) void tiempo(){ // Lee el RTC RTC.readTime(); // Memoriza la fecha actual day = RTC.getDays(); month = RTC.getMonths(); year = RTC.getYears(); //Memoriza la hora actual hora = RTC.getHours(); minuto = RTC.getMinutes(); segundo = RTC.getSeconds(); return; }
// Lee el voltaje de entrada float midebateria(){ batt = (analogRead(bateria))*volt; return batt; }
//Lee el voltaje interno long readVcc() { long readVcc=0; ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); delay(2); ADCSRA |= _BV(ADSC); while (bit_is_set(ADCSRA,ADSC)); readVcc = ADCL; readVcc |= ADCH<<8; innerVcc = 1126400L / readVcc; // Back-calculate AVcc in mV innerVcc = innerVcc / 1000; return innerVcc; }
// Obtiene la temperatura interna de dispositivo Arduino long readTemp() { long readTemp=0; ADMUX = _BV(REFS1) | _BV(REFS0) | _BV(MUX3); delay(20); ADCSRA |= _BV(ADSC); while (bit_is_set(ADCSRA,ADSC)); readTemp = ADCL; readTemp |= ADCH<<8; innertemp = (readTemp - 125) * 1075; // temp in x10^-4 degC innertemp = innertemp / 10000; // temp in degC return innertemp; }
// Mide la temperatura y humedad ambiental y calcula el punto de rocío void temphumroc(){ SH15.measure(&ambtemp, &humedad, &TRocio); }
// Lee la irradiancia (TSL235R) void radiacion(){ volatile long pulsos = 0; for (int i=0; i <= 10; i++){ FreqCounter::f_comp = 10; FreqCounter::start(periodo1); while (FreqCounter::f_ready == 0) pulsos=FreqCounter::f_freq; delay(20); } irrad = (pulsos*1000)/(periodo1*area1*1000); return; }
// Lee la temperatura superficial (DS18B20) float temperatura() { sensors.requestTemperatures(); tempext=sensors.getTempCByIndex(0); return tempext; }
// Mide la humedad del suelo int sueloH(){ suelohum=analogRead(suelo); // Read the sensor suelohum=(suelohum*0.1904761905); // Calculate soil moisture from the lecture*100/525 return suelohum; }
// Mide la temperatura del suelo (DS18B20) void suelotemp() { sensors2.requestTemperatures(); TSAr=sensors2.getTempCByIndex(0); TSAb=sensors2.getTempCByIndex(1); return; }
// Mide la luminosidad (LDR) unsigned int luminosidad(){ float photocellReading0 = analogRead(luz); // Read the analogue pin float Vout0=photocellReading0*0.0048828125; // calculate the voltage lux=500/(10*((5-Vout0)/Vout0)); // calculate the Lux return lux; }
// Mide la intensidad de lluvia (disdrómetro) unsigned long midegotas() { volatile unsigned long gotas=0; unsigned long millis(); long startTime = millis(); // mide el numero de gotas en 30 segundos while(millis() < startTime + 30000) { int sensorReading = analogRead(lluvia); if (sensorReading >= sensibilidad) { gotas=gotas+1; } } intensidad = ((gotas / area2) / 30); // calcula la intensidad de la lluvia en gotas/m2/sec }
// Mide la velocidad del viento void velocidadviento(){ BWCounter = 0; attachInterrupt(1, addcount, CHANGE); unsigned long millis(); long startTime = millis(); while(millis() < startTime + periodo2) { } detachInterrupt(1); unsigned int RPM=((BWCounter/2)*60)/(periodo2/1000); // Calculate revolutions per minute (RPM) velviento = ((pi * diametro * RPM)/60) / 1000; // Calculate wind speed on m/s }
// Contaje de pulsos anemómetro void addcount(){ BWCounter++; }
// Graba los datos en formato ASCII en una memoria flash SD void grabar(){ // It works... i removed to save space in the forum // Muestra los datos en el puerto serie Serial.print(message); return; } Excuse to paste here all the code, but in this way you have all the information and not only the partial one... Thanks![/code]
|
|
|
|
|
11
|
Using Arduino / Sensors / Re: Wind Sensor
|
on: June 01, 2012, 09:50:28 am
|
Hi Sirus, Ok, here is the code what i wrote for read data from my home-made anemometer based on an IR-sensor. It count the number of pulses in a period of 10 seconds, and calculate the wind velocity taking into account the anemometer characteristics... It use interrupts in the digital pin number 3 (INT1). May be it could be useful to you. Enjoy it! /* QRD1114 IR Sensor on an cups anemometer * Authors: M.A. de Pablo & C. de Pablo S., 2010 * version: 1.1 20110714 * Wind speed information: http://en.wikipedia.org/wiki/Beaufort_scale */ // Pin definitions //# define IR 3 // Receive the data from sensor # define led 13 // Light a led
// Constants definitions const float pi = 3.14159265; // pi number int period = 10000; // Measurement period (miliseconds) int delaytime = 10000; // Time between samples (miliseconds) int radio = 65; // Radio from vertical anemometer axis to a cup center (mm) char* winds[] = {"Calm", "Light air", "Light breeze", "Gentle breeze", "Moderate breeze", "Fresh breeze", "Strong breeze", "Moderate gale", "Fresh gale", "Strong gale", "Storm", "Violent storm", "Hurricane"};
// Variable definitions unsigned int Sample = 0; // Sample number unsigned int counter = 0; // B/W counter for sensor unsigned int RPM = 0; // Revolutions per minute float speedwind = 0; // Wind speed (m/s) unsigned short windforce = 0; // Beaufort Wind Force Scale
void setup() { // Set the pins pinMode(led, OUTPUT); digitalWrite(led, LOW); // sets the serial port to 115200 Serial.begin(115200); // Splash screen Serial.println("ANEMOMETER"); Serial.println("**********"); Serial.println("Based on QRD1114 IR sensor"); Serial.print("Sampling period: "); Serial.print(period/1000); Serial.print(" seconds every "); Serial.print(delaytime/1000); Serial.println(" seconds."); Serial.println("** You could modify those values on code **"); Serial.println(); }
void loop() { Sample++; Serial.print(Sample); Serial.print(": Start measurement..."); windvelocity(); Serial.println(" finished."); Serial.print("Counter: "); Serial.print(counter); Serial.print("; RPM: "); RPMcalc(); Serial.print(RPM); Serial.print("; Wind speed: "); WindSpeed(); Serial.print(speedwind); Serial.print(" [m/s] (+/- 0.07 m/s); Wind force (Beaufort Scale): "); Serial.print(windforce); Serial.print(" - "); Serial.println(winds[windforce]); Serial.println(); delay(10000); }
// Measure wind speed void windvelocity(){ speedwind = 0; counter = 0; digitalWrite(led, HIGH); attachInterrupt(1, addcount, CHANGE); unsigned long millis(); long startTime = millis(); while(millis() < startTime + period) { } digitalWrite(led, LOW); detachInterrupt(1); }
void RPMcalc(){ RPM=((counter/2)*60)/(period/1000); // Calculate revolutions per minute (RPM) }
void WindSpeed(){ speedwind = ((2 * pi * radio * RPM)/60) / 1000; // Calculate wind speed on m/s if (speedwind <= 0.3){ // Calculate Wind force depending of wind velocity windforce = 0; // Calm } else if (speedwind <= 1.5){ windforce = 1; // Light air } else if (speedwind <= 3.4){ windforce = 2; // Light breeze } else if (speedwind <= 5.4){ windforce = 3; // Gentle breeze } else if (speedwind <= 7.9){ windforce = 4; // Moderate breeze } else if (speedwind <= 10.7){ windforce = 5; // Fresh breeze } else if (speedwind <= 13.8){ windforce = 6; // Strong breeze } else if (speedwind <= 17.1){ windforce = 7; // High wind, Moderate gale, Near gale } else if (speedwind <= 20.7){ windforce = 8; // Gale, Fresh gale } else if (speedwind <= 24.4){ windforce = 9; // Strong gale } else if (speedwind <= 28.4){ windforce = 10; // Storm, Whole gale } else if (speedwind <= 32.6){ windforce = 11; // Violent storm } else { windforce = 12; // Hurricane (from this point, apply the Fujita Scale) } }
void addcount(){ counter++; }
Note 1: the function what is more interesting to you is "windvelocity" Note 2: here you have more info and pictures about my anemometer: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1282599142
|
|
|
|
|
12
|
Using Arduino / Sensors / Re: Wind Sensor
|
on: May 31, 2012, 08:58:18 am
|
Hi Sirus, Some time ago i made a wind gauge (based on a QRD1114 IR sensor) and i read the interrupts by the use of INT1 and interrupts http://arduino.cc/es/Reference/Interrupts http://arduino.cc/es/Reference/AttachInterruptBut what i think it is also important to think about the measurement frequency... Depends of your sensor (you do not say what type it is) may be 1Hz is so high... in my case, to have a mean value, i have a frequency of 1 data per minute... (although i recognize that it could be so low). I do not have here my code. I will post here later. May be it could help you in some way. Cheers,
|
|
|
|
|
15
|
Using Arduino / Networking, Protocols, and Devices / How to... wake up an arduino by Bluetooth? [SOLVED]
|
on: May 28, 2012, 07:56:22 am
|
|
Hi folks,
I have an arduino what remains sleeping for one hour. Then, a RTC wakes it up in order to capture data with different sensors, save the data into an SD card, and go to sleep again. When i want to download the data, i take the SD card and that is. But now I would like to connect a bluetooth module in order to read and download the data wirelessly. Then my question is: is it possible to wake up my sleeping arduino by the bluetooth?. I tried sending a character in order to see if it was enought to wake it up... but it doesn´t work...
Could you give me any idea about it? Thanks!
|
|
|
|
|