Skip to the content
PCBKitNew board
2 layers41.5 × 85 mmBase station, the printed circuit board in 3D

Base station

bytecod3/ear-tag1

Ear tag with LORA

Size
41.5 × 85 mm
Copper layers
2
Thickness
1.6 mm
Parts
4
Nets
43
Pads
58
Tracks, vias
95, 12
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
12 Dec 2024
Updated
18 May 2025

Overview

Base station is an open-source printed circuit board by bytecod3, from the bytecod3/ear-tag repository on GitHub, published under the MIT licence. It is a 2-layer board of 41.5 × 85 mm with 4 parts on 43 nets, routed with 95 tracks and 12 vias.

It is built around the NODEMCU-32SLUA and RA-01H. Its parts include 2 ICs, 1 resistor and 1 diode. It belongs with the ESP8266 boards of this library.

Main components

2

README

README.md

ear-tag

Ear tag with LORA

Introduction

This proejct implements a catle ear tag using LORA technology. The purpose of the tag is to monitor location and activity of the cattle. It is tailored to open ranch setups where the cattle have a huge chunk of land to graze.

This ear tag also monitors the activity level of the cattle and uses a custom algrithm to detect shcok and abnormal vibrations to tell whether the animal fell, is still lying down etc.

How it works

The device reads accelerations from an accelerometer sensor and does data processing to translate them into useful data like shock and activity levels. Using a GPS, we can monitor the real-time location of the animal.

This data is transmitted to a base station via a LORA gateway and visualized on the farmer's device, either phone and/or desktop setup.

Measuring acceleration and activity monitoring

MPU6050 measures acceleration using its on-chip accelerometer with four programmable full scale ranges of ±2g, ±4g, ±8g and ±16g that can be set by the user.The X, Y and Z are relative to how the chip sits on the module as shown to the right and will ultimately be dependent on the orientation of the module on the device.

Measuring rotation

MPU6050 measures rotation using its on-chip gyroscope with four programmable full scale ranges of ±250°/s, ±500°/s, ±1000°/s and ±2000°/s that can be set by the user. The axis of rotation are relative the the X,Y and Z shown to the right.

Using the I2C Interface

The module uses I2C interface for communications with MCU.It supports two different I2C addresses;0x68 and 0x69.That allows two devices to be used on the same bus or in case there is an address conflict with another device on the bus. The AD0 pin determines the I2C address to use.This pin has built in 4.7k pull-down resistor on module.if the pin is left unconnected,the line will be pulled low and the default I2C address will be 0X68.To select 0x69, connect the ADO pin to 3.3V. The SCL and SDA pins connect to A5 and A4 pins in analog input pins on the arduino board. The Auxiliary I2C address with pins labeled EDA and ECL are an I2C bus controlled by the MPU-9250 so that it can communicate directly with other sensors so that it can get additional information for its internal computations.

Pitch and roll calculation

Acceleration is read from all axes(x, y, z). The read values are then used to calculate the pitch and roll angles as shown below.

Pitch calculation
c
pitch = 180 * atan2(accelX, sqrt(accelY*accelY + accelZ*accelZ))/PI 
Roll calculation
c
roll = 180 * atan2(accelY,sqrt(accelX*accelX + accelZ*accelZ))/PI

Filtering and correcting MPU6050 data for accuracy

After obtaining MPU6050 accelerometer and gyroscope readings, addressing sensor drift, noise, and measurement errors is essential for accurate motion tracking and orientation estimation. [1]

Animal exhibit distinct diurnal patterns depending on the time of day[2]. This means that in the morning and evening they show high activity but during nightime they are ruminating and therefore low activiy. To detect the shocks, a High pass filter(HPF) is used to discard all data/noise below a given cutoff frequency.

Complementary filter

This ear tag uses a simple complemetary filter to do the data cleanup especially when calulating the pitch and roll angles. The formula is shown below:

c
angle = alpha * (accelerometer_value + gyroscope_value * dt) + (1 - alpha)* accelerometer_value

The graph shows the results obtained from applying this complementary filter:

alt text

The red line shows the filtered pitch angle while the blue line shows the raw pitch angle.

Moving average filter

The moving average filter is used to smooth out acceleration values to remove high frequency noise. It averages the last N values and returns a cleaner value. This filter is used when we do not have big memory constraints and at the same time we need to implement basic filtering.

text
/* pseudo code */

create a buffer  
read sensor  
store the previous N values 
calculate the average of the values 
return the average 

The acceleration values are prone to high frequency noise therefore the average filter was applied to them. The image below shows the result of filtering the x acceration:

alt text

The blue line shows the raw unfiltered value. Red line shows the filterd value. As it can be seen, the moving average filter works as expected, removing high frequency noise from the acceleration value.

Shock detection

In case the animal falls, we can use the MPU6050 to detect the shock and apply corrective measures. The accelerometer used is configured to measure up to (+/-)16g range.

Resultant acceleration calculation

To be able to register sudden animal activity, we have to keep track of the resultant acceleration, also called the magnitude of acceleration. The graph below shows the valeus of the raw magnitude of acceleration(using raw unfiltered values):

alt text

The sharp spikes show the acceleration when the device is dropped from about 40 cm high. It can clearly be seen that the magnitude of acceleration is high when this occurs.

This next figure shows the resultant acceleration using raw and filtered acceleration values, combined into a single plot.

alt text

The red line shows the cleaner values obtained from the accelerometer.

By monitoring the value of this acceleration, we can be able to set a threshold that we then check to determine if there is a sudden upsurge of activity.

Real Time animal tracking with GPS

To track the animal in real time we emply a NEO6M GPS module that read the GPS location data. The data read from GPS is:

  • latitude
  • longitude
  • day
  • month
  • year
  • minute
  • second

