Environmental Monitoring Rover - Powered by Intel Edison

by CJA3D in Circuits > Arduino

11648 Views, 239 Favorites, 0 Comments

Environmental Monitoring Rover - Powered by Intel Edison

IMG_8999 copy 2.JPG
Environmental Monitoring Rover - powered by the Intel Edison
Screen Shot 2015-10-18 at 5.47.42 PM copy.png
56244a2315be4d3a9000090f.jpeg
56244d4f45bceb47000008b6.jpeg

This is a instructable inspired by the Mars Curiosity Rover , I don't expect this rover to make it to Mars !! but you mimic it and implement some cool features using the Intel Edison. Having said that ,on mother Earth you can find industrial applications for this, to monitor hazardous condition.

Here are some features implemented using

  • A modified toy truck, which will act as the rovers chassis
  • Using a python-flask web app running on Intel Edison to control the Motors on the rover
  • Using a web cam to stream video to the web app to check the rovers line of sight
  • Add sensors to monitor the environment variable (click the Sensor button for real time sensor values)
    • Temparature
    • Gas sensor
    • UV sensor
  • Upload Sensor data to the Intel cloud analytics for future reference, by clicking the PostIoT button in the web app

Collecting Components Parts You'll Need

IMG_8797.JPG

Here are the components you'll need

Electronic components

Tools and other material

  • Zip ties
  • Multimeter
  • Wall mount DC12V ~1.5A to connect to the Edison during setup
  • Mini USB cable to connect to the Edison
  • 3D printer and Filament(this is optional but I would suggest at-least to print the Motor Driver STL file for easy mounting and wiring )
  • machine screws(about 10 ) if you plan on printing the STL files attached in the steps below.

Selecting a Chasis for the Rover

561d2f6c45bceb4c7100022a.jpeg

In my case, I am using the same toy monster truck as a chassis which I used on an older project.(the truck, retails for about 20$ at a superstores like Walmart etc). Here you can use any robotic chasis that would hold the Edison Arduino break out.

Remove the screws from the Monster truck and gently dis-assemble the parts.

Be careful and patient ! while getting the circuit board and the battery holder out to prevent it from damaging the battery holder.

Test the Motors and Solder Wire to the Battery Pack(Optional)

561eec1e50e1b6395b00045b.jpeg
IMG_8380 copy.JPG
IMG_8386.JPG
5604b4b050e1b65fcd000178.jpeg

Before you get to interesting bits below test to check if the DC motor are still functional , in my case I used a 4 AA battery holder to test both the motors as shown in the picture above.

Now desolder the circuit board using a soldering iron from the battery holder.

Once done add batteries to holder and do a quick voltage test using a multimeter as shown in the picture above, in my case the battery holder uses 5 AA batteries , which means a output voltage of about 8-8.5 Volts.

Solder some breadboarding wire to the two ends of the battery holder as shown in the picture above.

Note: This is an optional step, if you are using a rover kit of some kind,just ensure that the Intel Edison Arduino break out is mountable on the rover.

3D Print the STL to Hold Motor Driver to the Grove Shield (Optional)

IMG_8820.JPG
Screen Shot 2015-10-13 at 1.26.11 PM.png
IMG_8806.JPG
IMG_8809.JPG

Download the STL file attach and 3D print. It should take about 5-10 mins .This part attaches to the Grove Base Shield which is mounted on the Edison.

First using a zip tie, secure the Sparkfun motor driver to the 3D printed part.

Now connect the Grove Shield on the Intel Edison Arduino Base board.

Then screw the 3D printed part to the base shield as shown in the picture above with 4X40 machine screws.

Preparing the Intel Edison - Flashing Yacto Linux Using Flash Tool Lite

Screen Shot 2015-10-09 at 1.44.19 AM copy.png

Now to prepare you Edison download the latest version of the Yacto linux image from the Intel website at

https://software.intel.com/en-us/iot/hardware/edis...

While writing this instructable, the Yacto release version is - edison-image-ww25.5-15.

As part of this install as shown in the picture above we are going to use Flash Tool Lite tool instead of the old command line method which include the command (reboot ota) was used in one of my older instructable(Getting Started with Intel Edison - Python Programming)

You can find the manual to use the Phone Flash lite tool at

https://software.intel.com/en-us/articles/flash-to...

Tip : We are using the Phone Flash lite to flash Yatco so that we can make use of the ~900MB of space in the root partition , this will be handy as we will be installing a lot of packages and can use the space to store picture taken by the webcam.

Configuring Intel Edison -WiFi and Password for SSH

