amc:ss2023:group-b:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
amc:ss2023:group-b:start [2023/07/20 14:42] – matsvei.yankouski | amc:ss2023:group-b:start [2023/07/24 21:23] (current) – stas.besliu | ||
---|---|---|---|
Line 16: | Line 16: | ||
(Specifications could be found here: [[https:// | (Specifications could be found here: [[https:// | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.1:** ESP32-CAM| | ||
The ESP32-CAM module is a versatile and compact development board that combines an ESP32 microcontroller with a camera module. It offers a wide range of functionalities, | The ESP32-CAM module is a versatile and compact development board that combines an ESP32 microcontroller with a camera module. It offers a wide range of functionalities, | ||
Line 22: | Line 23: | ||
(Specifications could be found here: [[https:// | (Specifications could be found here: [[https:// | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.2:** UARTSBee| | ||
The UARTSBee v5.0 module is a handy and user-friendly communication module that facilitates serial communication between devices. Equipped with a USB-to-serial chip, it enables easy connection and data exchange between a computer and various electronic devices or microcontrollers. Its compact design and robust functionality make it an essential tool for debugging and programming microcontrollers, | The UARTSBee v5.0 module is a handy and user-friendly communication module that facilitates serial communication between devices. Equipped with a USB-to-serial chip, it enables easy connection and data exchange between a computer and various electronic devices or microcontrollers. Its compact design and robust functionality make it an essential tool for debugging and programming microcontrollers, | ||
+ | |||
+ | |||
+ | |||
=== 4) USB A cable to micro USB cable === | === 4) USB A cable to micro USB cable === | ||
USB (Universal Serial Bus) is a widely used interface technology that enables the connection and communication between electronic devices. It simplifies the process of data transfer, device charging, and peripheral connectivity. The USB standard consists of various types of connectors, including Type-A, Type-B, and Type-C, each serving specific purposes. When a USB device is connected to a host device, such as a computer or smartphone, it establishes a communication link through a series of protocols. These protocols define the data transfer speed, power delivery, and the type of data being transferred. The USB interface provides a plug-and-play functionality, | USB (Universal Serial Bus) is a widely used interface technology that enables the connection and communication between electronic devices. It simplifies the process of data transfer, device charging, and peripheral connectivity. The USB standard consists of various types of connectors, including Type-A, Type-B, and Type-C, each serving specific purposes. When a USB device is connected to a host device, such as a computer or smartphone, it establishes a communication link through a series of protocols. These protocols define the data transfer speed, power delivery, and the type of data being transferred. The USB interface provides a plug-and-play functionality, | ||
Line 32: | Line 38: | ||
==== Our final setup looks like that: ==== | ==== Our final setup looks like that: ==== | ||
- | {{: | + | ^{{: |
+ | |**Fig.3:** Theoretical + Physical Setup| | ||
- | < | ||
For the setup we had to perform a couple of steps: | For the setup we had to perform a couple of steps: | ||
* | * | ||
- | The initial setup of the camera had glue on the lens protector and on the lens rotator.{{ : | + | The initial setup of the camera had glue on the lens protector and on the lens rotator.^{{ : |
+ | |**Fig.4:** Broken camera filter| | ||
So to make a proper focus we had to remove this glue or simply just to loosen the rotator. We made it using a knife and pliers. | So to make a proper focus we had to remove this glue or simply just to loosen the rotator. We made it using a knife and pliers. | ||
Unfortunately, | Unfortunately, | ||
Line 47: | Line 54: | ||
For this step we used the AI-on-the-edge project from Jomjol: [[https:// | For this step we used the AI-on-the-edge project from Jomjol: [[https:// | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.5:** Working Principle| | ||
+ | |||
+ | ^{{ : | ||
+ | |**Fig.6:** SD Card HTML File configuration| | ||
The project gives us a possibility to make our own computer vision system to interact with the water meter. The key features of the project are: | The project gives us a possibility to make our own computer vision system to interact with the water meter. The key features of the project are: | ||
Line 61: | Line 72: | ||
- REST API | - REST API | ||
- | {{ : | + | |
+ | The initial step of the installation was to download the ZIP archive [[https:// | ||
After downloading the repository we copied the SD card folder to our SD card that we used for the camera setup. | After downloading the repository we copied the SD card folder to our SD card that we used for the camera setup. | ||
Inside we could find a WLAN.ini file where we had to insert our wifi credentials in order to have our camera connected to our wifi. The SD card we use should not be bigger then 16Gb and should have FAT32 format. | Inside we could find a WLAN.ini file where we had to insert our wifi credentials in order to have our camera connected to our wifi. The SD card we use should not be bigger then 16Gb and should have FAT32 format. | ||
Line 76: | Line 88: | ||
Then we have to wait a little bit until the code will be transferred into the ESP32 cam: | Then we have to wait a little bit until the code will be transferred into the ESP32 cam: | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.7:** ESP32-CAM response| | ||
After performing these steps the ESP32 module should start to blink. If it blinks 4 times and then stops for a while then everything is ok and we can check it in Serial Monitor. | After performing these steps the ESP32 module should start to blink. If it blinks 4 times and then stops for a while then everything is ok and we can check it in Serial Monitor. | ||
Line 83: | Line 96: | ||
After successfully installing the software we can move to the step of setting the camera up. For this purpose we use the ip address we can obtain from serial monitor info. For us it was 192.168.2.167, | After successfully installing the software we can move to the step of setting the camera up. For this purpose we use the ip address we can obtain from serial monitor info. For us it was 192.168.2.167, | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.8:** Welcome HTML Page| | ||
We figured out that we had a problem with our wifi connection and it was repeating from time to time. We found a solution and it is to connect the camera to the mobile hotspot but later the problem repeated. So we think that just reconnecting helps but not for a long time. | We figured out that we had a problem with our wifi connection and it was repeating from time to time. We found a solution and it is to connect the camera to the mobile hotspot but later the problem repeated. So we think that just reconnecting helps but not for a long time. | ||
Line 91: | Line 105: | ||
Firstly we had to make a clear reference image. We can simply do this following the instructions. The image is needed for the system to know where to find the values. | Firstly we had to make a clear reference image. We can simply do this following the instructions. The image is needed for the system to know where to find the values. | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.9:** Reference image setting| | ||
The idea of the configuration is to align a proper box for the computer vision to work. By the box we mean that we have to indicate which field are suppose to be read. We can add or remove the boxes so finally we had to read the numbers and the analog indicator so just for test we made 3 number boxes and one analog indicator box. Then we can reboot the ESP32 module. | The idea of the configuration is to align a proper box for the computer vision to work. By the box we mean that we have to indicate which field are suppose to be read. We can add or remove the boxes so finally we had to read the numbers and the analog indicator so just for test we made 3 number boxes and one analog indicator box. Then we can reboot the ESP32 module. | ||
The next step is to get the image of a water meter. We can check the status of the system in a serial monitor. There we can see that after rebooting and two failed attempts to connect to wifi we finally can start making photos (so-called “Rounds”). The round is a one time recognition. | The next step is to get the image of a water meter. We can check the status of the system in a serial monitor. There we can see that after rebooting and two failed attempts to connect to wifi we finally can start making photos (so-called “Rounds”). The round is a one time recognition. | ||
- | {{ : | + | ^{{ : |
+ | |**Fig.10: | ||
+ | |||
+ | ^{{ : | ||
+ | |**Fig.11: | ||
Initially, we had aligned our boxed with mistakes and we could clearly seen that the values are not correct. But after making proper boxes and making some improvements we finally got our recognised results. We then tried to recognise the analog values as well and we indeed got some results but we think that the system is not recognising the analog values properly. Also, it is clear that when the value is in between two states (between 8 and 9 for example) the system sometimes make mistakes. It should clearly see the value to get it so we think that it is useful to also check the photo of a water meter. | Initially, we had aligned our boxed with mistakes and we could clearly seen that the values are not correct. But after making proper boxes and making some improvements we finally got our recognised results. We then tried to recognise the analog values as well and we indeed got some results but we think that the system is not recognising the analog values properly. Also, it is clear that when the value is in between two states (between 8 and 9 for example) the system sometimes make mistakes. It should clearly see the value to get it so we think that it is useful to also check the photo of a water meter. | ||
- | The window should look like that if everything went good: | + | ^{{ : |
+ | |**Fig.12: | ||
+ | |||
+ | ====== Another setup ===== | ||
+ | As it was previously said a number recognition process could make some mistakes in a lot of situations. Also, it could be not very convenient to open the website and check the results. But we have a solution for that situation. | ||
+ | |||
+ | ^{{ : | ||
+ | |**Fig.13: | ||
+ | We made a telegram bot which could be used for checking the values of the water meter. | ||
+ | |||
+ | We had to perform a couple of steps to make this bot usable: | ||
+ | - Creating a new bot | ||
+ | - Using the credentials from the created bot | ||
+ | - Making the bot work | ||
+ | - Receiving photos and check | ||
+ | |||
+ | After performing these operations we were able to get photos of the water meter directly onto our telegram account using /photos command and turning on the flash using /flash command. | ||
+ | |||
+ | For this project we used the code: | ||
+ | <file c# code.cs> | ||
+ | |||
+ | #ifdef ESP32 | ||
+ | #include < | ||
+ | #else | ||
+ | #include < | ||
+ | #endif | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | // Replace with your network credentials | ||
+ | const char* ssid = " | ||
+ | const char* password = " | ||
+ | |||
+ | // Initialize Telegram BOT | ||
+ | #define BOTtoken " | ||
+ | |||
+ | // Use @myidbot to find out the chat ID of an individual or a group | ||
+ | // Also note that you need to click " | ||
+ | // message you | ||
+ | #define CHAT_ID " | ||
+ | |||
+ | #ifdef ESP8266 | ||
+ | X509List cert(TELEGRAM_CERTIFICATE_ROOT); | ||
+ | #endif | ||
+ | |||
+ | WiFiClientSecure client; | ||
+ | UniversalTelegramBot bot(BOTtoken, | ||
+ | |||
+ | // Checks for new messages every 1 second. | ||
+ | int botRequestDelay = 1000; | ||
+ | unsigned long lastTimeBotRan; | ||
+ | |||
+ | const int ledPin = 2; | ||
+ | bool ledState = LOW; | ||
+ | |||
+ | // Handle what happens when you receive new messages | ||
+ | void handleNewMessages(int numNewMessages) { | ||
+ | Serial.println(" | ||
+ | Serial.println(String(numNewMessages)); | ||
+ | |||
+ | for (int i=0; i< | ||
+ | // Chat id of the requester | ||
+ | String chat_id = String(bot.messages[i].chat_id); | ||
+ | if (chat_id != CHAT_ID){ | ||
+ | bot.sendMessage(chat_id, | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | // Print the received message | ||
+ | String text = bot.messages[i].text; | ||
+ | Serial.println(text); | ||
+ | |||
+ | String from_name = bot.messages[i].from_name; | ||
+ | |||
+ | if (text == "/ | ||
+ | String welcome = " | ||
+ | welcome += "Use the following commands to control your outputs.\n\n"; | ||
+ | welcome += "/ | ||
+ | welcome += "/ | ||
+ | welcome += "/ | ||
+ | bot.sendMessage(chat_id, | ||
+ | } | ||
+ | |||
+ | if (text == "/ | ||
+ | bot.sendMessage(chat_id, | ||
+ | ledState = HIGH; | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | |||
+ | if (text == "/ | ||
+ | bot.sendMessage(chat_id, | ||
+ | ledState = LOW; | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | |||
+ | if (text == "/ | ||
+ | if (digitalRead(ledPin)){ | ||
+ | bot.sendMessage(chat_id, | ||
+ | } | ||
+ | else{ | ||
+ | bot.sendMessage(chat_id, | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | |||
+ | #ifdef ESP8266 | ||
+ | configTime(0, | ||
+ | client.setTrustAnchors(& | ||
+ | #endif | ||
+ | |||
+ | pinMode(ledPin, | ||
+ | digitalWrite(ledPin, | ||
+ | |||
+ | // Connect to Wi-Fi | ||
+ | WiFi.mode(WIFI_STA); | ||
+ | WiFi.begin(ssid, | ||
+ | #ifdef ESP32 | ||
+ | client.setCACert(TELEGRAM_CERTIFICATE_ROOT); | ||
+ | #endif | ||
+ | while (WiFi.status() != WL_CONNECTED) { | ||
+ | delay(1000); | ||
+ | Serial.println(" | ||
+ | } | ||
+ | // Print ESP32 Local IP Address | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (millis() > lastTimeBotRan + botRequestDelay) | ||
+ | int numNewMessages = bot.getUpdates(bot.last_message_received + 1); | ||
+ | |||
+ | while(numNewMessages) { | ||
+ | Serial.println(" | ||
+ | handleNewMessages(numNewMessages); | ||
+ | numNewMessages = bot.getUpdates(bot.last_message_received + 1); | ||
+ | } | ||
+ | lastTimeBotRan = millis(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | ====== Discussion ====== | ||
+ | Despite these systems being effective in taking photos of the water meter we think that we have to improve the system of recognition. Without the system we cannot make a proper data analysis and a long time analysis so the usage of systems is limited for now. | ||
- | {{:amc: | + | It was a difficult task to make the camera work and connect it to a wifi while maintaining the connection between a camera and computer. We faced a lot of struggles: |
- | {{: | + | |
- | {{: | + | |
+ | | ||
+ | - The Ai-on-the-edge project website was not working | ||
+ | - For telegram bot it was really hard to connect the number recognition system to a bot. There are some project on the internet, however, they use premade bots or paid ORS system. So we had to train the ai system by ourselves on a huge amount of data which was not possible due to a lack of data. | ||
- | {{: | + | However, we made a big progress in maintaining the smart water meter system. A lot of improvements could be made but we proved that it is possible to extract data from the ESP32 module and use it to build smart solutions for easier life. |
- | ===== Discussion ===== | ||
===== Links ===== | ===== Links ===== | ||
+ | [[https:// | ||
+ | [[https:// | ||
+ | [[https:// | ||
amc/ss2023/group-b/start.1689856931.txt.gz · Last modified: 2023/07/20 14:42 by matsvei.yankouski