The current process of sewer line cleaning is reactive rather than proactive. Phone calls are registered in an event of clogged sewer line in an area. Moreover, it is difficult for manual scavengers to zero-in on the point of error. They use hit-and-trial method to carry out the cleaning process in multiple manholes in the affected area, wasting a lot of time. Additionally the high concentration of the toxic gases lead to irritability, headaches, fatigue, sinus infections, bronchitis, pneumonia, loss of appetite, poor memory and dizziness.
The solution is to design a prototype, which is a small device - with a form-factor of a pen - embedded onto the lid of a manhole. The lower section of the device which is exposed to the inside of the manhole while the lid is closed - comprises of sensors which detect the level of water inside the sewer and the concentration of gases which include methane, carbon monoxide, carbon dioxide and nitrogen oxides. The data is gathered to a master station, which communicates with these devices installed at each manholes over LoRaWAN, and sends the data to a cloud server, which hosts a dashboard for monitoring purposes. Further, this bridges the gap between municipal authorities responsible for the sewer maintenance and garbage collection. Installation of these devices throughout the city will allow a preventive solution to identify and pinpoint the location of clogged sewer line before the wastewater reaches the surface.
1. Ultrasonic sensor - HC-SR04
2. Gas sensor - MQ-4
3. LoRa gateway - Raspberry pi 3
4. LoRa module - Semtech SX1272
6. Buzzer module
7. 500mAh, 3.7V Li-ion battery
For the first prototype, I used a tic-tac (box of fresh mints) as the enclosure. The attachment of ultrasonic sensors was done in such a way so as to point the Tx and Rx towards the sewerage flow. Connections to the ultrasonic sensor and the gas sensor are very easy. Just need to power the individual sensors and use any of the 8 digital pins available in the NodeMCU for reading data. I have drawn the connections for better understanding.
Step 2: Getting Acquainted With SEMTECH SX1272
Our next step would be to install the libraries on our NodeMCU.
You can find the libraries to the Semtech LoRa module in this link :https://github.com/lupyuen/LoRaArduino
To install this library:
- Install it using the Arduino Library manager ("Sketch" -> "Include Library" -> "Manage Libraries..."), or
- Download a zipfile from github using the "Download ZIP" button and install it using the IDE ("Sketch" -> "Include Library" -> "Add .ZIP Library..."
- Clone this git repository into your sketchbook/libraries folder.
To make this library work, your Arduino (or whatever Arduino-compatible board you are using) should be connected to the transceiver. The exact connections are a bit dependent on the transceiver board and Arduino used, so this section tries to explain what each connection is for and in what cases it is (not) required.
Note that the SX1272 module runs at 3.3V and likely does not like 5V on its pins (though the datasheet is not say anything about this, and my transceiver did not obviously break after accidentally using 5V I/O for a few hours). To be safe, make sure to use a level shifter, or an Arduino running at 3.3V. The Semtech evaluation board has 100 ohm resistors in series with all data lines that might prevent damage, but I would not count on that.
The SX127x transceivers need a supply voltage between 1.8V and 3.9V. Using a 3.3V supply is typical. Some modules have a single power pin (like the HopeRF modules, labeled 3.3V) but others expose multiple power pins for different parts (like the Semtech evaluation board that has VDD_RF, VDD_ANA and VDD_FEM), which can all be connected together. Any GND pins need to be connected to the Arduino GND pin(s).
The primary way of communicating with the transceiver is through SPI (Serial Peripheral Interface). This uses four pins: MOSI, MISO, SCK and SS. The former three need to be directly connected: so MOSI to MOSI, MISO to MISO, SCK to SCK. Where these pins are located on your Arduino varies, see for example the "Connections" section of the Arduino SPI documentation. The SS (slave select) connection is a bit more flexible. On the SPI slave side (the transceiver), this must be connect to the pin (typically) labeled NSS. On the SPI master (Arduino) side, this pin can connect to any I/O pin. Most Arduinos also have a pin labeled "SS", but this is only relevant when the Arduino works as an SPI slave, which is not the case here. Whatever pin you pick, you need to tell the library what pin you used through the pin mapping (see below).
The DIO (digitial I/O) pins on the transceiver board can be configured for various functions. The LMIC library uses them to get instant status information from the transceiver. For example, when a LoRa transmission starts, the DIO0 pin is configured as a TxDone output. When the transmission is complete, the DIO0 pin is made high by the transceiver, which can be detected by the LMIC library. The LMIC library needs only access to DIO0, DIO1 and DIO2, the other DIOx pins can be left disconnected. On the Arduino side, they can connect to any I/O pin, since the current implementation does not use interrupts or other special hardware features (though this might be added in the feature, see also the "Timing" section).
In LoRa mode the DIO pins are used as follows:
- DIO0: TxDone and RxDone
- DIO1: RxTimeoutIn
FSK mode they are used as follows::
- DIO0: PayloadReady and PacketSent
- DIO2: TimeOut
Both modes need only 2 pins, but the tranceiver does not allow mapping them in such a way that all needed interrupts map to the same 2 pins. So, if both LoRa and FSK modes are used, all three pins must be connected. The pins used on the Arduino side should be configured in the pin mapping in your sketch (see below). Reset The transceiver has a reset pin that can be used to explicitely reset it. The LMIC library uses this to ensure the chip is in a consistent state at startup. In practice, this pin can be left disconnected, since the transceiver will already be in a sane state on power-on, but connecting it might prevent problems in some cases. On the Arduino side, any I/O pin can be used. The pin number used must be configured in the pin mapping (see below).
The transceiver contains two separate antenna connections: One for RX and one for TX. A typical transceiver board contains an antenna switch chip, that allows switching a single antenna between these RX and TX connections. Such a antenna switcher can typically be told what position it should be through an input pin, often labeled RXTX. The easiest way to control the antenna switch is to use the RXTX pin on the SX127x transceiver. This pin is automatically set high during TX and low during RX. For example, the HopeRF boards seem to have this connection in place, so they do not expose any RXTX pins and the pin can be marked as unused in the pin mapping. Some boards do expose the antenna switcher pin, and sometimes also the SX127x RXTX pin. For example, the SX1272 evaluation board calls the former FEM_CTX and the latter RXTX. Again, simply connecting these together with a jumper wire is the easiest solution. Alternatively, or if the SX127x RXTX pin is not available, LMIC can be configured to control the antenna switch. Connect the antenna switch control pin (e.g. FEM_CTX on the Semtech evaluation board) to any I/O pin on the Arduino side, and configure the pin used in the pin map (see below). It is not entirely clear why would not want the transceiver to control the antenna directly, though.
Step 3: 3D Printing an Enclosure
Once I had everything up and running, I decided to 3D print a case for the module for a better looking design.
With the final product in hand, Installation in the man-hole and obtaining real-time results on a dashboard was easy. The real-time gas concentration values with the water-level indication allowed authorities for a proactive approach along with a safer way to address the problem.