IMG_3763 copy.JPG
Screen Shot 2015-10-09 at 1.54.15 AM.png
Screen Shot 2015-10-09 at 1.54.52 AM.png
Screen Shot 2015-10-09 at 1.56.00 AM.png

Connect the Edison Arduino breakout as shown in the picture

  • basically connect the lower most USB port to the cable that will be connected to your computer. This is the Serial over USB port.
  • And connect another micro USB cable to the port which is closer to the switch. In this scenario this port will be used to power up the Intel Edison and the expansion board.

Now on your Mac, open the Terminal App

To get into the Edison via the Serial port use the following command screen/dev/tty.usbserial-A
and then hit the Tab key, this will populate the complete device name then type 115200 –L(in my case screen /dev/tty.usbserial-A402IDIL 115200 –L)

The Intel Edison has an Wifi chip on-board,so take advantage of it! if you have have a WiFi router at home..
To configure the Wifi on the Edison, type in the following command

configure_edison --wifi 

and hit the enter key It takes about 10 seconds for the Edison to scan for Wifi networks and list them as shown in the screen shot above. Type the number which matches with you WiFi router name , in my case "androidpod" is my network name which corresponds to 40 in the list

Type in your password, and once done make a note IP address and web url which in my case is http://edisonhub.local/. Bookmark the URL above as you will need this to know your IP address to SSH in.

To set a password for the Edison use

configure_edison --password

Once done using another terminal window, check if you are able to SSH in using

ssh root@ip-address-of-Edison

Now if you choose you can use ssh terminal or the screen terminal to setup the urls for the official packages repository for the Edison.

echo "src intel-iotdk http://iotdk.intel.com/repos/1.1/intelgalactic" > /etc/opkg/intel-iotdk.conf
 opkg update
 opkg upgrade

Now to complete the build you will also need the unofficial packages repository ,for this update the /etc/opkg/base-feeds.conf file, followed by the update command

vi /etc/opkg/base-feeds.conf

Then add the following line and !wq to save the file in vi editor

src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32

the run an update

opkg update 

Note: Do not run "opkg upgrade" for the unofficial repo, this will unnecessarily eat up space in your root partition.

For more info refer to AlexT's blog at http://alextgalileo.altervista.org/edison-package-...

Wiring Up the Intel Edison to the Sparkfun Motor Driver

IMG_8814.JPG
IMG_8816.JPG
IMG_8818.JPG
IMG_8835.JPG

Now for the wiring first connect the signal half of Sparkfun motor driver(TB6612FNG break out which is dual H-Bridge) to the base shield as shown in the first picture , here are the connections

  • STBY to pin 10 on the base shield which act as the Standby

To control back motor of the truck

  • PWMA to pin 3 - this is a PWM pin to control the speed of the motor
  • AIN1 to pin 9
  • AIN2 to pin 8 - both these pins decide the direction the back wheels will spin.

To control the front motor which provides direction to the truck

  • PWMB to pin 5
  • BIN1 to pin11
  • BIN2 to pin 12

Now insert/mount the board on your rover and complete the other side of the connections, that is

  • A01 to one terminal of the back motor as shown in the second picture above
  • A02 to the other terminal
  • B01 to one terminal of the front motor
  • B02 to the other terminal

Then to Power up the motor

  • Connect VCC to the battery +ve
  • and GND which to the GND of the battery back , here is where I use the Mini bread board to make a common ground connection to the Grove base shield

Tip: This is a pretty expensive piece of hardware so a suggestion here would be to use, zip ties to secure the board to the base. And also use electrical tape where ever necessary to prevent short circuits..

Testing Motors a Basic Test With the Python Code

Testing Motors using Python on the Intel Edison and Sparkfun Motor Driver

Now it time to test you rover/tuck motor and decide the direction the wheels are spinning.

Place you rover up side down and power it up using the 9V battery.

Download the code attached and upload the code to the Edison using a FTP tools like FileZilla/Winscp

And then run the following

Downloads

Installing Packages for the Flask Web App

Screen Shot 2015-10-08 at 7.55.45 PM.png

To install flask for the web app we will use pip to install it, which means that we will have to install the python pip package first, use the following command once you have ssh'ed into the edison.

 opkg install python-pip

Now that pip is successful installed as shown in the screenshot above install flask

pip install flask

Tip: I prefer using vi editor, but if you new to Linux or like prefer the nano editor over Vi, which will make it easier to edit file, if you have to, using the following command to install nano

opkg install nano

Testing the Flask Install

Screen Shot 2015-10-09 at 2.01.42 AM.png
Screen Shot 2015-10-09 at 2.04.22 AM.png

