top of page

Raising Pigs with AI

  • ruogu-ling
  • Oct 8
  • 11 min read
ree

Story of Zhang Tengfei

Zhang Tengfei, CTO of Ruixu Technology, once told me their story about using AI to raise pigs.

At first, even he was confused — how could artificial intelligence and pig farming possibly go together?


He said he first heard the idea from his friend Lan Song, now the CEO of Ruixu.

They were both PhD students at Nanyang Technological University in Singapore.

One day, Lan approached him and said, “Brother Fei, how about joining me to do AI pig farming?”


Zhang was surprised that Lan thought of him for this, because his field was geophysics — meant for exploring stars and oceans, not pigsties.


He laughed as he described his research.

He used to study solar prominences — massive jets of plasma thousands of kilometers high that erupt from the sun.

His computer programs could detect, track, and calculate their size — all fascinating, but utterly unrelated to pigs.


In another project, he used GPS signals to study the atmosphere.

When GPS waves pass through air, they delay by less than one nanosecond.

From that minute delay, he could infer temperature and humidity profiles.

Still — nothing to do with pigs.


He joked that his largest livestock experience was raising a cat.


The only real link to entrepreneurship, he said, was his love of programming.

He had written two programming books.

There’s a saying in startup circles: Everything’s ready except the programmer.

He had done procedural programming, object-oriented programming — but never pig-oriented programming.

“You can’t make a mobile game for pigs,” he said, “so I was really puzzled.”


But out of friendship, he agreed to visit a pig farm.

That first visit, he told me, felt like a spiritual cleansing.

Before even seeing a pig, there were endless steps — a small chamber, a sudden hiss of air, red lights flashing — “I thought I was entering a gas chamber,” he joked.

It turned out to be atomized disinfection.


Then came the showers and clothing changes.

All his clothes — even underwear — were locked away.

He had to shower multiple times before entering the living area.

He waited 48 hours in quarantine for health checks before he was allowed inside.

That farm was the largest single pig farm in Asia, with 16,000 sows producing 400,000 piglets a year.

The manager told him, “We’re afraid people carry germs, so our bio-security is stricter than a military zone.”

In Zhang’s words: “Basically, the pigs thought I was too dirty.”


When he finally entered the breeding barn, he was stunned — a sea of pigs, white and endless.

Each barn stretched over 300 meters long and fifty wide, filled with pregnant sows in individual stalls to protect their pregnancies.


He noticed the automatic feeding system: overhead pipelines called feed lines transported grain throughout the barns.

At feeding time, all the lines released food simultaneously — “a wave of pigs surging forward,” he said, “magnificent.”


Below the pigs were slatted floors, allowing manure to fall through into channels where scraper machines removed it constantly.

Contrary to popular imagination, the barns weren’t piled high with waste.


He also saw a ventilation system.

Inside, the smell was “remarkable,” he said — a mix of stench and heavy ammonia that made eyes water.

But thanks to air filtration, almost no odor reached the outside.


The farm had cost over 100 million yuan to build.

He thought, “With that kind of investment, there must be a market for high-tech pig farming.

If pigs can fly on the wind, then AI pigs can too.”

So he joined the startup.



Their first problem to solve was measuring pigs’ body temperature.

Temperature is vital for disease control, yet traditional thermometers are inserted rectally — unpleasant for both pigs and people.

Workers usually only checked when a pig ate less or acted oddly, meaning infections were often caught too late.

Better temperature monitoring could sharply reduce mortality.


Temperature was also key to breeding.

Each sow’s reproductive cycle is about 21 days, and missing the ovulation window wastes time and money.

On average, each Chinese sow produced ten fewer piglets per year than one in Denmark or the Netherlands — a 3,000-yuan loss per sow.

The reason was poor estrus detection.


Currently, workers rely entirely on experience — bringing a boar near, pressing the sow’s back, observing vulva changes.

The signs are subtle; even agriculture graduates need years to master it.


But temperature offers a stable clue: a sow’s body heat fluctuates noticeably around ovulation.

With AI algorithms, that pattern could be detected precisely, improving breeding success.


So temperature mattered for both disease control and reproduction.

Could they make pigs quietly wear a smart device that continuously monitors it?

What should a pig’s wearable look like?


They began with reference cases.

Cows wear neck collars with sensors and pedometers — but pigs, he said, “are too fat; they don’t have necks.”


So they thought: wearable… why not clothing?

Like infants’ smart onesies with built-in thermometers.

But pigs hate wearing clothes.

To make one wear something, you must restrain it by the nose, which is extremely sensitive — once held, the pig freezes.

They managed to put the little vest on, but soon every single one was torn apart.

The idea was scrapped.


Next, they tried earrings that measured ear temperature.

They gave themselves three months to prototype — design, mold, software.

Excitedly, they tested it at the farm.

After two shakes, the pig flung it off.


They didn’t give up.

