Firmware configuration
Overview
The Configuracion.h file centralizes all configurable parameters for the CICERONE AirLink
firmware. This allows you to customize the device behavior without modifying the core source code.
All configuration options are defined using preprocessor directives (#define).
File Location
The configuration file is located at: firmware/Configuracion.h
Configuration Parameters
Device Identification
ID_USUARIO
Defines a unique identifier for this device. This ID is included in all data transmissions to identify the source device on the server.
Default value:
Usage:
- Change this value to assign a unique name to each device in your deployment
- Use alphanumeric characters and underscores
- Keep it short but descriptive (e.g., "AIRLINK_ROOM_301", "AIRLINK_LAB_A")
Example:
NB-IoT Module Control
HABILITAR_NBIOT
Enables or disables the NB-IoT communication module. When disabled, the device will still collect sensor data but will not transmit it to the server.
Default value:
Options:
1- Enable NB-IoT transmission (default)0- Disable NB-IoT transmission
Usage:
- Set to
1when you want to enable remote telemonitoring - Set to
0for testing, development, or standalone data logging without connectivity - Disabling NB-IoT saves power and reduces operational costs
Example (disabled):
Power Saving
Disabling NB-IoT can significantly extend battery life if you only need local data logging via the serial monitor.
Server Configuration
These parameters define where the device sends its data via HTTP POST requests.
SERVIDOR_IP
The server's IP address or domain name where data will be transmitted.
Default value:
Usage:
- Replace with your actual server URL or IP address
- Include the protocol prefix (
http://orhttps://) - Do not include trailing slashes
Examples:
#define SERVIDOR_IP "http://192.168.1.100"
#define SERVIDOR_IP "http://iot.mycompany.com"
#define SERVIDOR_IP "https://api.airquality.example.org"
SERVIDOR_PUERTO
The server port number for the HTTP connection.
Default value:
Usage:
- Must be provided as a string (enclosed in quotes)
- Common values:
"80"(HTTP),"443"(HTTPS), or custom ports - Coordinate with your server administrator
Examples:
#define SERVIDOR_PUERTO "80" // Standard HTTP port
#define SERVIDOR_PUERTO "443" // Standard HTTPS port
#define SERVIDOR_PUERTO "8080" // Alternative HTTP port
SERVIDOR_API
The API endpoint path on the server that receives the data.
Default value:
Usage:
- Define the relative path to your API endpoint
- Always start with a forward slash (
/) - Must match the endpoint configured on your server
Examples:
#define SERVIDOR_API "/api/v1/airquality"
#define SERVIDOR_API "/data/sensors"
#define SERVIDOR_API "/receive"
Complete Server URL
The device constructs the full URL by combining these parameters:
SERVIDOR_IP:SERVIDOR_PUERTO/SERVIDOR_API
For example: http://iot.mycompany.com:64340/aqindoor
Network Provider Configuration
APN_NBIOT
Access Point Name (APN) for the mobile network operator's data service.
Default value:
Usage:
- Contact your IoT SIM card provider for the correct APN
- Some providers work without an APN (use empty string
"") - This is crucial for establishing data connectivity
Common APN Examples:
| Provider | APN Value |
|---|---|
| 1NCE | "iot.1nce.net" |
| ThingMobile | "TM" |
| Vodafone IoT | "nb.iотgprs" |
| No APN required | "" |
Example configurations:
#define APN_NBIOT "iot.1nce.net" // 1NCE
#define APN_NBIOT "TM" // ThingMobile
#define APN_NBIOT "" // No APN required
Important
Using an incorrect APN will prevent the device from connecting to the internet. Always verify with your SIM card provider.
Configuration Workflow
Step-by-Step Guide
- Open the configuration file
Navigate to firmware/Configuracion.h in your code editor
- Set device identification
Assign a unique ID_USUARIO for each device
- Configure server details
Enter your server's IP address, port, and API endpoint
- Set network APN
Enter the APN provided by your IoT SIM card operator
- Enable/disable NB-IoT
Set HABILITAR_NBIOT based on your requirements
- Compile and upload
Build and flash the firmware to your device using Arduino CLI
Example Configuration
Here's a complete example configuration for a typical deployment:
#ifndef CONFIGURACION_H
#define CONFIGURACION_H
// Device identification
#define ID_USUARIO "AIRLINK_HOSPITAL_ROOM_305"
// Enable NB-IoT transmission
#define HABILITAR_NBIOT 1
// Server configuration
#define SERVIDOR_IP "http://iot.hospital.org"
#define SERVIDOR_PUERTO "443"
#define SERVIDOR_API "/api/v2/airquality/data"
// Network provider APN
#define APN_NBIOT "iot.1nce.net"
#endif // CONFIGURACION_H
Compilation Notes
Preprocessor Directives
All configuration options use #define preprocessor directives. Changes take effect at compile
time, so you must recompile and upload the firmware after modifying Configuracion.h.
Conditional Compilation
The HABILITAR_NBIOT flag uses conditional compilation. When set to 0, all NB-IoT related code
is excluded from the compiled binary, resulting in:
- Smaller program size
- Reduced memory usage
- Lower power consumption
- Faster startup time
This is implemented throughout the codebase using preprocessor conditionals:
Troubleshooting
Connection Issues
If the device cannot connect to the server:
- Verify APN: Ensure
APN_NBIOTmatches your provider's specification - Check server URL: Confirm
SERVIDOR_IPis reachable from the internet - Validate port: Ensure
SERVIDOR_PUERTOis not blocked by firewalls - Test API endpoint: Verify
SERVIDOR_APIaccepts POST requests
Debug Mode
For detailed troubleshooting information, enable debug output in Debug.h:
#define DEBUG_LEVEL 3 // Set to 3 for verbose output
#define DEBUG_NBIOT 3 // Enable NB-IoT debug messages
Monitor the serial output (115200 baud) to see connection attempts and error messages.
Related Documentation
- Debug Configuration - Configure debug output levels
- API Reference - Complete firmware documentation
- Hardware Assembly - Physical device setup
See Also
Debug.h- Configure debug output and testing modesDatetime_helper.h- Timezone and time synchronization settings- Firmware API Documentation - Complete code reference with Doxygen