Using an editor(vi/nano) of your choice create a file and add the python code for a simple flask app, this will test if our flask installation was successful.

nano helloflask.py

Add the following lines of code

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello Intel Edison!"

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=800, debug=True)

Save the file using ctrl+X

and then at run the python file

python helloflask.py

Now test the app using you browser ,using the ipaddress of the Edison, as shown in the second picture above.

http://ip-address-of-Edison:800

Note: if you have forgotten/not made note of your ip address use the following command

ifconfig 

Testing the Rover Using Flask Web App

Screen Shot 2015-10-16 at 4.59.38 PM.png
Testing Python-flask controller App on the Intel Edison
Screenshot_2015-10-18-22-11-11.png
IMG_8829.JPG
Screen Shot 2015-10-16 at 4.40.06 PM.png

At this point shutdown the intel Edison using and get it off the wall adapter and power it up using 9v battery.

shutdown -h now 

Download the zip file attached and upload it to the Intel Edison using an FTP tool like filezilla.

SSH into the Edison and navigate to the basicflaskController folder and then run the command

cd basicflaskController
python flaskController.py

Now use your smartphone/table to bring up the app using your Edison IP address followed by the port :800, which in my case is

http://192.168.0.24:800

Congratulations !! on getting this far, you can now use the web app to control the Truck/rover as shown in the Video above

3D Print the Part to Hold the Webcam and Mount It Using Zip Ties(Optional)

56219a494fbadec043000f9e.jpeg
IMG_8840.JPG
IMG_8843.JPG
IMG_8845.JPG

Now to add a line to sight to the rover we are going to add a UVC webcam to the USB port of your Edison.

3D printing the parts is optional here, if you can find other alternatives to secure the webcam to the rover.

If you plan to 3D print and have the same web camera, that is the Logitech HD Webcam C270, download the STL file and slice it and 3D print it. Based on your setting 3D printing should take about 15-20 mins.

Now snap the 3D printed part on the camera and using Zip ties secure it to the top of the rover.

Finally add the USB to the USB port of the Edison as show in the picture above.

Installing Packages You Need to Run the Webcam

5622e50445bceb470000018f.jpeg
Screen Shot 2015-10-08 at 9.46.49 PM.png
Screen Shot 2015-10-09 at 2.10.43 AM.png
Screen Shot 2015-10-09 at 2.23.13 AM.png

Now to use the webcam connected to the USB port, you will need the following modules/packages to be installed on the Edison.

Before you install the kernel modules, you will need to backup , increase and restore the boot partition, or you will run into the error as shown in first screen shot above.

Use the following command to back-increase and restore the boot partition, as shown in the second screen shot

mkdir /home/root/boot-backup 