“If not in three months, then in six,” Zhang said.

They built a second generation — the main body clipped to the outer ear, with a probe extending into the ear canal.

It looked better, pastel-colored like macarons.

But again, the pigs shook them off.


The third version stayed on but couldn’t transmit data properly — radio frequency tuning turned out to be “a form of sorcery.”


Those “three months” stretched into two years.

He laughed bitterly: “Customers are always right — ours just happen to weigh 300 kilos.”

Unlike human consumers who treat devices gently, pigs smash, bite, and ram them.


The hardware endured brutal testing, especially waterproofing.

They pumped air into water tanks to detect any bubble leaks.

Their structural engineer, who’d once designed smartphones and smartwatches at Foxconn, initially felt confident.

But he soon lost hope — “designing for pigs is harder than for humans.”


By the sixth generation, they finally succeeded.

Zhang recalled how Lan called from the test site, asking routine questions they’d failed before:

“Is it on? Secure? Any stress response? Is the signal out? Is the temperature accurate?”

This time, every answer was yes.

When he hung up, they didn’t cheer or hug.

They just sat quietly, both knowing what those two years had cost.


That sixth-generation product became their first commercial success, nicknamed the Electronic Doctor —

the world’s first and only accurate wearable thermometer for pigs.

Its readings differed from rectal thermometers by less than 0.13°C — extraordinarily precise, given that even a gust of wind could affect results.


To achieve this, Zhang built a temperature calibration model, finally using his atmospheric-physics background again.

He used OpenFOAM simulation software to model a pig’s ear canal,

then built a physical prototype using silicone, with a water bath at 39°C to mimic real conditions.

When a pig developed a fever, the system automatically sent an SMS alert.


He recalled the first time:

“When we got that message — ‘Pig #X has a fever’ — we cheered, ‘Finally! A pig has a fever!’ Then we realized that wasn’t great news and told the staff to check.”

At first, the worker refused: “The pig’s eating and sleeping fine.”

After some pressure, he measured rectally — indeed, it had a fever.

They treated it immediately, and soon the temperature dropped.


Two years passed before they could proudly show a working product.

Then came an unexpected call from one of China’s largest farming corporations.

The company had searched worldwide for such a device.

A Danish supplier had told them, “There’s a startup in Singapore making it.”

That was them.


Zhang said this proved that the pig industry isn’t as backward as people imagine.

China is the world’s largest pork producer and consumer.

The entire pork ecosystem — including related sectors — is worth three trillion yuan,

and pork itself about 1.4 trillion, two to three times the smartphone market.


Every year, 690 million piglets are born in China — meaning each Chinese person eats roughly half a pig per year.

Even the biggest producer, Wens Group in Guangdong, sells 19 million pigs annually,

not enough for one city like Beijing.


Wens ranks first in China, second in the world.

Within a few years, it will become the company managing the largest number of animal individuals in human history.

But managing industrial goods is easier than managing 19 million animals.


He gave an example: counting pigs.

With two or three, no problem.

But as numbers grow, it becomes complicated — pigs age, die, pile up, or hide.

And once the scale exceeds hundreds, thousands, or tens of thousands,

you must rely on workers — who may misreport for various reasons.


They realized they needed a scientific way to count pigs,

like traffic cameras that track cars and people.

They installed ceiling-mounted cameras and called the system Tianpeng —

named after the heavenly marshal who oversees pigs in Chinese legend.


The Tianpeng system uses deep neural networks and other AI vision technologies —

tools Zhang already knew from studying the sun’s prominences.

It can identify, count, and model each pig,

even reconstruct its 3D shape and weight from images.


Weighing pigs used to be a nightmare — chasing them onto and off a scale.

Pigs panic easily, backing away when pressured, turning the process chaotic.

“Pig herders are paid by commission,” he said, “because it’s such a skill.”

Tianpeng’s weight estimates reached 95% accuracy,

solving a major data-entry bottleneck for large farms.


The system also tracks behavior —

whether a pig ate, moved, or fought.

For Wens Group’s 60,000 partner farms, each technician covers a 40-kilometer radius.

They used to spend most of their time on the road,

barely minutes inside each site.

Now, it’s as if every pig has 24-hour remote care.


This earned praise from Mr. Wen Pengcheng, former chairman of Wens Group,

who said their work represented the future of the industry.

Wen was a legendary first-generation farmer of the reform era,

who built a trillion-yuan company from a village cooperative

and donated much of his stock to universities to link research and farming.


Still, Zhang admitted, even giants like Wens account for only 3% of China’s pig production.

The top eight producers together represent barely 7%.

Over half of China’s pork still comes from smallholder farmers.


Among them, technological investment and data transparency remain extremely poor.

Consumers rarely know where their pork comes from or how it was raised —

a problem that frustrates many agricultural experts.


A retired official from the Sichuan Department of Agriculture once showed Zhang a messy notebook

