So now its time to wrap up and finalize our Eclipse IoT Open Challenge project. Our contribution, the Raspberry Pi Eclipse IoT car, moves around in directions controlled remotely using CoAP and snaps pictures that are published via the MQTT protocol. A distance sensor makes the car stop if it is too close to an object. You can see how the car works in the video below.
Here is the list of the Hardware we used:
- Raspberry Pi Model B
- WiPi WiFi USB dongle
- USB camera
- Car plattform https://www.m.nu/robotplattform-dubbla-plattformar-hjul-motorer-p-1130.htm
- Motor control https://www.m.nu/picoborg-control-small-motors-from-your-raspberry-piborg-p-1071.html
- Rechargeable battery https://www.m.nu/robotplattform-dubbla-plattformar-hjul-motorer-p-1130.html
- Distance sensor https://www.m.nu/hcsr04-ultrasonic-sensor-p-1072.html
The application that runs on the Pi is programmed with Reactive Blocks. This is what it looks like:
The Motor Control block controls how the car moves forward, right, left and stop based on commands from the CoAP interface block. You can read more about this in the previous blogpost about the car. The HC_SR04_Ultrasound block interfaces the distance sensor and stops the car if it is too close to an object/wall. Here you can see the block magnified.
The information from the distance sensor is also sent via the CoAP interface block for remote viewing. The MQTT interface block communicates with the camera and publishes pictures to the MQTT server. This is what the block looks like inside
The Grabber block interfaces the camera and takes a new picture as soon as it is ready, resulting in a stop-motion like video. The pictures are converted to JPEG format in the Convert Image block and published to the MQTT server in the MQTT publish block.
We did experience some problems with the range and the stability of the WiFi connection. To compensate for this, the Timeout block was added to make the car stop if the car loses its connection with the remote application for more than 3000ms.
Hardware problems are time-consuming to fix and due to time-limitations we did not try alternative options for connectivity. It could be interesting to see how bluetooth performs. In addition we experienced that motors seem to interfere with the Raspberry Pi power supply causing occasional Raspberry Pi collapses.
The remote console application running on a laptop computer was also implemented using Reactive Blocks. This application lets you control the car with buttons and view the image stream together with data from the distance sensor
Want to see the details of the Reactive Blocks implementations for this project? Join the IoT-challenge team and download the complete modifiable Raspberry Pi car application. Got some new ideas? We will be happy to hear from you.