invandy / Oregon_NR

Arduino library for Oregon Scientific and Explore Scientific wireless sensors decode and simulate
Other
31 stars 21 forks source link

BTHR968 #14

Open platone58 opened 3 years ago

platone58 commented 3 years ago

hello, I lost my BTHR968 of the WMR968 station, I tried to simulate with your program and it doesn't work or at least it works only t temperature and humidity as part in one of the three channels but only as a THGN132 sensor, I tried with other programs found on the net but yours is the only one who calculates something right in the two nibbles after the post-amble, or so I'm convinced. can you help me?

invandy commented 3 years ago

Hello. Ofcorse it is possiible to simulate your lost sensor with "Transmitter"and if you need a real data - with "BME280_Transmiter" examples. You have to change packet length, data fields and method of calculating CRC8. Moreover validiry of pressure data in you sensor packet is still doubtfull and requre additional researching with real sensor. I have no one.

platone58 commented 3 years ago

Hello, i have tried but do not know the exact length to change and crc method, can you send me a little sketch? thanks from Italy ,Giovanni

Il giorno lun 25 gen 2021 alle ore 12:03 invandy notifications@github.com ha scritto:

Hello. Ofcorse it is possiible to simulate your lost sensor with "Transmitter"and if you need a real data - with "BME280_Transmiter" examples. You have to change packet length, data fields and method of calculating CRC8. Moreover validiry of pressure data in you sensor packet is still doubtfull and requre additional researching with real sensor. I have no one.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invandy/Oregon_NR/issues/14#issuecomment-766736604, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYHNE7HDJHX3T2TN6DFLT3S3VFZPANCNFSM4VLX6V7Q .

invandy commented 3 years ago

ОК. Lets try to make BTHR emulator with common efforts. First, I'll make a sketch that will send a test packets, and you will test one on your weather station and give me a table with two columns:

  1. sent pressure data
  2. weather station pressure readings Also you'll have to pick up with your weather station the transmission intervals that is suitable for this sensor Second, we will create a final sketch. Do you plan to make a emulator only or device with battery and timer, like in "BME280_Transmiter" example?
platone58 commented 3 years ago

i want to say thanks for your help. I think I build a battery-powered emulator like in your project. I sure help you build a series of pressure points but how do I determine the right time interval? I want to use the BME280 and if everything works fine I could adapt the software to work with ATTINY85, could that be an idea?

Il giorno mar 26 gen 2021 alle ore 11:44 invandy notifications@github.com ha scritto:

ОК. Lets try to make BTHR emulator with common efforts. First, I'll make a sketch that will send a test packets, and you will test one on your weather station and give me a table with two columns:

  1. sent pressure data
  2. weather station pressure readings Also you'll have to pick up with your weather station the transmission intervals that is suitable for this sensor Second, we will create a final sketch. Do you plan to make a emulator only or device with battery and timer, like in "BME280_Transmiter" example?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invandy/Oregon_NR/issues/14#issuecomment-767459204, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYHNE2774EBSXG64QVCV63S32MHTANCNFSM4VLX6V7Q .

invandy commented 3 years ago

include

//variables is to be find out

define SEND_TIME 40000; //from datasheet - "around 40 seconds"

define CRC_START_SUM 0x00 //I suppose this value is 0x00, but not shure

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// unsigned long time_marker_send = 0; Oregon_TM transmitter(4, 28);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(115200);
transmitter.buffer_size = 23; transmitter.protocol = 2;

transmitter.setType(0x5D60); transmitter.SendBuffer[2] &= 0x0F; //no channel data transmitter.setId(0xF0); //suitable values for for this sensor: A7h, F0h

transmitter.SendBuffer[3] = 0; transmitter.setBatteryFlag(0); // Full battery transmitter.setTemperature(20.4); // +20.4 transmitter.setHumidity(40); // 40% transmitter.setComfort(20.4, 40); //

//Set pressure data word pressure_data = 0x19D; //0x19D, 0x186 and so on transmitter.SendBuffer[7] &= 0xF0;
transmitter.SendBuffer[7] += pressure_data & 0x0F;
transmitter.SendBuffer[8] = ((pressure_data & 0xF00) >> 8) + (pressure_data & 0xF0);