and spoke passionately for two hours about China’s pig traceability system.


Over ten years ago, China launched a national ear-tag identification program,

funded by the Ministry of Agriculture.

Each pig’s ear tag carried a unique ID to trace its origin.

In theory, if contaminated meat appeared, you could trace it back to the farm.

But in practice, the system failed.

When thousands of dead pigs floated down the Huangpu River in 2013,

most lacked ear tags.


Why? Because not tagging had “advantages.”

Farmers might buy 1,000 pigs but insure only 100.

When one died, they’d claim it was among the insured ones.

The ear tags were mailed to farmers to apply themselves,

and many delayed tagging until right before slaughter —

attaching tags only to healthy pigs.

Inspectors couldn’t prove otherwise.


Traditional tagging uses pliers to press the male and female parts of the tag together through the ear.

Zhang’s team modified the pliers with an electronic activation module.

When the tag clipped on, it automatically registered who, when, where,

and whether the action was authentic.

It transmitted that data instantly.


These features — number recognition, motion detection, authenticity verification —

used simple AI methods, yet had real impact.


At first, they feared resistance from farmers.

But during a pilot in a small Sichuan farm, something unexpected happened.

The owner, a man in his fifties, shadowed them all day, handing out cigarettes.

The team suspected he was stalling, so they rushed to finish tagging and leave.


The next day, the man called them to chat over tea.

He confessed he didn’t want to evade supervision,

but the environment forced him.

Local peers cheated insurance routinely;

if he stayed honest, others made trouble for him.

Some low-paid inspectors relied on “gray income,”

so they also encouraged fraud.


Before leaving to pick up his daughter, he sighed,

“I’ve raised pigs all my life. If I can’t anymore, I don’t know what else to do.”


Zhang said that was the first time he truly felt the human side of technology —

its power to bring fairness and dignity.

They decided to make their data open to governments and insurers,

helping honest farmers become model farms,

reducing false claims and simplifying real ones.


They even hoped to develop financial tools to ease farmers’ loans.

But so far, he admitted, they’d failed.

Ear-tag data was too thin,

and advanced systems like Tianpeng were far too costly for smallholders.


Ultimately, AI pig farming, he said, is just a set of new tools

that make the industry a little simpler, a little fairer.


Their team now has 30 members —

80% devoted to R&D,

including four PhDs and experts in electronics, mechanics, software, algorithms, veterinary science, and animal husbandry.

“The industry is desperate for talent,” he said.

“If any of you feel inspired to join pig farming after hearing me, contact me —

but be warned, it’s hard work.”


During the African swine fever outbreak,

no one could enter or leave farms;

fresh food was banned for fear of contamination.

Their engineers and animal technicians lived inside for months,

eating only starches and pork until they were sick of it.

On weekends, they made noodles themselves.


He acknowledged that pig farming in China has long been stigmatized.

People often ask, “Are Chinese pigs all raised with clenbuterol?”

He said China’s control is stricter than America’s.

The real issue is overuse of antibiotics,

a legacy of weak biosecurity now being corrected, perhaps too strictly.


He once saw a farm in Zhejiang surrounded by angry villagers.

No matter how much the owner spent on environmental protection,

residents still protested, blocked the gates, even beat workers.

But when the farm shut down, pork prices soared.


Some critics told him, “Your pigs have no soul.”

He said he’d love pigs to live better lives,

but large-scale welfare farming isn’t realistic in China.

Western farms seem kinder only because they have more land.

China lacks that space — high-density farming is unavoidable.

“If we wanted soulful, free-range pigs,” he said,

“we’d need many times more land and pork would become a luxury for the rich.”


He called the industry backward but full of potential.

People say, “AI is easy — just upload the videos to the cloud and count pigs.”

But rural farms lack the internet bandwidth for that.

It’s not the algorithms; it’s the infrastructure that limits progress.


So why persist?

He said he often asks himself that.

“Every time I return from a pig farm, the first thing I do is shower —

but even after washing, my hair still smells.”


Then he met a veteran pig farmer who gave him the answer.

When Zhang asked, “Do you want AI pig farming to sell pork at higher prices?”

the man replied, “No, you city kids don’t get it —

there’s still not enough pork for everyone in China.

I just want more people to have meat to eat.”

That farmer had left a comfortable veterinary job in the 1990s,

built a billion-yuan business, and never changed his simple goal.


“This,” Zhang said, “is why the industry deserves attention.”

There are 700,000 livestock workers and countless small farmers

waiting for fairness, understanding, and resources

to make real change possible.


And the biggest beneficiaries?

He smiled: “All of us who eat pork.”


Thank you.

Comments


Contact

China, Liaoning, Shenyang

Xinggong North Street 104 Avenue

General Inquiries:
86 15566156705

Customer Care:
Ruogu-ling@hotmail.com

Follow

Sign up to get the latest news on our product.

© 2035 by Yumeyi. 

bottom of page