Friday 12 October 2018

LoRat Trap Monitor. Part 4 - PCBs and Antennas

The PCBs arrived, first from PCBWay and not too long afterwards from OSHPark. They look pretty good. Although the classic purple from OSHPark is interesting, I was pleased I selected white from PCBWay.




More importantly they seem to work. I found that there is an issue with the footprint for the SMD u.FL antenna connector which I have fixed for "next time" and also added some holes for direct antenna wire connection. However I'm unlikely to use the u.FL connector as simply a piece of wire or one of the coil antennas which comes the LoRa modules is likely to suffice. The part I was most concerned about - the SMD footprint for the LoRa module, seemed to be spot on and was not hard to solder - just run a fillet of solder up against every pin and remove any bridges with wick.





After that excitement there was a fairly long gap in this project as I was busy at work and ski season meant we were away many weekends.  All that time I still had my prototype out in the garden attached to a rat trap. Sadly there are no rats around at the moment, in our garden at least. At the same time I do check it from time to time and set it off manually to confirm the batteries are still good and the receiver is still running. There have been no false positives so far.

I wanted to experiment a bit with an antenna on the receiver. It was just sitting in my office with a small coiled antenna but to get the most range out of it I want to have an external antenna, located in the garage. This required the use of a WiFi extender to get a decent WiFi signal out to the garage and the construction of a suitable antenna.

Before I did that I wanted some way to estimate range. To do this I use built simple device using a Arduino Uno and a I2C LCD screen connected to a LoRa module. Code for this is on github. Faced with the difficulty of cutting a square hole, neatly, for the LCD I decided to have an enclosure laser cut out of acrylic sheet. This the first time I've tried anything like this, but it worked out pretty well. I used this box generator to generate the starting point for the design. A couple of bolts and standoffs keep the thing together, although I later added some plastic adhesive around the base.




When the test button is pressed it generates a random number then sends that to the base station and waits for a reply. If it gets the same number back in response then it prints the confirmation of that and the signal strength:




The science of antennas, for LoRa along with other radios, is pretty complicated. There's a lot of information on the Internet, some of it contradictory. I had bought this antenna off Aliexpress but wasn't really convinced it would be a good outdoor solution. In the end I decided to build a quarter-wave ground plane antenna as described here. That site also has a very useful calculator so I could cut fives pieces of single core copper wire taken from a domestic supply type cable and use a SMA->TNA adapter I got off TradeMe. This conveniently has four holes which can be used to bolt on the ground planes.




The pieces of wire are not super straight but I assume that won't matter too much. Along with a home-made 2m coaxial cable my initial tests showed it was slightly better than the antenna I bought off Aliexpress.





The antenna sits neatly on top a piece of 15mm pvc tube which then serve as a mounting post:



Initial tests suggest I get pretty good coverage all around the neighborhood. But I'll be trying to quantify that over the next few days.






Monday 6 August 2018

LoRat Trap Monitor. Part 3 - PCB design

I have now created a prototype PCB design to hold the LoRa radio and the Arduino Mini.

The schematic is pretty straight-forward:



As is the resulting board which is about 34 x 65mm:





This should fit inside one of the candidates for a repurposed enclosure - an "Eclipse" mint tin.

Design files are available on Github.

I created some custom footprints for the LoRa module and the U.FL antenna socket and these are also available on Github.  The LoRa module is quite tricky and might be difficult to solder but we shall see.

I'm having prototypes made at both OshPark and PCBWay simply for comparison. The latter will turn out quite cheaply as long as a cheap shipping option is available.




Sunday 5 August 2018

LoRat - remote trap monitoring. Part 2 - a (brief) successful field test

A brief followup to part 1. I did a preliminary field test over the weekend in our back yard. Since I have not caught a rat for a while I adapted it for mouse trap simply by rubber banding a mouse trap to the rat trap. On Saturday night, while on vacation in Wanaka, I was pleased to get this email:





Then when I got back on Sunday evening I found there was indeed a mouse in the trap:




It rained a couple of times and there was some wind over the weekend but there were no false alarms, the sensor seems to be still in good order. So far it is proving reasonably robust and it was great to see it adaptable to different trap types. So I'll leave it out for another few days before trying to find a more remote site to test it on rats.

Work is still underway on the PCB and figuring out a smaller and cheaper enclosure.


Tuesday 31 July 2018

Remotely monitored rat traps. Part 1 - early prototypes



Background






In recent months I've become interested in predator control in our neighbourhood. New Zealand native birds, reptiles and insects evolved in the absence of the mammalian predators which have been subsequently introduced such as rats, feral cats, hedgehogs, possums and especially mustelids (stoats, ferrets and weasels)  In addition to the wider scale efforts and the ambitious 2050 government target, many suburban neighbourhoods have begun backyard trapping. Some with considerable success.  Although there have been individual households in my own neighbourhood that have been trapping for some time, organised efforts are relatively new.

As I've set traps in my own property and those of several neighbours I've been surprised by the satisfaction to be gained from eradicating pests. However it's quite time consuming to properly monitor even just the 9 traps I have now.  As our efforts expand it seems that being able remotely monitor traps would be a great asset. I'd love to only go out and reset the trap when I know it's been sprung. My initial enthusiasm for checking them every day is starting to wear off.


Requirements

This project has some fairly demanding requirements.

  • Radio range
    Although we, through an expander, have fairly good WiFi coverage in the garden I want to be able to monitor traps over a wider range than just our own property. GSM is too expensive as is Xbee. I've experimented in the past with cheap 433Mhz garage door opener type boards and the more sophisticated nrf24l01 type devices but I haven't been impressed with the range available, especially in the face of obstacles like buildings and vegetation.
    Recently I've become aware of LoRa technology. These have ranges in the kms but low power requirements and are fairly cheap.  As far as I can tell these are legal in NZ, certainly the duty cycle is very, very low.
  • Detecting when the trap is sprung
    When I first started thinking about this project I was imagining some type of electrical connection or magnet/hall effect sensor to know when the trap had been sprung. However these all require some modification to the trap itself and are all a bit fiddly. About the same time I purchased a gas operated resetting A24 trap from the excellent Good Nature company. These have an counter which based on the description is some sort of vibration detector which wakes a MCU and increments a counter. That gave me an idea - perhaps I could do the same with a simple vibration switch attached to the interrupt of a sleeping Arduino of some sort. My first thought was a pizeo sensor like this. However that would need additional components, some sort of comparator and an inverter at least. I then discovered there's an even simpler device - a vibration switch which is just a wire coiled around a central post. The "fast" one seems about perfect, sensitive enough to catch the trap going off but not so sensitive that the wind or just walking by will set it off. 
  • Robustness
    There are two aspects of this. Firstly although the traps are generally in wooden boxes they are exposed to the elements at each end. So the system needs to be well protected against rain, frost, inquisitive rodents and eventually their blood. I'm still not 100% sure how I'll achieve this but some sort of shrink wrapping might be a good way to go. The other aspect is that humane rat traps go off with a considerable amount of force. While the sensor does need to have a firm connection to detect that, it also needs to be constructed fairly robustly to avoid being shaken to bits.
  • Power
    Although I did contemplate having some sort of solar power source that's not likely to be practical given these traps are usually placed undercover, along fences and under trees where rats like to hang out. Having sourced a cheap source of Arduino Min Pro clones I discovered that these are well suited to low power applications.  In particular based on the information in this very useful page.  With the LoRa radio asleep and the power LED soldered off the Arduino it only draws 64 μA when sleeping. In theory that means a 9V battery would last well over a year and four AAs considerably longer. When transmitting the draw is about 100mA but that's only for a few ms and presumably only rarely anyway. Field testing will be needed to establish exactly how long the battery will last. Some additional power savings can be achieved by using a 3.3 V power regulator with a low quiescent current but although I have ordered some of these I'm not planning to use them yet.
  • Cost
    Considering a Victor Rat trap in a wooden tunnel retails for $35 and is about the cheapest rat solution available what would a reasonable price for a monitoring solution? I originally thought about $10 for the sensors (the base station doesn't matter that much since I only need one of those). However the Arduino, remarkably cheap at $3, and the LoRa module at $7 already hit that traget. So perhaps $15 assuming I can make a reasonably sized PCB doesn't seem so bad. In fact the base station won't be that much more expensive since WiFi enabled ESP8266 modules are so cheap

Related Projects

Unsurprisingly I'm not the first to think of this. In fact the original idea came from hearing about this project in Taranaki.  There's not a lot of details but it looks like they are using the Celium product which appears to have a significant range advantage over LoRa although there are no details on cost. I doubt it's cheap.

One LoRa based product is EcoNode.  Again no information on price and it looks like it is tied to one particular type of modified trap.

There is also Trapminder. This based on a GSM cellular modem and solar powered so likely quite expensive per unit.

I'm sure there are others out there....

Overview of System

The plan is to construct something which is represented by the following block diagram:
Note the base station also includes an Arduino Pro Mini. This isn't strictly necessary since in theory it's possible to connect the LoRa module directly to the Wemos D1 Mini but I had some problems making that work and it's only slightly more complex to have the Arduino manage it.


The code is based on three Arduino scripts:
Note there's another private script I use to set the Wifi and Email passwords in the EEPROM of the ESP8266.

The following are photos of the prototypes. The sensor is currently in a domestic plastic storage container which is bolted via some aluminium angle to the bottom of the trap. In this way it's well clear of the mechanism but firmly connected to the trap.  
Sensor Prototype

Receive prototype on breadboard

Receiver prototype

Next Steps

  • Test the prototype in the field. I've been fairly successful in clearing out rats but I may try one of the neighbouring properties
  • Design a PCB for the sensor
  • Build a simple transmitter with an LCD attached to survey the range of the receiver and signal strength around the neighbourhood



A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil

 A Proton Precession Magnetometer - Part 1: Overview and Polarisation Coil For some time now I've wanted to add a magnetometer to my wea...