Example uses a shelly sensor, which has a offset mode in its new firmware. So below is not needed any more. But the example can be used for any calibration/adjustments.
I’ve put two examples in the NodeRed function
First the solution
var temperature=msg.payload.tC;
var humidity=msg.payload.tF;
// calc new offset example
// simple offset + 2.3 off real measurement
msg.payload.tC=temperature + 2.3;
// more complex example
// take two measurements (with a big difference)
msg.payload.tF=1.11 * (humidity - 1);
return msg;
First adjustment is plus or minus a value. Second is more precise when the temperature needs more adjusting
Dots on the red line are measured values Blue is how it should be
So measured was 2.8 but should be 2 And measured 14.5 but needs to be 15
slope = (14.5-2.8)/(15-2) = 0.9
To get the multiplication factor = 1/0.9 = 1.1111
=(2.8-heightadjust)*1,1111 should give us 2
2/1.1111 = 2.8 – heightadjust
1.8 = 2.8 – heightadjust = 1
So the formula is realhumid = 1,1111 * ( measuredhumid – adjust )
Under hardware in domoticz install the mqtt broker. Configure your mqtt server (mine is mosquitto) Add devices to floorplans to send these to Mosquitto
Now i can see the topics in MQTTExplorer
Install the home assistant websocket palette in NodeRed
Configure the nodes like above
These are some example flows (I’ll put the function code below)
Above are the NAMED entities in Home Assistant
CODE
//Code for NR temperature filtering on domoticz IDX
//A door censor uses nvalue instead of svalue1
//Humidity can be svalue2
//Check the Mqtt payload in MQTTExplorer which to use!
var varidx = msg.payload.idx;
var varnvalue = msg.payload.svalue1;
if(varidx == 3108)
{
msg.payload = {};
msg.payload = varnvalue;
return msg;
}
Example of the trigger node. When a temperature sensor battery dies, and no new data arrives- in 1 hour, I get a pushover warning. (use pushbullet/email/TV notification whatever you want)
Our bedroom has a shelly dimmer, this one is connected with a wall switch and is being controlled by Domoticz, Home Assistant and NodeRed.
I had to fix some stuff, so this was a perfect time to jot down some notes.
I’ve wired it up like this: (I’ve got a Line wire in my ceiling socket, so i placed the module there instead of the wall socket)
Configure the Shelly as mentioned in the manual. After that do the following: Advance > Developer settings : (Enable CoIot if you want a easy auto detect for Home Assistant) Enable MQTT (This will DISABLE cloud ! ) Server: the ip number of your Mqtt Broker
Next I did was:
Now the wall switch will change/toggle what the current state is. (If the light is off, and you switch it on using Mqtt, you probably needed to hit the switch two times to turn it off again. Not so with this setting.)
My Nodered Flow ( Not using the Shelly palette nodes in this example)
The Mqtt IN node sets the state of the switch when you use the wall switch! Cozy turns light on at a specific level. The slider send an off command when 0% selected, else an on command and the sliders value.
A ledstrip on a Harp, now I can see the strings at night!
Woohoo .. ( Little harp in the background (autoharp))
Well .. its a pity that the distance of the leds is NOT the same as the strings distance.
I could light up the string to be played, or even cooler … When using FFT code (Fast Fourier Transform), I could light up the string being played! I’m probably going to try to implement this at a later time.
But I didn’t like the continuous logins with automated logins.
So below solution is what i’ve implemented for now.
I’ve installed the IOT extra package from Mikrotik, now I can send MQTT messages from my Wifi enabled Mikrotiks to my Mosquitto broker. (Download extra package zip, extract iot-7.x-arm.npk, upload this to your mikrotik files folder, and reboot) The script I’m running on my Mikrotik, sends the active wifi connections with the comments. ( When a comment is set in the Access List, then it’s a know connection )
[admin@RB40111] /iot/mqtt> export
# may/15/2023 21:45:12 by RouterOS 7.9
# software id = xxxx-xxxx
#
# model = RB4011iGS+5HacQ2HnD
# serial number = xxxxxxxxxxxxxxxxx
/iot mqtt brokers
add address=10.1.x.y client-id=rb4011 name=NR
I made the following script on my MT named mqtt
:local broker "NR"
# MQTT topic where the message should be published
:local topic "rb4011/mac"
:foreach i in=[/interface wireless registration-table print proplist=mac-address as-value] do={
:local message "$i"
/iot mqtt publish broker=$broker topic=$topic message=$message
}
A schedule is needed to run this script every 15 minutes
[admin@RB40111] /system/scheduler> export
# may/15/2023 21:48:14 by RouterOS 7.9
# software id = xxxx-xxx
#
# model = RB4011iGS+5HacQ2HnD
# serial number = xxxxxxxxxxx
/system scheduler
add interval=15m name=mqtt on-event=mqtt policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=may/15/2023 start-time=13:30:54
Now all wifi connections will be send to topic rb4011/mac.
# Example
.id=*6a;comment=Mobile Henri wlan2;mac-address=44:46:87:xx:xx:xx
Using NodeRed I can make filters and notifications
Below function: get Mac and Comment from payload, if the comment is empty then it is a unknown connection … so send me a warning using Pushover.
// filter function
var output = msg.payload.split(";");
var comment = (output[1].split("="));
var mac = (output[2].split("="));
msg.payload={};
msg.payload = mac[1];
if (comment[1] == "") {
return msg;
}
// is xx:xx:xx:xx:xx:xx online? example
var output = msg.payload.split(";");
var comment = (output[1].split("="));
var mac = (output[2].split("="));
msg.payload={};
msg.payload = mac[1];
if (mac[1] == "xx:xx:xx:xx:xx:xx") {
return msg;
}
Now i’m getting a notification when an unknown wifi connection is made on my Access Point. ( I going to implement the Access List from MT at a later point. No access when not in the Access List)
Sometimes you forget you ordered something from Ali Express, it takes too long to arrive.
Today i’ve got this in my mailbox
These are HLK-LD2401B motion/presence detectors € 2,91 a piece.
While PIR sensors are slow and doing only motion sensing, these nice small and cheap devices are fast and have more outputs.
Bluetooth (can be used using home assistant integration)
Motion and presence
60 degrees detection angle
Measurements to moving/static objects (while the datasheet mentions till 5 meter, i’ve got measurements well above that.
Fast updates, and i mean really fast
Only 7mm x 35mm
mmWave – 24GHz
GPIO Uart
According to the bad translation it can also measure if you ‘devour’ something. Dutch ‘vreten’ means wild fast eating something. Setting the language to English gives me the word ‘fretting’
Right screenshot shows Coline sitting at a distance of 5.5 meters
Above, the update speed in HA
To try: connect Uart to remote ESP and tweaking the device https://www.youtube.com/watch?v=dAzHXpP3FcI and distance gates
Maybe i can use some Triangulation go find the precise location of a person.
While doing stuff like, making our home a little greener. Smoking meat. Working on diorama’s and my Escape game. I found time to make this little maze game.
Using an ESP32, mini joystick and a 8×8 led matrix. The objective is to get to the other side of the invisible maze.
It is a blind maze, so you have to figure out the path by trail and error. I found it quite fun and entertaining. (Coline had a hard time finishing the mode 3 maze)
I’ve got 3 settings on the maze: 0 – There is a trail where you have been. 1 – No trail, but only red leds showing walls. 2 – No trail, red reds and a reset to square 0,0 .. so you have to remember the path you previously took.
I’ll add code and schematics tomorrow …
Light blue shows you where you have been
Mode 2 game, reset when hitting a wall
Hitting the end block!
Maze is static at the moment, i’m planning to implement a “Recursive division method” to generate the maze.
Code
#include <Arduino.h>
#include <Adafruit_NeoPixel.h>
// joystick pins
int up=33;
int down=25;
int left=32;
int right=26;
int cursor=32;
// 0 easy = trail // 1 only red walls // 2 = reset to 0.0
int mode=2;
//int trail=32;
int trail=0;
// Which pin on the Arduino is connected to the NeoPixels?
#define LED_PIN 2
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 64
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// bits set opening in square
// 2
// -----
// 1 | | 4
// -----
// 0
// so 5 is a passage from left to right (1+4)
int maze[8][8] = {
4,5,3,6,5,5,5,3,
6,5,11,12,5,3,6,9,
14,1,12,5,3,10,12,1,
12,5,5,3,10,12,5,3,
2,6,5,9,14,5,1,10,
10,10,6,5,9,6,5,9,
12,11,10,6,1,10,6,1,
4,9,12,13,5,13,13,1,
};
int displaymatrix[8][8] = {
{ 0,1,2,3,4,5,6,7 },
{ 15,14,13,12,11,10,9,8 },
{16,17,18,19,20,21,22,23},
{31,30,29,28,27,26,25,24},
{32,33,34,35,36,37,38,39},
{47,46,45,44,43,42,41,40},
{48,49,50,51,52,53,54,55},
{63,62,61,60,59,58,57,56}
};
int x = 0;
int y = 0;
void setup() {
// joy
pinMode(32, INPUT_PULLUP);
pinMode(33, INPUT_PULLUP);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
// mode set with jumpers
pinMode(34, INPUT_PULLUP);
pinMode(35, INPUT_PULLUP);
Serial.begin(115200);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(10);
// set begin and end pixel
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);
strip.show();
//mode select
if (digitalRead(34) == 0) {
mode=0;
if (digitalRead(35) == 0) {
mode=2;
} else {
mode=1;
}
// finish effect
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
// reset to start (mode 2)
void reset2start() {
strip.setPixelColor(displaymatrix[x][y], 0, 0, 0);
strip.show();
x = 0;
y = 0;
strip.begin();
strip.show(); // Initialize all pixels to 'off'
strip.setBrightness(10);
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.setPixelColor(displaymatrix[7][7], 0, 255, 0);
strip.show();
}
// finish effect
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
void loop() {
int isUp = (bitRead(maze[x][y], 1));
int isRight = (bitRead(maze[x][y], 2));
int isDown = (bitRead(maze[x][y], 3));
int isLeft = (bitRead(maze[x][y], 0));
if (digitalRead(up) == 0) {
if (isUp == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
x++;
if ( x > 7) { x=7;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(down) == 0) {
if (isDown == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
x--;
if ( x < 0) { x=0;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(left) == 0) {
if (isLeft == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
y--;
if ( y < 0) { y=0;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (digitalRead(right) == 0) {
if (isRight == 1){
strip.setPixelColor(displaymatrix[x][y], 0, 0, trail);
y++;
if ( y > 7) { y=7;}
strip.setPixelColor(displaymatrix[x][y], 0, 0, 255);
strip.show();
} else {
strip.setPixelColor(displaymatrix[x][y], 255, 0, 0);
strip.show();
if (mode == 2){
delay(1000);
reset2start();
}
}
}
if (x ==7 && y == 7){
strip.begin();
strip.show(); // Initialize all pixels to 'off'
rainbow(20);
}
delay(200);
}
"If something is worth doing, it's worth overdoing."