# Flash Flood Early Warning System in Colima, Mexico
## 2 Materials and Methods
### Sensor and Processing Considerations  
The ultrasonic water level sensors ToughSonic Remote 14, 30, and 50 are used to measure the distance between the water surface and the sensor location. The data generated are then processed within the microcontroller and encapsulated in a JSON (\"JavaScript Object Notation is a lightweight data exchange format\") structure, along with an identification string. These data are then transmitted to the server through the 3G cellular network and stored into the NoSQL (\"No Structured Query Language\") database to carry out future calculations that can later be used for flood forecasting. Several versions of this sensor are available, each of which possess different ranges and communication interfaces. Three different models were considered (ToughSonic Remote 14, 30, and 50), each with a different range, although all of them communicate through the RS-485 standard. The RiverCore processor board does not support this standard. Consequently, a Max 485 transceiver was employed to handle the communication between the microcontroller and the sensor. Before connecting to RiverCore, each sensor needs to be configured employing the manufacturer's software, ASCII (\"American Standard Code for Information Interchange\") streaming, with a 57,600 baud rate, which is the default configuration the fixed node accepts for this sensor. Some calculations to determine the distance between the ToughSonic sensor and the water occur in RiverCore (fixed node). The water depth is then calculated at the EWIN server with the characteristics of each site. Each sensor and site are treated differently since the formula varies between Remote 14, 30, and 50, and every physical site has its characteristics and topographic data. Along with the ultrasonic water level sensor, every fixed node also incorporates a soil moisture sensor. The TEROS 10 is an analogue sensor, which makes its integration into the network simpler. Figure 6: RiverCore hardware modules. However, an analogue sensor may also report some inconsistent values because analogue signals suffer from greater interference and other physical factors like the wiring length. The TEROS 10 reports an output of 1000 to 2500 mv, which the microcontroller translates into voltage accordingly to its 12-bit resolution. These data are then transmitted, as is, and the server transforms the data into usable information regarding soil conditions. The information from the humidity sensor is used to calibrate the hydrological model, since the soil has an antecedent humidity before a heavy precipitation episode. If the soil moisture is low, it has a greater capacity to absorb water volume and the opposite is true if the soil has a high moisture content. In this last scenario, it is easier to generate runoff. Therefore, the humidity sensor data are used to calibrate the hydrological model to know the response of the basin and to use these variables in the forecast model. There are two types of fixed nodes on the EWIN network: RiverCore and weather stations. The weather station node retrieves the weather information from the ATMOS 41 weather station which packages 12 weather sensors. It features a 3-wire interface following the SDI-12 protocol for communicating sensor measurements. The weather station measures 12 weather variables including air temperature, relative humidity, vapor pressure, barometric pressure, wind speed, wind gusts and direction, solar radiation, precipitation, lightning strikes, and lightning distance. The data are backed up internally by the weather station node and sent to the server unmodified to be stored and displayed. The RiverCore main processing board is based on the AT91 SAM3x8E, which can communicate with different protocols; this allows it to be compatible with different sensors and devices, with optimum efficiency. The compatible communication protocols are listed below:  
* I2C;
* SDI-12;
* SPI;
* RS-232/RS-485;
* USB;
* Analogue input.