The company I work for is in one of the buildings in a park. Usually, I drive an electric car to work. Sometimes when the electric car runs out of power, it needs to be charged in the park. However, the charging area is open air, which means that whenever it rains, I need to go downstairs to the charging area in time to collect the charger, otherwise dangerous accidents may occur. But every time I couldn't predict the rain in advance, and even when it started to drizzle, it was still not enough time to rush over. In order to effectively solve the above problems, I decided to predict the time of rain by detecting Lightning. Since rain is usually accompanied by dark clouds, we can predict rain by detecting the electric field in the dark clouds. In this paper, I decided to use Grove Lightning Sensor(AS3935) to complete my project
2.Hardware2.1 Grove Lightning Sensor (AS3935)
The Grove Lightning Sensor is a highly sensitive sensor that detects electric fields free in air and using an internal proprietary algorithm determines if it is caused by the front end of a storm with lightning events. It is very easy to be used as a plug and play device using the Grove standard cable can accept several adjustments to be optimized for the application environment, both indoor or outdoor.
The use is for preventive alert on incoming lightning front of a storm so to avoid injuries to electrical equipment or human and for weather research because can furnish several data on the strength and number of events. This sensor can be fully integrated with other sensors in a forecast weather station and be very useful in agriculture for crop protection in case of incoming storms. Can detect the lightning front of a storm up to 30 – 40 km distance, when is still out of sight.
Next, we will use the AS3935 sensor module, and then deploy the AS3935 module to the cloud by accessing the DataLogger.
2.2 Sensor Builder && SenseCAP Data Logger
SenseCAP S2110 Sensor Builder is an open-source tool to build RS485 sensors with 500+ Grove sensors. It also enables developers to build a custom industrial-grade LoRaWAN sensor connecting to SenseCAP Cloud with SenseCAP Data Logger.
It has Seeed Studio XIAO RP2040 as the dual-core ARM Cortex M0+ processor, and has one Grove and one RS485 connector, enabling developers to connect with 500+ Grove sensors and various MODBUS RS485 sensors to develop custom industrial-grade MODBUS RS485 sensors for various IoT applications.
For the LoRaWAN application, developers could easily connect it with a SenseCAP LoRaWAN Data Logger to transfer the data to SenseCAP Cloud, which only takes a 5-minute simple BLE configuration in SenseCAP Mate App. Clear data results and further analysis could be easily obtained from SenseCAP Dashboard and SenseCAP Mate App. IoT platforms such as Helium, TTN, LORIOT, etc. are also supported.
3.Test the AS3935 with ArduinoNow we use Arduino to program XIAO to communicate with AS3935 and read the data. We can find the Arduino code from the official Wiki of Seeed Studio:https://wiki.seeedstudio.com/grove-lightning-sensor-as3935/
Download the program to XIAO, then we can test it with an electric spark generator, like a lighter defibrillator as below:
Then we open the serial port monitor of Arduino IDE to check the output. We can see that when the AS3935 does not detect lightning, it will always listen, and every time it detects lightning, it will output the detected data, such as whether lightning is detected and the estimated distance of lightning occurrence:
At this point, we have completed the test of the AS3935 sensor. Next, we will try to connect the AS3935 sensor to the SenseCAP Data Logger, so that it can be viewed in the cloud APP accordingly.
4.Connect to DataloggerThe next step is to establish a connection between the Sensor Builder and the SenseCAP Data Logger, enabling visualization of AS3935 on the cloud APP. First, we need to download the official sample code of Sensor Builder into the board, open the IDE of Arduino, connect the Sensor Builder, and select Seeed XIAO RP2040 as the development board. At the last step, we will burn the code into the board.
Open the serial monitor and we see the following output, we will see the following output, Lightning class sensor has two outputs, the address is 52 and 54, address 52 corresponding parameter is the cumulative number of detected lightning, address 54 corresponding to the address 54 is the estimated distance to the lastest lightning.
At the same time, we connect the SenseCAP Data Logger to the SenseCAP Cloud through the SenseCAP Mate App according to the tutorial. For the specific tutorial:https://wiki.seeedstudio.com/Build-LoRaWAN-Sensors-SenseCAP-XIAO-Controller-Data-Logger/
Because we need to read two pieces of data: the cumulative Number of lightning detected and the distance of the last lightning detected, so we need to fill the Measurement Number as 2 here, and then fill the Measurement Settings.
After clicking Measurement Setting, we can see Measurement1 and Measurement2, such as the two Register addresses obtained in the previous part of our test, where we fill in 52 and 54 respectively. For other parameters, we can refer to the following figure:
Go back to General and click Measure, and now it will display the sensor value.
Above, we have completed the basic use of AS3935 Sensor, and programmed Sensor Builder on Arduino to read AS3935. Then, the Sensor Builder and SenseCAP Data Logger are connected to SenseCAP Cloud for cloud data visualization. Through the cloud, we can remotely view the status of the sensor to determine whether lightning is detected and the distance from which lightning occurs.
At present, everything seems to be normal, but in fact, there are some problems when this module is combined with the Data Logger. For example, the duration of lightning occurrence is not long, and the duration of sensor measurement in the SenseCAP Data Logger is also short. Therefore, if the Sensor Builder is not provided with continuous power to keep it in the state of continuous detection, it is very likely that the lightning occurrence point will be missed when the Data Logger reads data, thus failing to detect lightning. In this way, the practicality of the AS3935 sensor will be greatly affected. Therefore, I suggest that if AS3935 is to be connected to the SenseCAP Data Logger for use, it is best to provide additional power to the Sensor Builder, which can greatly improve the probability of the sensor detecting lightning.
In addition, We can modify the relevant code in SensorLightning.hpp to determine whether the Data Logger reads the accumulated number of detected lightning (0~count) or whether it detects lightning (0/1). We can use count or L_struck to pass the parameters we want to obtain. As the following shown:
Comments