Oregon THN128 transmit and receive C library for Arduino
MIT License
This is a 433MHz wireless 3-channel Oregon THN128 temperature transmit/receive Arduino library for ATMega328, ESP8266 and ESP32 using the (reverse-engineered) Oregon THN128 v1 protocol:
This Arduino library can be used with low-power ATMega328 microcontroller (AVR architectures like Arduino UNO
and
Pro Mini 3.3V 8MHz
boards).
Temperature transmitter on the left breadboard:
Receiver on the right breadboard:
The Erriez_Oregon_THN128_ESP32_MQTT_Homeassistant.ino sketch can be used with Homeassistant integration.
Example screenshot Homeassistant dasboard:
Follow the steps below:
configuration.yaml
:mqtt:
discovery_prefix: ha
# Enable when using SSL:
# certificate: /ssl/ca.crt
# client_cert: /ssl/client.crt
# client_key: /ssl/client.key
MQTT broker hostname, username and password should be configured in Homeassistant | Settings | Devices | MQTT
.
Configure the listed macro's in the example, build and run from the Arduino IDE. The following Oregon THN128 entities are automatically registered after a succesful MQTT connection:
Supported hardware:
AVR designed for low-power
ESP8266
ESP32
For low-power transmitters, a Pro Mini 3V3 8MHz
bare board with ATMega328 microcontroller is highly recommended. The
board has no serial interface chip which reduces continuous power consumption. An external FTDI232 - USB serial
interface should be connected for serial console / programming. (See red PCB on the picture)
The SMD power LED should be desoldered from the Pro Mini to reduce continuous power consumption.
A transmitter with (protected) 1500mA 18650 battery can operate for at least 6 months with LowPower.h
functionality
implemented. (By sending the temperature every 30 seconds)
Changing the BOD (Brown Out Detection) fuse to 1.8V allows operation between 1.8 and 4.2V 18650 battery. (Explanation beyond the scope of this project)
1 to 3 temperature transmitters are supported, similar to the original Oregon THN128 temperature transmitters.
Check list of counterfeit DS18B20 chips , because this makes a huge difference in accuracy and read errors at 3.3V. Many DS18B20 chips from Aliexpress are counterfeit and won't work reliable at voltages below 3.3V.
NiceRF Wireless Technology Co., Ltd. sells high quality 433MHz transmit (STX802) and receiver modules (STX882) with a good range.
A 18650 battery (with protection circuit) should be connected directly to the VCC pin (not VIN).
The voltage regulator can be desoldered from the pro-micro board when not used for more power reduction.
A packet is sent twice:
Data (see header file ErriezOregonTHN128Receive.h):
The callback function void delay100ms()
has been removed as this was not compatible with ESP32. The application should
change the code to:
// Send temperature twice with 100ms delay between packets
OregonTHN128_Transmit(&data);
delay(100);
OregonTHN128_Transmit(&data);
AVR targets can replace delay(100)
with LowPower usage:
LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
LowPower.powerDown(SLEEP_60MS, ADC_OFF, BOD_OFF);
LowPower.powerDown(SLEEP_15MS, ADC_OFF, BOD_OFF);
capture from the Oregon THN128 can be opened with https://www.saleae.com/downloads/.
This project is published under MIT license with an additional end user agreement (next section).
End users shall accept the End User Agreement holding export restrictions to Russia to stop the WAR before using this project.