//Set forecast transmitter.SendBuffer[9] = 0x60;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void loop() { if (millis() >= time_marker_send) { calculateAndSetChecksum(); transmitter.SendPacket(); time_marker_send = millis() + SEND_TIME; PrintSentData(transmitter.SendBuffer); } }

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void PrintSentData(byte buf) { Serial.print(millis() / 1000); Serial.print("s \t\t"); for (byte i = 0; i < transmitter.buffer_size; i++)
{ byte trmbuf =
buf; Serial.print(trmbuf >> 4, HEX); i++; if (i >= transmitter.buffer_size) break; Serial.print(trmbuf & 0x0F, HEX); buf++; }
Serial.println(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void calculateAndSetChecksum() { byte CCIT_POLY = 0x07; transmitter.SendBuffer[9] = transmitter.SendBuffer[9] & 0xF0; transmitter.SendBuffer[10] = 0x00; transmitter.SendBuffer[11] = 0x00; byte summ = 0x00; byte crc = CRC_START_SUM; byte cur_nible; for(int i = 0; i < 10; i++) { cur_nible = (transmitter.SendBuffer[i] & 0xF0) >> 4; summ += cur_nible; if (i != 3) { crc ^= cur_nible; for(int j = 0; j < 4; j++) if (crc & 0x80) crc = (crc << 1) ^ CCIT_POLY; else crc <<= 1; }
cur_nible = transmitter.SendBuffer[i] & 0x0F; summ += cur_nible; if (i != 2) { crc ^= cur_nible; for(int j = 0; j < 4; j++) if (crc & 0x80) crc = (crc << 1) ^ CCIT_POLY; else crc <<= 1; }
} transmitter.SendBuffer[9] += summ & 0x0F; transmitter.SendBuffer[10] += summ & 0xF0; transmitter.SendBuffer[10] += crc & 0x0F; transmitter.SendBuffer[11] += crc & 0xF0; }

invandy commented 3 years ago

Try this. First, Put your weather station into search mode and try to send packets with CRC_START_SUM = 0. If it will be unseccessefull, try other values. Second, after exiting from search mode station have to keep connection with sensor if SEND_TIME is correct. I found "around 40 seconds" in sensor datasheet, but do not know what they mean exactly

platone58 commented 3 years ago

Grazie I quickly tested your program. Nothing appears on the oregon station but instead on the RTL_433 program running on Raspberry it is correctly seen as: Oregon BHTR968, ch 0, battery 1, house code 15, Hum 40%, Press 1013 hPa, 20.30 C. I have tried to randomly change the CRC but without success.i tried also to modify the tx time at 10 seconds but .. I will continue the tests

Il giorno mar 26 gen 2021 alle ore 15:51 invandy notifications@github.com ha scritto:

Try this. First, Put your weather station into search mode and try to send packets with CRC_START_SUM = 0. If it will be unseccessefull, try other values. Second, after exiting from search mode station have to keep connection with sensor if SEND_TIME is correct. I found "around 40 seconds" in sensor datasheet, but do not know what they mean exactly

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invandy/Oregon_NR/issues/14#issuecomment-767595258, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYHNE7QV7N2GSBGQ4FC6XDS33JHDANCNFSM4VLX6V7Q .

invandy commented 3 years ago

Try CRC_START_SUM = 0xA1

invandy commented 3 years ago

I found real packet from sensor "5D600CE26610840091C3683" and loaded it in "CRC8_search" utility. At CCIT_POLY = 0x07 it gives CRC_START_SUM = 0xA1

platone58 commented 3 years ago

Awesome, thanks! IT WORK !! Thanks a lot . Now I want to check the BME280 or better sensor, you are a big boss ! welcome in italy

Il giorno mar 26 gen 2021 alle ore 20:15 invandy notifications@github.com ha scritto:

I found real packet from sensor "5D600CE26610840091C3683" and loaded it in "CRC8_search" utility. At CCIT_POLY = 0x07 it gives CRC_START_SUM = 0xA1

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invandy/Oregon_NR/issues/14#issuecomment-767766796, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYHNE6R5HKWR3EULEANGS3S34IFJANCNFSM4VLX6V7Q .

invandy commented 3 years ago

Don't forget about table :)

platone58 commented 3 years ago

i'm trying different value, at 7 seconds not loss, 10 same ok , i'll try 40 in short time

Il giorno mar 26 gen 2021 alle ore 20:49 invandy notifications@github.com ha scritto:

Don't forget about table :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/invandy/Oregon_NR/issues/14#issuecomment-767786281, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYHNE3QIQVVSNZLO66IIW3S34MF5ANCNFSM4VLX6V7Q .

invandy commented 3 years ago

After exiting search mode almost all Oregon stations block sensors with incorrect transmission interval. Lost data on the display in 15-20 minutes means that you set a wrong interval. Try to increase e.g. temperature on 0.1C with every transmisson. If data stops change on the display it means that connection is lost. Try pressure_data = 0x19D, 0x186 and 0x190 at least and write a displayed pressure value. It will allow to correct calculate pressure field.