Use the built-in light sensor to detect the quality of street lights.
AVR-IoT Cellular Mini
Battery
Clear can
SoftwareArduino
AdafruitIO
Buildstep.1 Set up Adafruit IO
Because my purpose is to detect brightness, it need to upload a brightness value.
When monitoring, it also need to know the location of the street lights, so it need to set up a separate feed for the coordinates.
Adafruit IO's Location feed not only has coordinates, but also numerical values, so using Adafruit IO actually only requires one feed.
step.2 Arduino Coding
MQTT pub/sub functional testing
Before receive AVR-IoT Cellular Mini.
I pretest MQTT function by using WIFI board MKR1000. Test with example "adafruitio_04_location". After adding a CA, I can connect normally and upload location data. Try using the example adafruitio_location_MQTT to upload general data and location to test successfully.
https://cdn-learn.adafruit.com/downloads/pdf/adafruit-io-basics-gps.pdf
It is recommended to use other WIFI boards to test the MQTT function first to save the cellular data usage.
After AVR-IoT Cellular Mini board arrive.
I found AVR-IoT Cellular Mini's MQTT example different with Adafruit. That I need rewrite the code. Reference with Adafruit webpage, location MQTT can use a simpler format when sending it to CSV
For example
momososo/feeds/street-light-monitor.location/csv
22.587,38.1123,-91.2325,112
The order is value "22.587" latitude: 38.1123, longitude: -91.2325, elevation: 112.
sensor reading test
Using the example "AVR-IoT VEML3328" -> "color", you can easily get the color and brightness values. Note that, it cannot correspond to lumens or candlelight, it is enough for the application.
Timer test / Power consumption test / Power saving test
Using the power down example, you can test at the same time. You need to complete the MQTT connection first.
Below is my measured current consumpt.
66~68uA with USB same with battery.
up to 30mA when wake-up.
250uA if connect UART before shutdown.
It takes about 5 seconds to power off after reading the sensor value.
If setting wake up once an hour, measure and upload.
Average power consumption = (3600 * 68 + 30000 * 5) / 3605 = 109.5 uA
With a 1500mAh battery, it can use
1500*1000/109.5 = 13698.6 hours
13698.6 /24 = 570.775 days, about 1.5 year.
This is just an estimate. Actual battery power may be insufficient based on my experience.
=== update ===
I found that sometimes uploading data takes more time, depending on the LTE-M network status. This means shorter battery life. If desired, you can modify the hourly measurement to two hours, or even five hours.
UART location settings
In order to save the cost of the GPS module, the location data is sent to the AVR-IoT Cellular Mini via UART when setting up the system and then stored in the EEPROM (AVR128DB48 or 25CSM04).
Use the Arduino serialevent example to modify it to polling mode.
// send "lat:123.456" for setting
if (inputString.startsWith("lat:"))
{
String sub_S = inputString.substring(4, inputString.length()); // from 4 to end
// SerialCDC.println(sub_S);
lat1 = sub_S.toDouble();
EEPROM.put(EEaddrlat, lat1);
}
// send "lon:123.456" for setting
if (inputString.startsWith("lon:"))
{
String sub_S = inputString.substring(4, inputString.length()); // from 4 to end
// SerialCDC.println(sub_S);
lon1 = sub_S.toDouble();
EEPROM.put(EEaddrlon, lon1);
}
// send "ele:1.00" for setting
if (inputString.startsWith("ele:"))
{
String sub_S = inputString.substring(4, inputString.length()); // from 4 to end
// SerialCDC.println(sub_S);
ele = sub_S.toDouble();
EEPROM.put(EEaddrele, ele);
}
// send "exit!" to exit
if (inputString.startsWith("exit!"))
{
SerialCDC.println(F("exit!"));
powerup_f = 0;
}
Use UART tools to transmit address information. Currently, the program needs to transmit it in three times.
"lat:123.456"
"lon:123.456"
"ele:0.0"
Need to send "exit!" to leave the setting
press SW100 when power on to enter UART location setting.
step.3 Combine various functions
Combine the above functions.
Set to wake up once every hour, measure the light sensor value and upload it, then go to sleep.
serial port out as below.
10:42:24.094 -> Device ID: 28
10:42:24.233 -> 99
10:42:25.534 -> [INFO] Connecting to operator.......... OK!
10:42:30.613 -> [INFO] Connected to operator Far EasTone
10:42:30.613 -> [INFO] Connecting to MQTT broker. OK!
10:42:39.376 -> [INFO] Published Success
10:42:39.376 -> [INFO] Powering down...
10:42:40.928 ->
11:42:48.114 -> [INFO] wake up!
11:42:48.160 -> Device ID: 28
11:42:48.299 -> 110
11:42:48.347 -> [INFO] Connecting to MQTT broker......... OK!
11:42:53.543 -> [INFO] Published Success
11:42:53.543 -> [INFO] Powering down...
11:42:53.976 ->
12:43:01.152 -> [INFO] wake up!
12:43:01.199 -> Device ID: 28
12:43:01.370 -> 93
12:43:01.370 -> [INFO] Connecting to MQTT broker. OK!
12:43:02.470 -> [INFO] Published Success
12:43:02.525 -> [INFO] Powering down...
12:43:03.025 ->
The Adafruit IO web data
The cellular data usage.
Actual installation results
Find an empty, clear can, secure the AVR-IoT Cellular Mini and battery, and close the lid.
Put the can near street light. Please make sure you have permission to place it.
Full picture of the scene.
Now, it start collect data. Hope no one moves it.
============================After five days, the following information was collected.
From the manual interpretation of the collected values, when the street lights work normally at midnight, the values are around 130~140, even on rainy days or new moons.
In this case, it is reliable to judge street lights with values below 100 as failures. I can write a simple judgment program and check it every day.
Please refer to attachment state_check for_upload.py
or
use the Adafruit IO Actions
Locate
Currently, the project still requires manual input of coordinate positions. AVR-IoT Cellular Mini uses LTE-M, which can calculate the device position through surrounding base stations.
I tried to use triangulation to locate, but I need to have the location data of the cell station first. I found a database called OpenCelliD, but the information in the database for my location was out of date, I could only get one cell station's location.
Battery voltagemonitoring
Although this device is very power efficient, monitoring the battery voltage is a useful feature.
Backup Lighting
Backup lighting can temporarily provide light when a streetlight failure is detected. Can be switched by local or cloud. However, due to the device's low power capabilities and cost concerns, this will be an optional feature.
Temperature monitoring
There is also a temperature sensor on the AVR-IoT Cellular Mini. Adding temperature data will not take up too much traffic. But it is not necessary for this project.
I have completed temperature reading and uploading in another project, and also found that the temperature will be affected by the cellular module.
ConclusionIn this project, I demonstrate reading the street light brightness value and uploading it from the AVR-IoT Cellular Mini to adafruit IO. Then the python program reads the previous day's value and makes a judgment. If you have research on python, you can even use machine learning to achieve more accurate judgments.
Although I only have one AVR-IoT Cellular Mini board, as long as government build it using the same method, I believe that after mass production, it can monitor the brightness of street lights in the entire city.
Make roads more comfortable and safer at night.
Comments