Introduction: IR Sensor for Water Measuring in a Tank
Nowadays with environment changes have been changing the way how people consume water in many cities, and there are problems in water supplies daily. There is a real need to plan and check how much water you have in your water tanks.
Learn how to build a device to measure the water level available in your tank using infra red sensor and Intel Edison board.
To cover the edison board, we use a old power supply case, zip ties and a pegboard.
Step 1: Step 1: Setup / Update Your Intel Edison Board
I recommend you visit the Intel official site to see how to assemble your Intel Edison:
https://software.intel.com/en-us/assembling-intel-edison-board-with-arduino-expansion-board
For download the latest firmware version use this link:
http://downloadmirror.intel.com/24910/eng/edison-image-ww18-15.zip
The step-by-step for Mac:
https://software.intel.com/en-us/flashing-firmware...
For linux:
Step 2: Step 2 : Configuring the Repositories
http://alextgalileo.altervista.org/edison-package-...
Edison configuration instructions:
To configure your Edison to fetch packages from this repo, replace anything you have in /etc/opkg/base-feeds.conf with the following (other opkg config files don't need any changes):
date --set=2015-06-19
===/etc/opkg/base-feeds.conf contents below===
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/edison
===end of /etc/opkg/base-feeds.conf contents===
Step 3: Step 3 : Setup of Pingo and Virtual Env
opkg update
opkg install git opkg install vim git config --global user.name "[your name]" git config --global user.email "[your editor]" git config --global core.editor vim
scp ~/downloads/virtualenv-13.0.3.tar.gz root@[your IP]:/home/root tar xf virtualenv-13.0.3 python setup.py install develop
virutalenv env27 source env27/bin/activate
git clone https://github.com/pingo-io/pingo-py.git python setup.py develop
Step 4: Step 4: Programming Your Edison
import time
import math
import requests
import mraa import pyupm_i2clcd as lcd
def ratio(_value, from_min=162, from_max=299, to_min=0.0, to_max=100.0): return (float(_value - from_min) * (to_max - to_min) / (from_max - from_min) + to_min)
pin = mraa.Aio(0) myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62) myLcd.setColor(0, 255, 128) while True: #url = 'http://192.128.0.148/?reading=%d' #url = 'http://127.0.0.1:5000/?reading=%d' url = 'http://ws.pinewoods.com.br/api?reading=%d' reading = 0 try: reading = pin.read() requests.post(url % reading) #requests.post(url % 666) # Debug except Exception as e: print e
myLcd.setCursor(0, 0) sensor = 'Sensor: %d' % reading myLcd.write(sensor) print sensor
myLcd.setCursor(1, 0) #distance = 87.09576644*math.exp(-0.004870217643*reading) level = ratio(reading) myLcd.write(' ') # clean myLcd.setCursor(1, 0) nivel = 'Nivel: %.2f %%' % (level) myLcd.write(nivel) print nivel
time.sleep(10)
Step 5: Step 5 : Building the Sensor Case
First, remove the electronics from your old PC power supply, we will need only the case.
Cut a piece of pegboard to just fit in your power supply case.
Using the zip ties fix your Intel Edison Board on pegboard.
Put the pegboard on the Power supply case.