element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Proof of Concept for Animal Tracker
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: armour999
  • Date Created: 16 Sep 2014 1:07 PM Date Created
  • Views 573 views
  • Likes 1 like
  • Comments 1 comment
  • raspberry
  • pi
  • sensors
  • enocean
Related
Recommended

Proof of Concept for Animal Tracker

armour999
armour999
16 Sep 2014

Introduction

 

Well I missed the deadline as a Road Tester for EnOcean Pi and Raspberry Pi to use the contact sensor to analyze data from FHEM and calculate distance, velocity and acceleration from motion. But I still decided to continue and the following are my results ! Please double click on an image to enlarge it. I am excited about the results of this project. This has been quite the trip for me.  The last year I have become interested in using technology to help animals. I have spent most of my career as an IT analyst and was fascinated by the use of drones and stop motion cameras to gather data about animals. I am very active in the animal welfare community and have 970 followers on Twitter. My interest in sensors started with this article and video about placing sensors on bees :

 

https://ca.news.yahoo.com/blogs/geekquinox/scientists-fit-5-000-bees-tiny-backpacks-track-164102657.html

http://youtu.be/xdk9Bh8W4js

 

I thank the kind encouragement from friends and co workers. Thanks to Eric, Robbie, Chris F , Jennifer, Kate and Jackie at work, To my daughter Katie who given a preview always said "Wow Mom your project looks good" ! I also thank my best buddy Mac the dog. He comes to my work area to look for playtime or a treat or just stays on the couch for a snooze. Lots of people "rolled their eyes" when I explained the project image I may be off on some of my assumptions and calculations but then I consider myself to be an engineer citizen aka hobbyist.


My original goal was to provide the kit to The University of Prince Edward Island for the Red Urban Fox Project. The kit offers a low cost solution to tracking animals. As soon as I develop the enclosure than I will offer them the kit. The sensor is solar powered, wireless and maintenance free.

 

My next blog will be a more detailed test. The sensor is going on Mac the dog's collar ! This will include a video.

 

Hardware

 

So I am using the Raspberry Pi and EnOcean Pi. I also have a Ethernet cable, a power adapter and SD card that contains the software . The initial set was using this White Paper:

 

White Papers for Energy Harvesting Wireless Sensor Solutions | EnOcean - Technology

 

image

 

 

image

 

 

Software

 

 

I used open source software for this project with the exception of a free trial version of Microsoft 365. But you can also download Open Office.

  1. Sqlite3
  2. Perl
  3. Linux
  4. Microsoft Access
  5. Microsoft Excel

 

 

Step 1 : Install Raspberry Pi software and FHEM software

 

I set  up Raspberry Pi and EnOcean and have detailed the steps on other blogs:

 

theimage

 

Step 2: Install FHEM Charting Front End

 

The steps come from this post:

 

http://www.fhemwiki.de/wiki/Neues_Charting_Frontend

 

Sudo Apt-get install sqlite3

Sudo Apt-get install libdbi-perl libdbd-sqlite3-perl

Sudo Apt-get install-f

 

 

I have SQLite installed and the perl libraries required. I now add some tables to the database:

 

cd /opt/fhem

sqlite3

 

I have change the directory to build the tables . The second command brings us to the sqlite3 prompt.

 

CREATE TABLE `history` (TIMESTAMP TIMESTAMP, DEVICE varchar(32), TYPE varchar(32), EVENT varchar(512), READING varchar(32), VALUE varchar(32), UNIT varchar(32));

 

CREATE TABLE `current` (TIMESTAMP, DEVICE varchar(32), TYPE varchar(32), EVENT varchar(512), READING varchar(32), VALUE varchar(32), UNIT varchar(32));

 

CREATE TABLE frontend (ID INTEGER PRIMARY KEY, TIMESTAMP DEFAULT CURRENT_TIMESTAMP, TYPE TEXT, NAME TEXT, VALUE TEXT);

 

Now I have three tables set up in the fhem.db. To view the tables use:

 

.tables

 

I now see history, current and frontend. While I am still in the /opt/fhem directory I need to set up code to let FHEM  connect to the database:

 

nano db.conf

 

%dbconfig= (

connection => "SQLite:dbname=/opt/fhem/fhem.db",

user => "",

);

 

It looks like this in putty when complete:

 

image

 

Now in FHEM event monitor enter the following command:

 

define myDbLog DbLog /opt/fhem/db.conf .*:.*

 

I waited a few minutes for the software to install.

 

 

Step 3: Gathering Random Data

 

From my research  the Reed Sensor is used in everyday applications such as laptops, measuring distance, when a door is open or closed. The magnet acts as an actuary and when moves towards the sensor will cause the sensor to close and when moved away will cause the state to be open.  I spent some time in analyzing this data with FHEM. The raw data looks like this this in Access:

