We made this project for a hackathon in Vives Brugge the challenge came from the province West-Flanders (belgium) and Infrax. they already have a system to get the data from the sensor to a computer but for this they have to use a usb-stick and they only get the data after 3 months. We changed the microcontroller so that the data gets send every 5 min to a database so that it can be viewed easily and fast.
Our ideaWe Had to make something that is easier to follow and has (almost) realtime data, we already know that Infrax has a LoraWan-Network that we could use. Because of this it was a logical decision to choose for LoraWan. The next step was to get it on a database. The first idea was to use an sql-database. But it would be easier for Infrax if we used an amazon database. thats why we use amazon DynamoDB.
Login pageThis project would be used for the government or a city, the only people who can see the data are the employees, this is why we build a login page.
<?php
error_reporting(E_ALL);
require 'vendor/autoload.php';
use Aws\DynamoDb\DynamoDbClient;
// Instantiate a client
$client = new DynamoDbClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => [
'key' => 'USER_KEY',
'secret' => 'SECRET_USER_KEY',
],
]);
$result = $client->scan([
'AttributesToGet' => ['dev_id','time','amountOfCars', 'direction'],
'ConsistentRead' => true,
'Limit' => 50,
'TableName' => 'hackathon_2018_elias',
]);
?>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['time', 'left', 'right'],
<?php
for ($i = 0; $i <= 18; $i= $i+2) {
$n = $i +1;
$time = $result->get('Items')[$i]['time']['S'];
$left = $result->get('Items')[$i]['amountOfCars']['N'];
$right = $result->get('Items')[$n]['amountOfCars']['N'];
echo "['".$time."',".$left.", ".$right."],";
}
?>
]);
var options = {
title: 'PassTru Data',
legend: { position: 'right' }
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
The data that has been send from the LoraWan to a database. The data is not standing perfectly (the time is a bit special). But we only had three days so we are happy with the result.
SimulationFor a simulation we made a small port that reads data from infrared LED's
We also had to make a businessplan. we used some numbers that we thought were about right. We know some of these numbers will be a bit higher and some will be a bit lower. Since we had so little time we still think it is as accurate as could be.
Comments