Arduino Boards are very versatile and easy to program. The board I programing is Libelium, Libelium is a company specializing in sensor networks. The company also providing boards has a wide range of accessories, in this case I work with gas sensors.
I made a file of modular programming in which with few configuration strings I can enable or disable features.
The development in question allows the variables collected from the sensors and setting them in a string compatible with csv format and sends by radio frequency up to 12 km and writ to a local text file (MicroSD card) to ensure not lose any data.
void setup() { PWR.ifHibernate(); key_access_in_EEPROM(); configurar_xbee868(); RTC.ON(); activar_sensores(); SD.ON();
[...]
crear_fichero(); } void loop() { Utils.blinkLEDs(3000); if( intFlag & HIB_INT ) { hibInterrupt(); } PWR.hibernate("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2); }
[...]
void generar_paquete_motas() { [...]
//generación de todas las variables[...] sprintf(aux2," MOTA2: %s, -mac: %s%s, -bat: %d, -temp: %s,
-ozone: %s, -polution: %s \n", RTC.getTime(),
macHigh, macLow, PWR.getBatteryLevel(), tabla,tabla2, tabla3); data=aux2; enviar_paquete(); }
[...]
void hibInterrupt()
{
generar_paquete_motas();
escribir_linea_fichero();
Utils.blinkLEDs(1000);
Utils.blinkLEDs(1000);
intFlag &= ~(HIB_INT);
}
As seen, the Loop and Setup functions only call functions that can run or not, based on the configuration you need.
This gives us great versatility and ease way of configuration.