Project tutorial

Foaling Monitor © GPL3+

Help the breeders to follow the pregnancy of the mares and alert them when the birth is imminent and intervene as soon as possible.

  • 1,122 views
  • 0 comments
  • 6 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Background

A breeder, friend of mine, asked me for help to find a technique to warn her in case one of her mare is giving birth. We could not find on the market any suitable device that would allow her continuing her other activities and alert her at any time, especially when she is not at the farm.

Requirements

1. The device shall be able to send alert on a mobile phone, per SMS, per email…

2. The device shall be able to have access to a network at any time

3. The device shall be dust and moisture-proof

4. The device shall be shock-resistant

5. The device shall be able to monitor the pregnancy for at least 3 weeks

How the requirements are fulfilled

1. The device shall be able to send alert on a mobile phone, per SMS, per email…

To give birth, a mare is lying on the flank. The strategy used is to detect this change of angle to trigger the alert.

The required range detection is from 45 to 90 °. It was decided to use two ball tilt sensors which also allows reducing the consumption.

This is not the calving season, so a reconstitution took place

The first alert is sent if the mare stays at least 30 seconds on the flank, two more alerts are sent one and two minutes later to ensure the breeder saw the messages. The duration of 30 seconds was defined to avoid false alert due to other movements of the horse.

The arduino MKRFox 1200 sends the message "HORSE" to the Sigfox backend.

I created a Callback to the Twilio platform that sends an SMS to the breeder.

Fanfan not being too cooperative for a minute, here's how it works.

2. The device shall be able to have access to a network at anytime

In the frame of this project, the stable is 6km away from the closest GSM relay. The network is therefore very bad for using an arduino and a GSM card in a portable configuration. To overcome this issue, it was decided to check the coverage of Sigfox. The picture below shows that the Sigfox coverage using 3 stations is good.

3. The device shall be dust and moisture-proof

The mare may be outside, therefore the material for the housing of the device is selected to resist outdoor environment.

4. The device shall be shock-resistant

The housing material has been selected to have strong resistance. However, a horse is a very powerful animal and we cannot ensure that the housing will resist all treatments. To avoid risk related to the battery ignition in case of shock it was decided to ban the use of Li-ion or LiPo battery.

The use of mercury ball sensor was proscribed to not endanger the horse in case the device is damaged

5. The device shall be able to monitor the pregnancy for at least 3 weeks

The breeder knows approximatly the date of birth and it is important to monitor the last 3 weeks of pregnancy. The arduino MKR Fox 1200 consuming 650μAh in standby mode, 2 AAA 1250mAh batteries will allow a battery life of 80 days.

The Board and wiring

Twilio

You need to create a twilio account

https://www.twilio.com/try-twilio

Enter the phone number that will receive the alerts.

Sigfoxbackend

Create your Sigfox account and associate your Arduino MKRFox1200

Select the device type

Select CALLBACKS, New, Custom callback

Enter informations :

Type : DATA, UPLINK

Channel : URL

Url pattern : https://AccountSID:AuthToken@api.twilio.com/2010-04-01/Accounts/AccountSID/Messages.json

AcountSID and AuthToken is in your Twilio account

HELP

Tanks to Jennifer, Fantasia, Zoe, Delphine and Elena for their help.

Custom parts and enclosures

Arduino MKR Fox 1200
Not include in Fritzing by default
arduino_mkr_fox_1200_fixed_GwlZp1tUIH.fzpz

Schematics

Electrical wiring
poney_Zz7PXqI51T.fzz

Code

PonyArduino
#include <SigFox.h>
#include <ArduinoLowPower.h>

const uint8_t SWITCH_PIN = 1;
const String payload = "HORSE!";
const uint8_t debug = false;
int Count = 0; //Timer
int Circle = 0; //Number message send. After 3 messages, go sleep

void setup() 
{

  if (debug == true) 
  {
    Serial.begin(9600);
    while (!Serial) {};
  }
  
  if (!SigFox.begin()) 
  {
    Serial.println("Shield error or not present!");
    return;
  }
  
  delay(200);

  // Send the module to the deepest sleep
  SigFox.end();

  // Attach switch pin and enable the interrupt 
  pinMode(SWITCH_PIN, INPUT_PULLUP);

  // The mare lies on the side, switch close circuit
  LowPower.attachInterruptWakeup(SWITCH_PIN, CircuitClose, FALLING); 
}

void loop()
{
  LowPower.sleep();

  Circle = 0;
  Count = 0;
  
  //If the mare is lifted, switch is open module goes sleep
  //Or after 3 messages sent the module goes sleep 

  delay(1000);

  while (Circle!=1)

  {
   if (digitalRead (SWITCH_PIN) == HIGH)
   {
    Circle = 1;
   }
   
   // Timer Count
   delay(1000);

   Count++; 
       
   // Send message after 30s, 60s and 120s
   if (Count == 30 || Count == 60)
   {
    sendString(payload);
   }

   if (Count == 120)
   {
    Circle = 1;
    sendString(payload);
   }
   
  }
}

void sendString(String str) 
{
  // Start the module
  SigFox.begin();
  // Wait at least 100mS
  delay(100);
  // Clears all pending interrupts
  SigFox.status();
  delay(1);

  SigFox.beginPacket();
  SigFox.print(str);

  int ret = SigFox.endPacket();  // send buffer to SIGFOX network

  SigFox.end();
}


void CircuitClose() 
{
  
}

Comments

Similar projects you might like

Development Board for AtTiny MCU

by Vincenzo G.

  • 124 views
  • 0 comments
  • 5 respects

The Magnetic Field and RGB Tester

Project tutorial by Kutluhan Aktar

  • 277 views
  • 0 comments
  • 5 respects

Ultrasonic Security System

Project tutorial by Krepak

  • 393 views
  • 0 comments
  • 6 respects

Version 2.0 Advanced Attendance System (Without Ethernet)

Project tutorial by GadgetProgrammers

  • 2,988 views
  • 5 comments
  • 44 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by IoTBoys

  • 174 views
  • 0 comments
  • 3 respects
Add projectSign up / Login