Open nonifo opened 9 months ago
I assume you are running the OrigoMqtt example. Are you seeing the welcome message "OrigoMqtt starting" when you start the device?
Otherwise, check that you have your serial monitor set to 115200 baud and that DEBUG_PRINT and DEBUG_PRINT_SIGNAL are both defined in Uservalues.h in the OrigoMqtt example folder.
exactly, OrigoMqtt example.
I see you have the correct baud setting and correct programming of the device, getting the welcome-message. And WiFi-connection is OK as it prints the assigned IP address. I assume your MQTT server is not password protected or unavailable so that it is causing problems for the device.
I am not sure what could be the problem then. I bought my two batches of the Origo detectors years apart, and they share the same signal construction and will be printed to the serial monitor when I press the alarm button of one of them for a few seconds. This is in Norway, not sure if they could have some variation of the signal in other regions, but I doubt it.
If you have a logic analyzer (A Cyprus board with USB connection costs only a few euros) that you can connect to the PulseView open-source program, you could log the pulses and compare them to the ones I have shown in the README. I have this logic analyzer.
You can also define DEBUG_PRINT_PARTIAL_SIGNAL to have it print any small parts of a signal it receives, perhaps that will give some clues.
I have a Wemos D1 mini that I run it on, also using pin D5 with a blue SRX882 receiver. I have had problems with the green 433MHz receivers, but I have never tried the one that is used in the smoke detector itself.
I'm in Sweden so it should not be that big differens. Just noticed that my "SRX882" is an SRX882S, maybe that's what are different.
I did order the logic analyzer from AliExpress too. Guesses it will become handy to have it. I also order an "DollaTek RXB6 433MHz Superheterodyne Wireless Receiver Module for Arduino/ARM/AVR" from Amazon due to the delivery time.
Hopefully I receive the RXB6 before the weekend.
I also tried to see if i have anything coming in on the from the data pin using this code.
`#define RECEIVER_PIN D2
void setup() { Serial.begin(115200); pinMode(RECEIVER_PIN, INPUT); }
void loop() { if (digitalRead(RECEIVER_PIN) == HIGH) { // Signal detected, read the data byte data[8]; for (int i = 0; i < 8; i++) { // Wait for the start of a bit while (digitalRead(RECEIVER_PIN) == LOW) {} // Bit has started, wait half a bit period and then read the value delayMicroseconds(200); data[i] = digitalRead(RECEIVER_PIN); } // Print the received byte for (int i = 0; i < 8; i++) { Serial.print(data[i]); } Serial.println(); } }`
At first i did not received anything but 0. But after connecting CS pin to 3.3v it begun to send data. But it did not do with your code, still nothing in the output.
If you get nothing printed even with DEBUG_PRINT_PARTIAL_SIGNAL defined, we must find out whether there is a compatible signal coming in on D5 at all, and I guess using the logic analyzer would be a good way to do that.
Looking at the SRX882S, I see it has higher sensitivity which is good. But I see from here that the requirements for connecting CS may be different. I have not connected CS at all on the SRX882, but you may have to connect it on the SRC882S to activate it, if you have not done so.
They also come in both 433 and 315 MHz versions. Perhaps you got the 315 MHz version? Probably not, but it could be a good idea to double-check.
I will test tonight with another module (RXB6) that I hope will arrive today.
But I will try with the srx822s once more when I have my logger. Something fellt wrong, I did order a new SRX882 as well, hope to get the version whitout an S. The first was ordered whitout S and still I recived with S. 🤷
Did you connect the CS on the SRX882S to positive to activate receiving?
Yes I did tried that. Nothing. Same with RXB6.
But my code from above give at least indication that something are coming in on the pin
Give this output. 00:05:43.835 -> 11101111 00:05:43.868 -> 11101111 00:05:43.868 -> 11011100 00:05:43.868 -> 00010111 00:05:43.868 -> 01011010 00:05:43.868 -> 01111111
I'm thinking if it possible to reroute the traffic on the pin, into PulseView some way. Never used it before, but sometime its a good time to learn ;)
I have not looked for other ways to get data into PulseView than with a logic analyzer, so I cannot say if there is a way to make an Arduino or other device pass it though. Hopefully your logic analyzer will not take too many weeks to arrive.
I did use my digital oscilloscope to begin with, until I found that the logic analyzer was much more fit for purpose. But I could freeze the pulse sequences with the scope as well, and measure the pulse widths.
Trying to use a Arduino UNO as logger ;) What next? Decoder??
I'm not sure if this file will help I think i succeeded to log at least one sequence.
Add the Timing decoder to see the length of pulses, then zoom in and scroll through the sequence.
Like this?
If you click on the Timing filter you get a property dialog. Set the "Edges to check" to "any". Then you get widths that can be compared to the ones I show in the printed output example in the README for the OrigoMqtt example.
This are what I got after pressing the button of one of them. But I pressed it soo longe that one of the the other smoke alarm started to beep .
Hmm, probably zoom out to see the repeated sequences first, like this, then zoom back in to see one sequence
Did you only get one sequence?
Only one :/ Is it some other settings? Your app are a little different from mine, i can set 1k samples and 200Hz for example, whats your settings?
Cannot really remember the numbers, but 20000 samples and a rate of 20000Hz should give a detailed look at those pulses of about 0.5ms width.
If you ordered a logic analyzer, that will enable you to properly analyze the signals. I hope it will not take many weeks to get it. You do not have access to a digital oscilloscope?
I have the .sr files for my detectors, so it should be easy to compare and verify that you are receiving the signals properly, and to modify my code if there are actual differences to the base signal.
@nonifo Just because I am curious -- did you get a logic analyzer and sample the signals with higher resolution?
Im back ;)
How to decode the signal? I cant get anything in the Arduino i'm using, its an UNO. But when i connect the SRX882S to my Cyprus Datalogger I get the picture above.
The capture from your data logger is clean and repeatable. It seems to be 10010110011010100110101001101001010101010101101000000 or 0x12CD4D4D2AAB40 in hex. Please verify before using it in case I was too hasty.
Did you define the 3 DEBUG_PRINT* defines that are shown at the top of OrigoSmokeDetector.h (before including OrigoSmokeDetector.h) or uncomment the defines in that header file, to enable printout of detected signals?
I assume you are not using the OrigoMqtt.ino example? (MQTT would require an Ethernet card for the Uno, I use an ESP8266 currently). Remember to enable the serial port and set the Arduino serial monitor to the correct baud rate.
I use OrigoModuleInterface, was hopping to get some kind of output in the console. I have an ESP i could try with also, but if i remember correctly i already have tried that last time
With an ESP8266EX NodeMCU v3
But absolutely nothing more.
Can you attach your sketch here exactly as it is when building? You did set the 3 DEBUG_PRINT* preprocessor defines?
// This file contains user-defined constants for the origo-mqtt example.
// Whether to print debug information to Serial. Typical use is to define the two on top, run it to scan and find
// the SEQUENCE_HIGHBITS and SEQUENCE_LOWBITS to insert fiurther down, then undefine the debug prints when all working.
#define DEBUG_PRINT // Print basic debug information (must be defined to define the other 2 below)
#define DEBUG_PRINT_SIGNAL // Whether to print complete signals and sequence bits (SCAN for bits)
#define DEBUG_PRINT_PARTIAL_SIGNAL // Whether to also print incomplete signals over a certain length.
// Note that this sequence is set by the main unit, and will change if it is reset.
// Do a SCAN operation to find them, then configure them here.
const uint32_t SEQUENCE_HIGHBITS = 0x5AAA,
SEQUENCE_LOWBITS = 0xA965A600;
// MQTT broker information (IP address, port number and top topic)
uint8_t BROKER_IP[] = { 10,21,1,6 };
uint16_t BROKER_PORT = 1883;
const char *ROOT_TOPIC = "origo";
// WiFi network to connect to
const char* WIFI_SSID = "smateknik24g";
const char* WIFI_PASSWORD = "xxxx";
// Digital input pin where SRX882 is connected
const uint8_t PIN_RADIORECEIVER = D2;
// Timesync server address
const char *TIMESYNC_SERVER = "time.cloudflare.com";
OrigoMqtt.ino untouched,
`/*** This sketch will pick up alarms from Housegard Origo smoke detectors, and will
* publish these on a MQTT broker for other systems to pick up.
* Onboard LED will flash quickly for 10s after an alarm has been received.
*/
#include "UserValues.h"
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <OrigoSmokeDetector.h>
#include <ReconnectingMqttClient.h>
//************************** Time sync ******************************
WiFiUDP ntp_udp;
NTPClient time_client(ntp_udp, TIMESYNC_SERVER, 0, 600000);
void setup_timesync() {
time_client.begin();
time_client.forceUpdate();
}
//************************* MQTT *****************************
ReconnectingMqttClient mqtt(BROKER_IP, BROKER_PORT, ROOT_TOPIC);
void publish_alarm(uint8_t detector_id) {
String topic = String(ROOT_TOPIC) + "/alarm/" + String(detector_id),
payload = String(time_client.getEpochTime());
mqtt.publish(topic.c_str(), (uint8_t*) payload.c_str(), payload.length(), false, 1);
}
void publish_heartbeat() {
String topic = String(ROOT_TOPIC) + "/heartbeat", payload = String(time_client.getEpochTime());
mqtt.publish(topic.c_str(), (uint8_t*) payload.c_str(), payload.length(), false, 1);
}
void publish_startup() {
String topic = String(ROOT_TOPIC) + "/startup", payload = String(time_client.getEpochTime());
mqtt.publish(topic.c_str(), (uint8_t*) payload.c_str(), payload.length(), false, 1);
}
void setup_mqtt() { publish_startup(); }
void loop_mqtt() {
mqtt.update();
// Send heartbeat
static uint32_t last_heartbeat = 0;
if ((uint32_t)(millis() - last_heartbeat) >= 10000) {
last_heartbeat = millis();
publish_heartbeat();
}
}
//***************** Logging data from 433MHz radio receiver ********************
const uint16_t RADIO_LISTEN_TIME = 110; // ms, more than twice the sequence length from the Origo detectors
uint8_t detector_id = 0; // Set to non-zero when an alarm was received by the last listening
uint32_t detector_time = 0; // The time of the last alarm received, in ms. Set to 0 after some seconds.
OrigoSmokeDetectorListener listener(PIN_RADIORECEIVER, SEQUENCE_HIGHBITS, SEQUENCE_LOWBITS, RADIO_LISTEN_TIME);
void loop_origo() {
detector_id = listener.listen();
if (detector_id != 0) { publish_alarm(detector_id); detector_time = millis(); }
if ((uint32_t)(millis() - detector_time) > 10000) detector_time = 0;
}
//**************************** WiFi *******************************
void setup_wifi() {
WiFi.begin((char*) WIFI_SSID, (char*) WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
#ifdef DEBUG_PRINT
Serial.print(".");
#endif
}
#ifdef DEBUG_PRINT
Serial.printf("\nDHCP assigned IP is %s\n", WiFi.localIP().toString().c_str());
#endif
}
//**************************** LED ********************************
// On-board LED will flash quickly when an alarm has been received
const uint16_t FAST_BLINK = 100, SLOW_BLINK = 1000;
bool led_on = false;
uint16_t interval = SLOW_BLINK;
uint32_t changed = 0;
void setup_led() { pinMode(LED_BUILTIN, OUTPUT); }
void loop_led() {
interval = detector_time == 0 ? SLOW_BLINK : FAST_BLINK;
if ((uint32_t)(millis() - changed) > interval) {
changed = millis();
led_on = !led_on; // Invert state
digitalWrite(LED_BUILTIN, led_on ? HIGH : LOW);
}
}
//********************** Main program **********************
void setup() {
#ifdef DEBUG_PRINT
Serial.begin(115200);
Serial.println("OrigoMqtt starting");
#endif
setup_wifi();
setup_timesync();
setup_led();
listener.setup();
setup_mqtt();
}
void loop() {
time_client.update();
loop_origo();
loop_mqtt();
loop_led();
}
`
DEBUG_PRINT_PARTIAL_SIGNAL should be DEBUG_PRINT_PARTIAL_SIGNALS. Not sure if that will help, but if it prints nothing that may make it print something. With that defined it should print all sequences it picks up even if not having the expected signal bit count.
I see it is typed incorrectly in UserValues.h, I will fix that. Sorry.
Finally i got something :)
But still nothing useful, i cant get a complete sequence, something more must be done.
Mostly a match with the bits from the PulseView capture :-) Except for the first bit (1) and the last two bits (0). Does it print the same sequence every time?
Seems lite it doesn't hit it every time pressing button on the smoke alarm. Only random. test.zip attached an sequence from PulsView in the zip file
It pauses to listen for twice the duration of a signal, so it will often start in the middle of a signal, and this seems bad when printing partial signals, but should pick up one full signal each time it stops to listen when the detector is sending. The data in the zip is exactly like your screenshot further up, 10010110011010100110101001101001010101010101101000000.
The serial output wrote this sequence except that it missed the first 1 and the last two 0s. Is it consistent in printing this when printing a sequence of close to 51 bits?
Got something like this always,
Oh, one more thing, the led lights up on the ESP, like it detecting signals, but it does not print to the serial monitor
A consistent sequence that is 50 long, not 51 as the code expects. Do you have more smoke detectors paired to the same master? Could be interesting to capture and compare their signals to see if the first 8 bits are different but the rest the same.
I have 8th of them :) But I have one that I have removed the siren from. Have kid sleeping next door to my "homeoffice".
Haha, yes, not a task compatible with sleeping family. I used home-alone time for it :-) But it could be interesting to see a couple more of their signals to compare.
Can you try to set in UserValues.h SEQUENCE_HIGHBITS = 0x6A6A SEQUENCE_LOWBITS = 0xD2AAB400
And see if that changes anything? These should be the bits after the first 8 bits that is the device id. Could help with getting recognition started.
I have done a repair, took one more detector and removed the siren from now.
This is what i got
Included the whole PulseView, attached another RTX822 to it ;)
Same highbits and lowbits as in the first detector! Promising. 0110101001101010 01101001010101010101101000
and still nog working,
If I pad the lowbits to 32 bits I get hex 0x69555A00, I guess that is correct. Forgot to pad in the first case.
nothing;
did run an pulseview in parallell, got exactly this everytime pressing the button om the detector x8
const uint32_t SEQUENCE_HIGHBITS = 0x6A6A, SEQUENCE_LOWBITS = 0x69555A00;
I will have to take a look at the conversion to hex to see if there is a reversal of bit order or something like that. Its been a while since I wrote the code so I do not remember all details:-) Will see if I can pick up the thread tomorrow evening, I have to call it a day now, busy tomorrow. Good night.
Good night, and once again, thanks for everything today!
Tried everything but nothing will output on D5 for me. Using an ESP8266 Nodemcu V3 but tried with an D1 mini pro to. Same result.
Do you have some tip where to start searching for faults? I even tried to steel one of the radios from one smoke detector to use as receiver. Nothing.