cp -rp /boot/* /home/root/boot-backup/

umount /boot

mkfs.vfat -v -nboot -F16 /dev/mmcblk0p7

mount /boot 

cp -rp /home/root/boot-backup/* /boot 

rm -r /home/root/boot-backup

Now you good to go and install kernel modules , which will extend the kernel for USB devices

opkg install kernel-modules

Now type the following command to validate if your web cam is detected,

lsusb

in my case it shows up as "Logitech Inc, webcam C270 "

Note: Here see that you flip the switch near the USB connector toward the power input if your camera does not show up.

Testing the Streaming From the Web Cam

Screen Shot 2015-10-18 at 12.24.32 PM.png

Now to the fun part, streaming from the Intel Edison WebCam!!

For this you will need to install the mjpg_streamer package

opkg install mjpg-streamer

And then use the following command to test the stream

mjpg_streamer -i "input_uvc.so -y -n -f 30 -r 640x480" -o "output_http.so -p 8080 -n -w /www”

And then got to you browser on your laptop and type the following, and use should be able to see yourself on in the browser as shown in the picture above.

http://IPAddress-of-Edison:8080

which in my case is http://192.168.0.24:8080/?action=stream, if you just want to see the live stream.

Tip: If you plan on taking picture/selfies with the Edison using your web cam, install fswebcam

opkg install fswebcam

And then to take picture use

fswebcam testPicture.png

Selecting the Grove Sensors to Add

IMG_8851.JPG

Now to get to the environmental monitoring part, choose your sensors, here I choose the following sensors

Grove – Temperature × 1 sensor

Grove gas sensor MQ5

Grove - UV Sensor

Since I am using python-flask , I have converted the Arduino Library into the equivalent python library, which you can find in the next step.

3D Print the Holder to Mount the Grove Sensor

IMG_8853.JPG
IMG_8855.JPG
IMG_8856.JPG
IMG_8869.JPG

3D print the STL file attached. Here I have attached 2 STL files which should take about 10-15 mins to print base on the one you select

#1 - Sensor Holder V2- this is ideal if you are planing on select in the same set of sensor, and already has mounting holes

#2 - Basic Sensor Holder - this is a simpler version so that you can drill holes after 3D printing and mount the sensors of your choice.

Screw the sensor to the 3D printed base and using zip ties attach them to your rover.

Testing the Grove Sensors

5622fbaa4936d45f900002dc.jpeg

Connect the sensors to the base shield

  • Gas sensor MQ5 to A0
  • Temperature to A1
  • and UV Sensor to A2

If you prefer to test each of the sensor individually download the zip file attached and upload it to your Edison to test each sensor.

For example to get the temperature printed to the terminal use

python TemperatureSensorValues.py

Using Intel IoT Cloud Analytics to Send Sensor Data

Screen Shot 2015-10-17 at 11.12.11 PM.png
5623fc702e7fb6d7df000031.jpeg
Screen Shot 2015-10-18 at 5.47.42 PM copy.png
Screen Shot 2015-10-17 at 11.42.10 PM.png
Screen Shot 2015-10-14 at 7.58.59 PM.png

To take advantage for the Intel IoT Cloud Analytics, follow the steps to setup and test uploading sensor data to the cloud.

Follow the link below for a overview and setup steps

https://software.intel.com/en-us/intel-iot-platfor...

In our scenario, we need to setup two new sensor instance for the UV index sensor and Gas Sensor once you have setup your login at

https://dashboard.us.enableiot.com/ui/auth#/login

Basically the temperature is setup by default at My Account -> Catalog at the web site above.

Got to My Account -> Catalog and click on Add Catalog Item button, and add the following values, as shown in the first screen shot above

Add the following catalog item

  • Component name = UVIndex
  • Type = Sensor
  • Data Type = Number
  • Unit of Measure = mV
  • Format = Float
  • Display = Time Series

And on the same line add values from Gas Sensor

  • Component name = GasDensity
  • Type = Sensor Data
  • Type = Number
  • Unit of Measure = mV
  • Format = Float
  • Display = Time Series

And then SSH into your Edison and follow the link above to check date,testing network connectivity,changeing the device Id and activating the Intel Edison.

Now register the UV index and Gas Sensor

iotkit-admin register uvindex uvindex.v1.0
iotkit-admin register gasdensity gasdensity.v1.0

And to list the catalog item use the following command as shown in the screenshot above

iotkit-admin catalog

Now to test posting values to the Intel Cloud use

iotkit-admin observation uvindex 60
iotkit-admin observation temp 21

And once you post a couple of values you should be able to setup a graph in the My Charts section on the intel IoT website as shown in the 3rd screen shot above.

3D Print the Fake Solar Panels (optional)

IMG_8874.JPG
IMG_8877.JPG
IMG_8882.JPG

Now to add looks! to your rover,3D print the fake solar panels STL file attached.3D the STL file should take about 10-15 mins based on your printer setting.

Then use a white paint pen to mark the groves in the 3D printed parts.

And then zip tie the 3D printed parts to the rover.

Downloads

Download the Code for the Monitoring App

IMG_9033.JPG
Screen Shot 2015-10-18 at 6.55.59 PM.png
IMG_8953.JPG
56244db745bcebf1d90002f5.jpeg

Download the flask web app attached and upload it to the Edison using a FTP tool like filezilla.

SSH into the Edison and run the flaskcontroller.py file

python flaskController.py

This will start the flask web app, you are now ready to open the web app on your tablet/mobile web browser

http://IPAddressfEdison:800

Congratulation !! you are done and now ready to drive your rover around using the controller web app and take temperature,Gas density and UV index readings at real time by clicking the Sensor button, and also post the values to Intel's IoT Analytic cloud, for a graphical view as shown in the screen shot above ..

Github link for the latest revisions to the code.

https://github.com/CJAndrade/Environmental-Monitor...

Rovers Future Enhancement

562449594936d45f90000961.jpeg

Here are some planned few future enhancements for the rover

  • Reduce the form factor using Intel Edison blocks from Sparkfun
  • Add some more interesting sensors like the Air Quality sensor
  • Add GPS to track the routes taken by the rover
  • And improve on the code, use openCV for spot detection(~something similar to face detection) as part of the flask app instead of mjpg-streams.
  • Power up the rover and Intel Edison with real solar panels , suggested by instructable members @GuthrieM1 and @VIVEK PRAKASHT

Please leave a comment below if you come up with some interesting suggestion..