Raspberry Pi For the final presentation of our P2 Project, I mostly handled debugging of the Raspberry Pi as well as adding interaction with an additional feature, which is disabled lots. Now, if the lot which the sensor is in is disabled, the Raspberry Pi will detect in via Firebase and display the lot's status on the LCD screen. AAs you can see for the code above, it will run checks that go into the Firebase to see if it exists. If it returns none, it means that the particular lot is not disabled. Google API In addition to the Raspberry Pi, I was in charge of implementing Google APIs into our ASP.Net website. To start, we used Google's Cloud Platform to gain access to the API. What we wanted to do was have maps that showed the user how to get to the particular carpark from their current position. To do this, we used Google's JavaScript Maps API and the Directions API. Some problems that we faced included getting the API to link to our webpage as we had some problems with the billing process. Another problems was that a lot of tutorials for the API were based off HTML. Asp.Net is slightly different, which may have caused some problems but eventually we were able to find tutorials to guide us in using the API. The fact that the API was also well documented also helped. These codes are using JavaScript to access the Google APIs. How they works is that using Google's Direction API, we get the coordinates of the user's current position using Google's geolocation service. Depending on which carpark they are looking at, Google will then set the fastest direction between both points. As for the Map itself, we just access the Google Map and set it to a <div> tag . The Map will then automatically appear inside the div. You can see the product in the image below. Although we said that we would try to implement the LTA API, in the end, we decided to drop it in favor of putting the Google Maps in as in didn't seem logical to try and implement the LTA API which would have made the scale of this project extremely large. As for the Demo itself, it went quite well. We did not have a lot of traffic but we still encountered some problems like the sensors not working due to wiring problems but eventually it worked well. We were able to showcase our website with all features as well as the interaction between the sensors, Raspberry Pi, Firebase and the website.
Conclusion In conclusion, for this project, I mostly handled the code for the Raspberry Pi sensors and the interaction with Firebase and the wiring with the sensors as well as creating the model for the final demo day. In addition, I did the Google Maps API for the ASP.Net Website. Overall, this project was a good experience with not much conflict and taught me a lot about how to work in a team.
0 Comments
Our group haven't really done much development in recent times. Due to other projects, we feel kind of stuck as to what to do next for the project. So far, what I've managed to do is to have the Raspberry Pi's LCD screen also display the car's carplate number, which I retrieved directly from Firebase.
Next things we have to do is to create the administrator functions for our program. This includes creating a news and announcement page as well as the back end portions. This will mostly involves use C# Firebase Libraries to communicate with the database so that the administrator can properly change the data. For the Raspberry Pi, there's not much else to do. Mostly, we have to wait for the administrator functions to complete to see if we need to use the Pi for anything else. The more important part is to properly code out the path for the Raspberry Pi so that it will access the proper data as we are simulating one sensor for one parking lot for the demonstration. For the Hackathon, I mostly worked on the Python side of things. While waiting for some other functionalities, I also helped to program some validations for the login feature that we plan to have in our website. We faced some problems when it came to this as I was unfamilliar with how the Firebase libraries worked in C# so I had to spend the majority of the 1st day trying to fix that. From what I understood, Firebase passed in JSON data which we could parse into a class. However, due to our unfamiliarity we faced a lot of problems For the second day, I was able to start working on some codes for the Raspberry Pi. We faced some problems downloading the libraries which were previously provided for us but we managed to find them. Other problems that we faced included finding a display for the Pi as well as technical problems trying to get it to connect. As a result, all this caused delays in getting to actually program with the sensors. Afterwards, we were coding the behavior of the website and firebase based of data from the ultrasonic sensors. The way it worked would be that if a booking was detected by the program, it would return a "Booked" status on the parking lot. If the sensor detected an object near, it would return an "Occupied" Status. Afterwards, if it detected the object left, it would delete the booking assuming the car left. In terms of making sure the object in the lot is the correct car, we plan to have a way to have the user acknowledge that they are in the lot and if not, have some further investigation. To lesson the load on the Firebase, a request to post will only be made if a change in Status is detected. In addition to the ultrasonic sensor, the program also would display a message on a LCD display that would be near the lot. Problems we occurred at first was that the drivers for the LCD were hard to find as previously, it was acquired by Portfolio 1 tutors. Eventually, we managed to find the code for the drivers. The behaviour for the LCD screen is quite similar to the updating of status, only changing message if a change was detected. With the integration of Python with Firebase complete, the next step for us would be to improve the UI and start implementing API. Furthermore, we also need to think of solutions to replace the barrier we have planned to stop other cars from going in. Sample Codes:
LCD Drivers
For Portfolio 2, our idea is to create an app that will allow the user to book parking lots. The interface will consist of register and login functions as well as a map interface. To get carpark information, we will be using LTA data from an API. Another feature is to have a search function that will detect nearby available carparks and their info. Upon arrival to a lot, the user will have to notify the system that they have reached. We will be using Raspberry Pi to make use of sensors which will be use to detect the presence of a car. If the user has said they have reached but the sensors do not detect a car, a warning will be given and the lot will be freed up after a certain amount of time has passed.
We are using C#(ASP.Net) to code the interface, Firebase for the database as well as Python to code the sensors. My role for now is to code the Raspberry Pi, but currently the main problem we face is actually connecting to the Raspberry Pi via Remote Desktop connection. In Portfolio 1, this was easy to accomplish as the tutors had it mostly set up. However, now we had to find alternatives so we decided to go with VNC server on the Pi which can be connected to on other computers. From now on, the main problems I foresee are getting the data from the API to show on the interface as well as doing any database validation as the Firebase library in C# is not as well documented as SQL libraries in C#. |
P2 Blog
|