image


So this is the data that is automatically collected by Enocean Pi every time  the sensor sends a telegram. The key data for me was the Time Stamp and the State. The challenge was to figure out how to use this data to measure distance. I found this post demonstrating the measurement of distance using a contact sensor and a magnet. Please have a look at this demo. It was the foundation of my project and encouraged me to know my objectives could be met.


http://www.meder.com/fileadmin/meder/pdf/en/Technical_Documents/Technical_Write-Ups/SurveyorsWheel_Measurement_ReedSensor.pdf


The first software I tried was the FHEM WebFrontEnd  charts. I invested a considerable amount of time trying to graph some meaningful data. The best I came up with is a Hourly Count of the change in State:

image

At this point I decided to try Microsoft Access . This is my comfort zone as I have used Access on previous contracts. The random data is generated at this point by me move the magnet close to the sensor and then away from the sensor.


Step 4: Extracting Data from FHEM


I now have a table with the random data on the Raspberry Pi. Using Sqlite3 I was able to extract that data to a .csv file  using the following steps after I have logged into Putty:

 

cd /opt/fhem.db

sqlite3 fhem.db

.mode csv

.output test.txt

select * from current

 

 

 

 



Now I have a .csv file that I can import into Access or Excel. I need to move the file from the Raspberry Pi to my Windows Desktop on my laptop. To do this I used FileZilla.  This is the first time I have used this utility . After connecting the Raspberry Pi in FileZilla I simply highlighted my .csv file and downloaded the file to my desktop.


image


Step 5: Analyzing the data in Access


I imported the .csv file and coverted the file to a table.  A Key field was added to provide a sequential auto number to each record in the table. This will be used in two expression. I created a query to extract the data I wanted to use: State and Time.. That's it ! I need to know when the STATE changes from Closed to Open or Open to Closed to detect movement. This will be explained in more detail in Step .


Fields Created

1: TimeStamp from the imported data

2, State from the imported data

3. Key an auto number

4. NextState: DLookUp("[State]","Mac","[Key]=" & [Key]+1)  This expression finds the next record State and populates the result in the field

5. NextTime: DLookUp("[TimeStamp]","Mac","[Key]=" & [Key]+1) This expression find the next record TimeStamp and populates the result in the field

6. TimeDiff: DateDiff("s",[TimeStamp],[NextTime])  This expression calculates the difference in time in seconds

7. Distance: IIf([State]=[NextState],0,2.36) This expression calculates distance in meters, If the STATE has not changed than there has been no movement. If the STATE has changed than there has been movement


I need running total for the TimeDiff and Distance. I tried DSUM but it would not return the correct results. As a workaround I created report with with the two fields and was able to select the property for each field and select running total.

 

image


image








Step 6: Test the Sensor


I was given the perfect box for the magnet and sensor. Has I move the box back and forth it changes the status from open to close. This is a crude prototype but does give me an idea what the final product should look like. It will need to be waterproof. I decided to challenge  Google Maps for distance and see how close I come to the measured distance. Time will be measured by a stop watch I will carry in my pocket. I assume Google Map's time is for a normal pace so the Stop Watch will measure my time for the walk. I am a woman of average height 5'6 and I will be taking two steps while moving the sensor. So I calculated 2.640 meters for each change in State (open,closed) . Below are my results:

 

image

 

image


Google Maps distance: 93.00 m

Sensor Distance:  113.52 m

Margin of Error:  22%


Stop Watch Time: 6.8 mins

Sensor Time: 8.5 mins

Margin of Error: 25%


 

 

Not bad as the prototype box is just my interpretation of what it should like. This has to be outsourced to create the final enclosure. The time difference probably turning off the stop watch too soon. I exported the Access Table to Excel because graphing in Access still is limited:

 

 

 

 

 

 

image

 

 

image

 

Going Forward

 

image

 

 

This is the Xtrinsic sense board. It is attached to the Raspberry Pi and contains 3 evaluation sensors. 1. MAG3110 (Magnetometer) 2. MPL3115A2 (temperature/pressure) 3. MMA8491Q (accelerometer). This is an evaluation board. I would like to research the possibility of matching the MAG3110 with the contact sensor. Here is a screen shot of the demo:

 

image

image

 

This raw data could provide longitude and latitude and so position can be determined. Imagine precision mapping without GPS !

 

 

 

 

 

 


 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.

  • Sign in to reply
  • DAB
    DAB over 10 years ago

    Nice update.

     

    It looks like you are making good progress and testing your gear.

     

    Say high to Max for me.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube