Smart Roadway




Introduction: Smart Roadway

Project description

This application is a monitoring of street traffic, in order to detect cars and notify danger notification in critical street pointers (i.e. no visibility on on the cares in opposite sense). Furthermore this application sent in a remote server information like counters of cars to have a statistic of passages. The feature shall improve in the future in order to provide more data addind i.e. new sensor for noise detection and quality of air.

Team members:

  • Enrico Beltramo
  • Fabrizio Bonetto
  • Danilo Avalle
  • Roberto Ferrero
  • Marco Moschetti
  • Alessandro Marcon
  • Elisa Buccaresi

With the contribution of FabLabCuneo

Step 1: How It Works

Architecture definition
The structure of the project is composed by follow elements:

  • 2 or more station with light notification and distance sensor to detect cars passage (each build with 1 arduino + 1 ultrasonic sensor + 1 light + Xbee radio transmitter)
  • 1 master to gathering all stations notifications, coordinate actions (light on/off) and send statistic to remote server (build with 1 edison + Arduino adapter board + Xbee radio transmitter)

Each station detect cars passage using ultrasonic distance sensor. When a car is detected, the station send a radio message to master and it, using a decision table internally configured, provide to take action (i.e turn on a light). A sample of procedure should be this one:

  • station 1 detect a car and notify it to master ⦁ the master get the message and, as required in the internal lookup table, send a message to station 2: light on after 4s for 4s
  • the station 2 get the message and after 4s set light on for 4s
  • in the while the master update the remote statistic with new car passage detected.

The project needs to build and program the 2 station and the master. Furthermore is necessary to program each Xbee module in order to create the radio network.

Step 2: Xbee Network Programming

Xbee network programming

The Xbee are simple radio modules that should be configured in order to create a complete radio network (“Xbee swarm”). There are many different configuration that should be used in this project, but, in order to have maximum scalability and configurability we chosen:

  • a coordinator (for the Master station)
  • 2 or more router (one for each station)

So, each radio module shall be configured and programmed for his defined role. The more easy way to program those module is to use the Sparkfun USB programmer in order to connect them to PC and with the XCTU tool program them.

The step to program are:

The configuration for coordinator role is:

  • Firmware (from menu: tools --> firmware explore) choose :_ Znet Router/End device AT
  • See --> picture 1

  • Node ID: 0
  • DH: 0 (for addressing of destination packets, in our case ever 0)
  • DL: FFFF (mean that each message send by Coordinator in in broadcast and can be received by each router in the network)
  • Network: 0 (should be any number in allowed range just ensure that the master and stations has the same value and it is different from other near Xbee networks)

The configuration for router role is:

  • Firmware_ Znet Router/End device AT
  • see --> picture 2

  • Node ID: na (is automatically configured by Arduino using the internal station node id)
  • DH: na (is automatically configured by Arduino to 0)
  • DL: na (is automatically configured by Arduino to FFFF)
  • Network: na (is automatically configured by Arduino to 0)

The correct firmware for each router should be loaded using follow configuration files (just go to load configuration file and select the file):

  • see --> profile_routerAT_25_master.xml

Note: if loading the configuration file you change the firmware, after the update force a write of all parameters.

The network was configured with all router in order to simplify the network configuration (having same firmware for all devices). Another choice should be to have router for station and coordinator role for Master:

  • see picture 3

Note: be sure to program each Xbee module separately with correct firmware and configuration.

Step 3: Station Build

Station build

Each station is composed by:

⦁ 1 Arduino

⦁ 1 ultrasonic sensor

⦁ 1 relay (to connect to light)

⦁ 1 Xbee module (configured as router see previous step)

The connection between Arduino pins and modules are follow: Ultrasonic sensor:

⦁ 5V --> 5V Arduino

⦁ GND --> GND Arduino

⦁ Echo --> digital pin 2 Arduino

⦁ Trig --> digital pin 3 Arduino

Xbee radio module:

⦁ 5V --> 5V Arduino

⦁ GND --> GND Arduino

⦁ DOUT --> digital pin 4 Arduino

⦁ DIN --> digital pin 5 Arduino

Light relay:

⦁ Command --> digital pin 6 Arduino

After make all connection, the Arduino should programmed. Here the sketch to use:

The program is a few complicated because provide many features:

⦁ Program Xbee module with correct network parameters

⦁ Read ultrasonic sensor and detect cars

⦁ Send data to Xbee (with repetition and aknowledge)

⦁ Read data from Xbee and execute action (i.e. light on off)

⦁ Read and write serial for configuration and log

After program the Arduino, it shall configured using serial communication. It’s possible to use the serial monitor of Arduino IDE:

see --> picture4

just ensure to set 9600 baud and CR option.

For send command, write command and press “ENTER”. The available commands are:

⦁ LOG ON: to enable verbose log

⦁ LOG OFF: to disable verbose log

⦁ DISTANCE ON: to enable log of distance read by sensor

⦁ DISTANCE OFF: to disable log of distance read by sensor

⦁ GET ID: to have the id of station

⦁ SET ID xx to set the node id. It should be between 1 to 20. It will automatically store in Arduino EEPROM and applied in next reboot of device

⦁ GET DISTANCE to get max distance for cars detection configured

⦁ SET DISTANCE xxxx to set max distance for cars detection. It will automatically store in Arduino EEPROM

Step 4: Master Build

Master build
Each master is composed by:

⦁ 1 Edison + Arduino adapter board

⦁ 1 Xbee module (configured as coordinator --> see previous step)

The connection between Arduino pins and Xbee radio module are:

⦁ 5V --> 5V Arduino

⦁ GND --> GND Arduino

⦁ DOUT --> digital pin 0 Arduino

⦁ DIN --> digital pin 1 Arduino

The master shall program with a project created with Eclipse editor. In the head of program is possible to configure the lookup table with actions to do after any notification from stations.

Using integrated wifi on the module it’s possible to connect the board to Internet and send remote statistic.

Be the First to Share


    • Digital Fabrication Student Design Challenge

      Digital Fabrication Student Design Challenge
    • Build a Tool Contest

      Build a Tool Contest
    • Leather Challenge

      Leather Challenge


    DIY Hacks and How Tos

    Cool. It would be really interesting to see what kind of data you can track over time.


    Reply 5 years ago


    The IOT part is ongoing, actually we would to track the traffic (as counter of cars) and, if the sensor is enough trustable to do that, the average speed of cars in order to detect traffic jam