This data is then packaged into a packet to make it easier for transmission. The GPS is read at a frequency defined by the DATA_UPDATE frequency value.

LORA packet structure

Field NameData TypeDescription
tag_iduint32_tUnique identifier for the tag
modeuint8_t0 = Operational, 1 = Simulation
dayuint8_tDay (1-31)
monthuint8_tMonth (1-12)
yearuint16_tYear (e.g., 2025)
houruint8_tHour (0-23)
minuteuint8_tMinute (0-59)
seconduint8_tSecond (0-59)
latitudefloatGPS latitude in degrees
longitudefloatGPS longitude in degrees
geo_fence_proximityuint8_tProximity to geofence (0-100%)
acceleration_xfloatX-axis acceleration (m/s²)
acceleration_yfloatY-axis acceleration (m/s²)
acceleration_zfloatZ-axis acceleration (m/s²)
acceleration_magnitudefloat√(x² + y² + z²) (m/s²)

Network and WiFi Provisioning

The device is configured to search for available networks and connect to them automatically. To do this, we implement a WIFI provisioning scheme that allows you to connect to the network you desire.

Follow the steps below to connect:

  • once the device is powered on, it will create a WIFI netwoek called "EAR-TAG-WIFI", whose password is "password".
  • Using your phone or PC, connect to this network.
  • Once connected, open your browser and type the following IP address"
text
192.168.4.1
  • A page with buttons will open up.
  • Click on "Configure WIFI". A list of available networks will be shown. (Also here you can type teh SSID or password of the network that you will create, assuming you are using only one device)
  • click on save
  • The device will reboot itself and save the network accordingly.

connecting to server

This section defiens the steps to connect tot the server. The server is built using with NodeJS and runs a MongoDB database.

  1. Install NodeJS, open the web app folder in terminal
  2. Run the following command.
c
nodemon server.js
  1. To get the IP address of the server, run the following command in terminal of your host machine
text
ipconfig

Now to make the ear-tag-device connect to the server, make sure the PC amd the ear tag are on the same network using the WIFI connection procedures listed above.

Update the server URL in code

Since this is not a production environment and we have dynamic IP addresses, we need to update our server IP address in the Ear-tag firmware. Locate the server line below in the firmware and change to:

c
const char* server_url = "http://YOUR_IP_ADDRESS:3000/api/location";

Replace with your IP address.

Upload the code the device and restart.

Schematics

PCB designs

The PCBs are designed using EasyEDA Pro. Please download EasyEDA Pro here -> https://easyeda.com/page/download

3D casing designs

Viewing the system flowcharts and diagrams

To open the flowcharts and diagrams, download draw.io app here -> https://github.com/jgraph/drawio-desktop/releases/tag/v25.0.2 Choose the WindowsInstaller version

References

[1] [2] text

Parts

4
QtyValueFootprintReferences
1200RResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P15.24mm_HorizontalR1
1NODEMCU-32SNODEMCU-32S:MODULE_NODEMCU-32SU2
1RA-01HRA-01H:XCVR_RA-01HU1
1USERLED_THT:LED_D3.0mmD1

Questions

How big is the Base station PCB?

It measures 41.5 × 85 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Base station use?

4 parts, built around the NODEMCU-32SLUA and RA-01H. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Base station KiCad files?

From the bytecod3/ear-tag repository on GitHub, at the commit this page was made from: the board is hardware/base-station/base-station.kicad_pcb and its schematic hardware/base-station/base-station.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Base station design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers64.1 × 98.3 mmLora life jacket, the printed circuit board in 3D

    Lora life jacket

    bytecod3/lora-life-jacket

    Electronic device for life jackets with LORA data transmission

    17 parts2Apache-2.0
  • 2 layers82 × 50 mmESP S3 MONITOR V 1 2, the printed circuit board in 3D

    ESP S3 MONITOR V 1 2

    electromotif208/pcb-portfolio

    👨‍💻 Electronics Engineer 📺 YouTube: ELECTROMOTIF 🔧 Tools: KiCad, EasyEDA 📡 Domains: Power Supply, ESP32, IoT, Embedded Hardware

    90 parts
  • 2 layers66.8 × 65.3 mmCooee brains, the printed circuit board in 3D

    Cooee brains

    DetectiveMittens/Cooee

    An open-source phone that can operate without GSM or LTE coverage. Utilising LoRa modulation and mesh networking to enable long range "off-grid" communication

    79 parts3GPL-2.0
  • 4 layers40 × 40 mmESP32 Board V2, the printed circuit board in 3D

    ESP32 Board V2

    Tay0710/Design_S1_006

    This project integrates hardware, firmware, and design elements to develop a fully functional autonomous 3D mapping drone system.

    42 parts3
  • 2 layers50 × 100 mmCorrector de postura, the printed circuit board in 3D

    Corrector de postura

    agustin-arg/Posture

    Dispositivo electrónico de corrección de postura corporal

    23 parts5
  • 2 layers30.5 × 77.5 mmProyecto sensor temperatura, the printed circuit board in 3D

    Proyecto sensor temperatura

    unla-investigacion-desarrollo/ecosistema-iot

    Antes de desarrollar el sistema final, realizamos una etapa de exploración donde investigamos y experimentamos con las siguientes tecnologías:

    8 parts5
  • 2 layers91.4 × 76.2 mmArm pcb, the printed circuit board in 3D

    Arm pcb

    AashishKanted/Kratos_Arm

    2023-24 Code base for the robotic arm of the kratos rover

    24 parts2
  • 2 layers65.5 × 51.8 mmIOT, the printed circuit board in 3D

    IOT

    hopkinskong/eie553-iot-hardware

    ESP32 IOT Smart Lock Device Hardware Schematic and PCB used in the course "EIE553 Security in Data Communication".

    14 parts2