Giter VIP home page Giter VIP logo

erriezoregonthn128's Introduction

Licence MIT Language C/C++ Release tag Open issue PlatformIO CI

Oregon THN128 433MHz temperature transmit/receive library for Arduino

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:

Oregon THN128

Transmit / receive hardware

This Arduino library can be used with low-power ATMega328 microcontroller (AVR architectures like Arduino UNO and Pro Mini 3.3V 8MHz boards).

Transmit and receive hardware

Temperature transmitter on the left breadboard:

  • Pro-Mini 3V3 8MHz.
  • Genuine DS18B20 temperature sensor.
  • STX802 low-power 433MHz transmitter.

Receiver on the right breadboard:

  • SRX882 low-power 433MHz receiver.
  • SSD1306 I2C 128x64 OLED display.
  • Pro-Mini 3V3 8MHz.

Supported microcontrollers

  • ATMega328 AVR designed for low-power
  • ESP8266
  • ESP32
  • Other microcontrollers are not tested and may or may not work

Arduino Examples

ESP32 with MQTT and Homeassistant

The Erriez_Oregon_THN128_ESP32_MQTT_Homeassistant.ino sketch can be used with Homeassistant integration.

Example screenshot Homeassistant dasboard:

Oregon THN128 ESP32 MQTT Homeassistant screenshot

Follow the steps below:

  1. Configure Homeassistant MQTT in configuration.yaml:
mqtt:
  discovery_prefix: ha
  # Enable when using SSL:
  # certificate: /ssl/ca.crt
  # client_cert: /ssl/client.crt
  # client_key: /ssl/client.key
  1. MQTT broker hostname, username and password should be configured in Homeassistant | Settings | Devices | MQTT.

  2. 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:

  • sensor.oregon_thn128_ch1
  • sensor.oregon_thn128_ch2
  • sensor.oregon_thn128_ch3
  • sensor.oregon_thn128_battery
  1. Configure Homeassistant dashboard configuration file:

Hardware Design Notes

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.

Oregon Protocol

A packet is sent twice:

Oregon THN128 Protocol

Data (see header file ErriezOregonTHN128Receive.h):

  • Byte 0:
    • Bit 0..3: Rolling address (Random value after power cycle)
    • Bit 6..7: Channel: (0 = channel 1 .. 2 = channel 3)
  • Byte 1:
    • Bit 0..3: TH3
    • Bit 4..7: TH2
  • Byte 2:
    • Bit 0..3: TH1
    • Bit 5: Sign
    • Bit 7: Low battery
  • Byte 3:
    • Bit 0..7: CRC

Oregon THN128 Temperature 16.6

Library Changes

v1.1.0

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);

Saleae Logic Analyzer

capture

capture from the Oregon THN128 can be opened with https://www.saleae.com/downloads/.

Generated Arduino Library Doxygen Documentation

MIT License

This project is published under MIT license with an additional end user agreement (next section).

End User Agreement 🇺🇦

End users shall accept the End User Agreement holding export restrictions to Russia to stop the WAR before using this project.

erriezoregonthn128's People

Contributors

erriez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

paulgreg froonix

erriezoregonthn128's Issues

Protocol 2.1

Feature request

Add protocol 2.1, it would be great!!!!!

Hardware setup

Arduino or esp

Is your feature request related to a problem?

no

Describe the solution you'd like

Implementing the 2.1 oregon protocol

Additional context

No response

Checks

  • I understand that this library is maintained by volunteers in spare time. Response time may vary.

Export restrictions.

Code adaptation for ESP32 ?

Hello,

Thanks a lot for your library which works great with an Arduino Uno.

I would like to use it on an Espressif ESP32 to integrate it on my weather station.
I’ve tried to adapt your library but without success for now...

While debugging, it seems I am never entering isPulseInRange since _tPinHigh is around ~450 or ~2250 but never into the correct range of 5100 ~ 5900. It works on Arduino so the problem isn’t from my thermometer.

By any chance, do you have any idea what can be pose problem to ESP32 port or what to look for ?

Best regards
Grégory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.