@hard-shovel said in Water Sensor:
typical types are H11AA1 or LTV814 etc
Thank you! Seems like the best way to for me than. Will order and wait for them to arrive
@hard-shovel said in Water Sensor:
typical types are H11AA1 or LTV814 etc
Thank you! Seems like the best way to for me than. Will order and wait for them to arrive
@hard-shovel said in Water Sensor:
Your diagram is reversed as you need to drive the led in the optocoupler from the relay coil connections.
Your ingenious scheme worked like a charm. Thank you!
Don't want to push but in such a rare possibility when you have access to such a marvelous help...
The fan is of asynchronous type with 3 wires (neutral and 2 speeds). Currently i have just connected the output for speed1 to relay NC contact and speed2 to fan to NO contact. So it looks like this.
With such connection i still have the manual switch to off - 1st speed. But with such connection i cannot use manual switch on humidifier to choose the second switch. I have already use a multi meter to find out contacts
i was thinking of making my sensors node completely parallel to the board and use 4n35 to sense 220V AC on different rotary switch positions and drive relays appropriately. All the schematics i found on the web use bridge rectifier. Wonder if there is any way to go without one - and if not - what to order from aliexpress?
@neverdie Do o really need the TLP222A as i already have 4N35 lying around
@hard-shovel said in Water Sensor:
If you have the arduino analogue pin connected to Pin3, where do you have the arduino GND connected?
Well actually nowhere Thought that as the analogue pin is pulled to ground that will suffice.
Was happy at first but still seems the readings are erratic. So will follow your great advice with the optocoupler.
Do i get the connection scheme correctly?
Ok took the measurements once again on the led. This time measuriong only LED pins and not the live neutral wire. Between 1 and 3 gave me 0,1AC and 1,8DC when red and 0,1AC and 0,1DC when green. So just connected the anlogue pin of arduino to pin3 of LED and it works. Readings 19-70 when red led turned on. And 0-3 when off.
Just wonder how this led works from AC and is it still a good advice to put optocoupler into it?
@hard-shovel said in Water Sensor:
Wow! Thank you! You just made a lot of stuff clear.
On the upper left part of the pannel - is actually a status LED. Which turns red when no water detected and green when it is. So i believe i should just dump the idea of getting anything from the water sensor and turn my view on the LED? This is the backside of the board.
AC is totally confusing me. Especially the LED part. When trying to measure ac voltage with my multimeter i have seen something like 30V between the live neutral and one of the LED legs. So any recommendation is very appreciated
Nope. Will it help in any way?
The chip on the original circuit reads HEF4093BT
I have an Electrolux air washer which i decided to convert to a smart one. So i have already added necessary relays and can control fan speed and power... One thing left. It has a water control built in. I want to keep the original functionality of the board so i need to connect to the water sensor in parallel.
This water control consists of two metal pieces submerged in water. And 2 wires going to the control board (from now on let's call them water wires)
I have taken the pic of the board and highlighted the part where this water wires connect. This circuit is driven by a 9V ac-ac transformer. Multimeter shows around 1,5-3V of AC current on the metal plates.
So going the easy way i've just connected to the metal plates +3,3V from arduino and then to the analog pin (pulled to ground via 10k). Actually it almost worked. Had reading of around 158 when water present and 60 when not.
But i lost the functionality of the control board. With +3,3V from arduino connected it always "detected" water even when there was none. (i have tried switching sides with no luck).
So i removed the 3,3V from arduino and just left the analogue pin connected to one of the metal plates. This gives me fluctuation reading from 2 to 30.
So i wonder what is the correct way to go?
Thanks. Will await eagerly for v1.8 as it seems this is the only great RGB code left for mysensors
Need a node with a button input (doesn't do anything to relay state) and a single relay. As this is connected to Home Assistant have to provide feedback and present the relay.
The problem is with the code below it just starts sending the relay state in a loop without stopping.
mys-out/67/1/1/0/2 1
Tried everything and seems got stuck somewhere
#define SN "MYS Vannaya Gidro"
#define SV "2.1.1"
//System settings
#define MY_NODE_ID 67
#define MY_RADIO_NRF24
#define MY_DEBUG
#include <Bounce2.h>
#include <math.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
//SETUP PINS
#define BUTTON_PIN1 7
const int MQ_Pin = A3;
#define RELAY_1 5
//Define CHILD_IDS
#define CHILD_ID_RELAY 1
#define CHILD_ID_BUT1 2
#define CHILD_ID_MQ 3
//Relay VARS
#define RELAY_ON 1
#define RELAY_OFF 0
//SENSORS
long SENSOR_Millis = 0;
long SENSOR_interval = 60000;
//Buttons
Bounce debouncer1 = Bounce();
int oldValue1=-1;
bool state;
//Messages
MyMessage msgRelay(CHILD_ID_RELAY, V_STATUS);
MyMessage msgMQ(CHILD_ID_MQ, V_LEVEL);
MyMessage msgBut1(CHILD_ID_BUT1,V_TRIPPED);
//Initial for HA
bool initialValueSent = false;
void before()
{
pinMode(BUTTON_PIN1, INPUT_PULLUP);
debouncer1.attach(BUTTON_PIN1);
debouncer1.interval(5);
pinMode(RELAY_1, OUTPUT);
digitalWrite(RELAY_1, loadState(1)?RELAY_ON:RELAY_OFF);
}
void setup()
{ Serial.begin(115200); }
void presentation()
{
sendSketchInfo(SN, SV);
wait(50);
present(CHILD_ID_RELAY, S_BINARY);
wait(50);
present(CHILD_ID_MQ, S_AIR_QUALITY);
wait(50);
present(CHILD_ID_BUT1, S_WATER_LEAK);
}
void loop()
{
if (!initialValueSent)
{
send(msgRelay.set(loadState(1)?RELAY_OFF:RELAY_ON));
}
unsigned long SENSOR_Current_Millis = millis();
if((unsigned long)(SENSOR_Current_Millis - SENSOR_Millis) >= SENSOR_interval)
{
SENSOR_Millis = SENSOR_Current_Millis;
float mq_reading = analogRead(MQ_Pin);
send(msgMQ.set(mq_reading, 1));
}
debouncer1.update();
int value = debouncer1.read();
if (value != oldValue1)
{
// Send in the new value
send(msgBut1.set(value==HIGH ? 1 : 0));
oldValue1 = value;
}
}
void receive(const MyMessage &message)
{
if (message.type==V_STATUS)
{
if (!initialValueSent)
{
initialValueSent = true;
}
// Update relay state to HA
state = message.getBool();
digitalWrite(RELAY_1, state?RELAY_ON:RELAY_OFF);
saveState(CHILD_ID_RELAY, state);
send(msgRelay.set(state?RELAY_ON:RELAY_OFF));
}
}
@bjacobse There is nothing difficult in setting it up. Just connect the irda to the 3rd PWM leg
ESP is the best solution although couldn't find the code with sensors (only clean/dock commands). I recently made a post on HomeAssistant forum - how wemos D1 fits nicely inside. You only need a buck converter and 4 cat5 wires soldered. And 5V serial output is not such a big problem as you need a voltage divider only on rx pin (didn't put it)
P.S. But then one of those "machine revolt weeks happened" so my esproomba didn't respond and then i burned it down. Next day my RPi3 went down with HA and lots of goodies. And today ESXi...
@jkandasa Thank you!
One more question. Now need to use a 3,3V arduino Pro (chinese version) (Nano and 5V version flashed via the uno without a hitch)
This is what i put into boards.txt The MYSBootloader_8Mhz.hex is from the dev branch
proMYSBL8.name=ATmega328 8Mhz MYSBootloader
proMYSBL8.name=ATmega328 internal 8Mhz with MYSBootloader
proMYSBL8.upload.tool=avrdude
proMYSBL8.upload.protocol=arduino
proMYSBL8.upload.maximum_size=30720
proMYSBL8.upload.maximum_data_size=2048
proMYSBL8.upload.speed=57600
proMYSBL8.bootloader.tool=avrdude
proMYSBL8.bootloader.low_fuses=0xE2
proMYSBL8.bootloader.high_fuses=0xDA
proMYSBL8.bootloader.extended_fuses=0x06
proMYSBL8.bootloader.unlock_bits=0x3F
proMYSBL8.bootloader.lock_bits=0xFF
proMYSBL8.bootloader.file=MySensors/MYSBootloader_8Mhz.hex
proMYSBL8.build.mcu=atmega328p
proMYSBL8.build.f_cpu=8000000L
proMYSBL8.build.board=AVR_UNO
proMYSBL8.build.core=arduino
proMYSBL8.build.variant=standard
Tried to flash the mysbootloader but get the following error
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM7 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x06:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM7
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.03s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x06"
avrdude: writing efuse (1 bytes):
Writing | ***failed;
################################################## | 100% 0.07s
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x06:
avrdude: load data efuse data from input file 0x06:
avrdude: input file 0x06 contains 1 bytes
avrdude: reading on-chip efuse data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: WARNING: invalid value for unused bits in fuse "efuse", should be set to 1 according to datasheet
This behaviour is deprecated and will result in an error in future version
You probably want to use 0xfe instead of 0x06 (double check with your datasheet first).
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xDA"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xDA:
avrdude: load data hfuse data from input file 0xDA:
avrdude: input file 0xDA contains 1 bytes
avrdude: reading on-chip hfuse data:
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM7 -b19200 -Uflash:w:C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/MySensors/MYSBootloader_8Mhz.hex:i -Ulock:w:0xFF:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Reading | ################################################## | 100% 0.01s
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
avrdude: reading input file "0xE2"
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.01s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xE2:
avrdude: load data lfuse data from input file 0xE2:
avrdude: input file 0xE2 contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude done. Thank you.
Using Port : COM7
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/MySensors/MYSBootloader_8Mhz.hex"
avrdude: writing flash (32754 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 32754 bytes of flash written
avrdude: verifying flash memory against C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/MySensors/MYSBootloader_8Mhz.hex:
avrdude: load data flash data from input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/MySensors/MYSBootloader_8Mhz.hex:
avrdude: input file C:\Program Files (x86)\Arduino\hardware\arduino\avr/bootloaders/MySensors/MYSBootloader_8Mhz.hex contains 32754 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x7800
0x00 != 0x11
avrdude: verification error; content mismatch
avrdude done. Thank you.
Error while burning bootloader.
@parachutesj Mind posting your finished code?
Also wonder what is the correct MQTT payload to start for example cleaning?
Upon start i see the following
mys-out/15/255/3/0/11 MYS Roomba
mys-out/15/255/3/0/12 2.1
mys-out/15/0/0/0/3 Roomba-Stop
mys-out/15/1/0/0/3 Roomba-Dock
mys-out/15/2/0/0/3 Roomba-Clean
mys-out/15/3/0/0/3 Roomba-Spot
mys-out/15/4/0/0/3 Roomba-Max
mys-out/15/5/0/0/3 Roomba-Power
mys-out/15/6/0/0/3 Roomba-Play
mys-out/15/100/0/0/6 Roomba-Batt-Temp
mys-out/15/101/0/0/39 Roomba-Batt-Proc
mys-out/15/102/0/0/30 Roomba-Batt-Volt
mys-out/15/103/0/0/30 Roomba-Batt-mAH
mys-out/15/104/0/0/36 Roomba-Batt-CHt
mys-out/15/105/0/0/36 Roomba-Batt-CHs
But publishing to
mys-in/15/2/1/0/3
mys-in/15/2/1/0/2
with payload 1 doesn't do anything
@gohan So is it first reboot. Or start flashing - reboot?
Well after much trial and error - seems that pin5 is behaving erratically. Don't know why. Rewired to an external dimmer board. Changed arduinos. Nothing helps which is extremly strange
No it's powered off mains so no sleep functions added
Nano also doesn't need any fuses. So everything works. Except to begin the flash procedure i have to unplug and plug the node. Is this intended behaviour? Otherwise i only see in MQTT one line of code and no response from node
@BulldogLowell Read about them. But still seems i address the array correctly. Or i'm wrong?
Had a code which was working for a long time. Decided to add another dimmer. And now having hard time. Seems to work light switches on - then never goes off. One dimmer is on 100% of the time. Any help much appreciated. Added comments on changed lines //ADDED
Guess screwed up with currentLevel but not sure
#define SN "MYS Kitchen Hood"
#define SV "2.1"
//System settings
#define MY_RADIO_NRF24
#define MY_RF24_CE_PIN 8 //ADDED
// Include all the libraries
#include <MySensors.h>
#include <SPI.h>
#include <DHT.h>
#include <math.h>
#include <Wire.h>
#include <Bounce2.h>
#define MY_NODE_ID 71
//DEFINE CHILD_IDS
#define DIMMER_NODE_1 0
#define DIMMER_NODE_2 1
#define DIMMER_NODE_3 2
#define DIMMER_NODE_4 3 //ADDED
#define CHILD_ID_HUM 4
#define CHILD_ID_TEMP 5
#define CHILD_ID_MQ 6
#define CHILD_BUT1 7
#define CHILD_BUT2 8
#define CHILD_BUT3 9
#define CHILD_BUT4 10
//BUTTONS
#define BUTTON_PIN1 A0
#define BUTTON_PIN2 A1
#define BUTTON_PIN3 A2
#define BUTTON_PIN4 A3
//SENSORS
#define DHT_PIN 8
const int MQ_Pin = A4;
//DIMMER
#define LED_PIN_1 3
#define LED_PIN_2 5
#define LED_PIN_3 6
#define LED_PIN_4 9 //ADDED
#define FADE_DELAY 5
DHT dht;
//BUTTONS
Bounce debouncer_1 = Bounce();
Bounce debouncer_2 = Bounce();
Bounce debouncer_3 = Bounce();
Bounce debouncer_4 = Bounce();
int oldValue_1=-1;
int oldValue_2=-1;
int oldValue_3=-1;
int oldValue_4=-1;
bool state1;
bool state2;
bool state3;
bool state4;
MyMessage msgbut1(CHILD_BUT1,V_STATUS);
MyMessage msgbut2(CHILD_BUT2,V_STATUS);
MyMessage msgbut3(CHILD_BUT3,V_STATUS);
MyMessage msgbut4(CHILD_BUT4,V_STATUS);
//SENSORS
float lastTemp;
float lastHum;
float hum_floa;
float last_mq_reading;
long Millis = 0;
long Millis_interval = 30000;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgMQ(CHILD_ID_MQ, V_LEVEL);
//DIMMER
//byte currentLevel[3] = {0,0,0};
byte currentLevel[4] = {0,0,0,0}; //added
MyMessage dimmerMsg0(0, V_PERCENTAGE);
MyMessage lightMsg0(0, V_STATUS);
MyMessage dimmerMsg1(1, V_PERCENTAGE);
MyMessage lightMsg1(1, V_STATUS);
MyMessage dimmerMsg2(2, V_PERCENTAGE);
MyMessage lightMsg2(2, V_STATUS);
MyMessage dimmerMsg3(3, V_PERCENTAGE); //ADDED
MyMessage lightMsg2(3, V_STATUS); //ADDED
void before()
{
dht.setup(DHT_PIN);
analogWrite( LED_PIN_1, 0);
analogWrite( LED_PIN_2, 0);
analogWrite( LED_PIN_3, 0);
analogWrite( LED_PIN_4, 0); //ADDED
pinMode(BUTTON_PIN1,INPUT);
digitalWrite(BUTTON_PIN1, HIGH);
pinMode(BUTTON_PIN2,INPUT);
digitalWrite(BUTTON_PIN2, HIGH);
pinMode(BUTTON_PIN3,INPUT);
digitalWrite(BUTTON_PIN3, HIGH);
pinMode(BUTTON_PIN4,INPUT);
digitalWrite(BUTTON_PIN4, HIGH);
debouncer_1.attach(BUTTON_PIN1);
debouncer_1.interval(5);
debouncer_2.attach(BUTTON_PIN2);
debouncer_2.interval(5);
debouncer_3.attach(BUTTON_PIN3);
debouncer_3.interval(5);
debouncer_4.attach(BUTTON_PIN4);
debouncer_4.interval(5);
}
void setup()
{ }
void presentation()
{
sendSketchInfo(SN, SV);
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
present(CHILD_ID_MQ, S_AIR_QUALITY);
present( DIMMER_NODE_1, S_DIMMER );
send(dimmerMsg0.set(0));
present( DIMMER_NODE_2, S_DIMMER );
send(dimmerMsg1.set(0));
present( DIMMER_NODE_3, S_DIMMER );
send(dimmerMsg2.set(0));
present( DIMMER_NODE_4, S_DIMMER ); //ADDED
send(dimmerMsg3.set(0)); //ADDED
present(CHILD_BUT1, S_BINARY);
present(CHILD_BUT2, S_BINARY);
present(CHILD_BUT3, S_BINARY);
present(CHILD_BUT4, S_BINARY);
}
void loop()
{
int value_but_1 = debouncer_1.read();
int value_but_2 = debouncer_2.read();
int value_but_3 = debouncer_3.read();
int value_but_4 = debouncer_4.read();
//DHT+MQ
unsigned long Current_Millis = millis();
if((unsigned long)(Current_Millis - Millis) >= Millis_interval)
{
Millis = Current_Millis;
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
float humidity = dht.getHumidity();
float mq_reading = analogRead(MQ_Pin);
if (isnan(temperature))
{Serial.println("Failed reading temperature from DHT");}
if (isnan(humidity))
{Serial.println("Failed reading humidity from DHT");}
if (isnan(mq_reading))
{ Serial.println("Failed mq_reading"); }
else
{
send(msgTemp.set(temperature, 1));
send(msgHum.set(humidity, 1));
send(msgMQ.set(mq_reading, 1));
}
}
//BUTTONS
debouncer_1.update();
if (value_but_1 != oldValue_1)
{
if ( value_but_1==0)
{
state1 = !state1;
send(msgbut1.set(state1));
}
oldValue_1 = value_but_1;
}
debouncer_2.update();
if (value_but_2 != oldValue_2)
{
if ( value_but_2==0)
{
state2 = !state2;
send(msgbut2.set(state2));
}
oldValue_2 = value_but_2;
}
debouncer_3.update();
if (value_but_3 != oldValue_3)
{
if ( value_but_3==0)
{
state3 = !state3;
send(msgbut3.set(state3));
}
oldValue_3 = value_but_3;
}
debouncer_4.update();
if (value_but_4 != oldValue_4)
{
if ( value_but_4==0)
{
state4 = !state4;
send(msgbut4.set(state4));
}
oldValue_4 = value_but_4;
}
}
//DIMMER
void receive(const MyMessage &message)
{
if (message.type == V_STATUS || message.type == V_PERCENTAGE)
{
int requestedLevel = atoi( message.data );
requestedLevel *= ( message.type == V_STATUS ? 100 : 1 );
requestedLevel = requestedLevel > 100 ? 100 : requestedLevel;
requestedLevel = requestedLevel < 0 ? 0 : requestedLevel;
fadeToLevel( requestedLevel, message.sensor);
switch(message.sensor)
{
case 0:
send(lightMsg0.set(currentLevel[0] > 0 ? 1 : 0));
send( dimmerMsg0.set(currentLevel[0]) );
break;
case 1:
send(lightMsg1.set(currentLevel[1] > 0 ? 1 : 0));
send( dimmerMsg1.set(currentLevel[1]) );
break;
case 2:
send(lightMsg2.set(currentLevel[2] > 0 ? 1 : 0));
send( dimmerMsg2.set(currentLevel[2]) );
break;
//ADDED CASE 3
case 3:
send(lightMsg3.set(currentLevel[3] > 0 ? 1 : 0));
send( dimmerMsg3.set(currentLevel[3]) );
break;
}
}
}
void fadeToLevel( int toLevel, byte sensorId )
{
int delta = ( toLevel - currentLevel[sensorId] ) < 0 ? -1 : 1;
while ( currentLevel[sensorId] != toLevel )
{
currentLevel[sensorId] += delta;
switch(sensorId)
{
case 0:
analogWrite( LED_PIN_1, (int)(currentLevel[sensorId] / 100. * 255) );
break;
case 1:
analogWrite( LED_PIN_2, (int)(currentLevel[sensorId] / 100. * 255) );
break;
case 2:
analogWrite( LED_PIN_3, (int)(currentLevel[sensorId] / 100. * 255) );
break;
//ADDED CASE3
case 3:
analogWrite( LED_PIN_4, (int)(currentLevel[sensorId] / 100. * 255) );
break;
}
delay( FADE_DELAY );
}
}
After some investigating it wasn't a timer issue but a range issue with a node (it was hard to figure out). So went ahead and built another node with your code. But being lazy - just bought an rgb strip drive from aliexpress (too much soldering of mosfets for me).
It uses some RGBdriver.h library https://github.com/letsgoING/Libraries/tree/master/LEDStripDriver
fe
All i had to change was
void set_rgb(int r, int g, int b) {
Driver.begin();
Driver.SetColor(r, g, b);
Driver.end();
}
And it worked. Except that fading/RELAX don't work out for me. Instead just get a flashing of white light. So i thought you might know some other parts must be adjusted as my arduino knowledge is not there yer
Ok this is the part of sketch in question.
You can see there are two functions in the end
sendHeatpumpCommand();
sendNewStateToGateway();
They only concern HVAC and send an update to the AC. But they get called each time i change for example brightness for the RGB strip
void receive(const MyMessage &message) {
if (message.isAck()) {
Serial.println("This is an ack from gateway");
//return;
}
Serial.print("Incoming message for: ");
Serial.print(message.sensor);
int val; //RGB VAR
String recvData = message.data;
recvData.trim();
Serial.print(", New status: ");
Serial.println(recvData);
switch (message.type)
{
case V_HVAC_SPEED:
Serial.println("V_HVAC_SPEED");
if(recvData.equalsIgnoreCase("auto"))
{
FAN_STATE = 0;
HA_FAN_STATE = "Auto";
}
else if(recvData.equalsIgnoreCase("min"))
{
FAN_STATE = 1;
HA_FAN_STATE = "Min";
}
else if(recvData.equalsIgnoreCase("normal"))
{
FAN_STATE = 2;
HA_FAN_STATE = "Normal";
}
else if(recvData.equalsIgnoreCase("max"))
{
FAN_STATE = 3;
HA_FAN_STATE = "Max";
}
break;
case V_HVAC_SETPOINT_COOL:
Serial.println("V_HVAC_SETPOINT_COOL");
TEMP_STATE = message.getFloat();
Serial.println(TEMP_STATE);
break;
case V_HVAC_FLOW_STATE:
Serial.println("V_HVAC_FLOW_STATE");
if (recvData.equalsIgnoreCase("coolon"))
{
POWER_STATE = 1;
MODE_STATE = MODE_COOL;
HA_MODE_STATE = "CoolOn";
}
else if (recvData.equalsIgnoreCase("heaton"))
{
POWER_STATE = 1;
MODE_STATE = MODE_HEAT;
HA_MODE_STATE = "HeatOn";
}
else if (recvData.equalsIgnoreCase("autochangeover"))
{
POWER_STATE = 1;
MODE_STATE = MODE_AUTO;
HA_MODE_STATE = "AutoChangeOver";
}
else if (recvData.equalsIgnoreCase("off"))
{
POWER_STATE = 0;
HA_MODE_STATE = "Off";
}
initialValueSent = true;
break;
case V_RGB:
{
Serial.println( "V_RGB command: " );
Serial.println(message.data);
long number = (long) strtol( message.data, NULL, 16);
// Save old value
strcpy(rgbstring, message.data);
// Split it up into r, g, b values
red = number >> 16;
green = number >> 8 & 0xFF;
blue = number & 0xFF;
send_status();
set_hw_status();
}
break;
case V_LIGHT:
{
Serial.println( "V_LIGHT command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val == 0 or val == 1)
{
on_off_status = val;
send_status();
set_hw_status();
}
}
break;
case V_DIMMER:
{
Serial.print( "V_DIMMER command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <=100)
{
dimmerlevel = val;
send_status();
set_hw_status();
}
}
break;
case V_VAR1:
{
Serial.print( "V_VAR1 command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <= 2000)
{
fadespeed = val;
}
}
break;
}
sendHeatpumpCommand();
sendNewStateToGateway();
}
Yes thank you for the tip! Mycontroller works.
For Mini Pro - no fuses are needed. Just download the hex - rename and flash.
What about the nano?
Looking at boards.txt i see only two difeerences
Nano
nano.menu.cpu.atmega328.bootloader.low_fuses=0xFF
nano.menu.cpu.atmega328.bootloader.extended_fuses=0xFD
Mys
proMYSBL.bootloader.low_fuses=0xF7
proMYSBL.bootloader.extended_fuses=0x06
But at the same time PRO mini is same as nano... So can also flash straight away?
Just a remark. Got yur sketch. But it wasn't working. It can be easily fixed with adding a pin output statement
void setup()
{
pinMode(ILED, OUTPUT); //OTHERWISE AN INTERNAL PULL UP RESISTOR IS ACTIVE
digitalWrite(ILED, LOW); }
I have merged two sketches together.
The first one was on switches and the second one was if/else if
So the first sketch was something like
Switch
case1
case2
End switch
Sendcommand();
Send status();
And after moving in the second sketch it became
Switch
case1
case2
newcase3
newcase4
End switch
Sendcommand();
Send status();
So now - everytime i issue commands that satisfy newcase3 and 4 - these two functions get executed. So i wonder how i can git rid of that... Can i just move them to the end of switch1 and 2 code?
@gohan Excellent. Searched through the thread but couldn't find any mentions how it can be done via mqtt What about the fuses?
Really want to try FOTA with MYSBoatloader but a little bit confused. First - do i have to burn the fuses (i'm using a chinese arduino mini pro 16Mhz) or can simply download MYSBootloader_16MHz.hex from dev brach and i'm good to go?
Another thing - i'm using an MQTT gateway attached to RPi3. Don't really want to change the gateway type - so is there a way to do OTA update? I have a spare UNO which i can connect to a notebook.
@mfalkvidd Thank you! That solved everything. Well almost. At the end of the heatpump sensor there was a call to two functions
sendHeatpumpCommand();
sendNewStateToGateway();
After moving the RGB code to the case switch - everytime i change the RGB light the AC beeps as it receives the command. Is there an easy solution for this?
So nobody has done it yet? What about mosfets? Can the same schematics be used as with led strips? But how to limit the power fed to crees?
Well guess it was a bug. Removed some of the include libs. Deleted serial output and ... it worked. Now one more thing to solve but i guess that's another story
Built a node which would combine together a DHT22 + MQ2 + RGB LED Strip on mosfets + IR Aircond control.
Problem i am facing
SENSORS+ IR Aircond code works Github HVAC and Sensor
Comiled sketch size 16468 bytes
SENSORS+RGB code works Github RGB and Sensor
Comiled sketch size 18910 bytes
By working i mean i ran them for half an hour (this was to rule out my main problem of the board - power supply as it's a 7805 converter which is quite hot) and during these time i was sending commands (strip lit up or send aircond temp + fan speed e.t.c). DHT and MQ2 values were reported as they should - every 60 seconds.
But when i combine all the code together. Everything works - but only humidity is being reported for sensors every 60 seconds (no temperature from DHT22 or air quality from MQ2 are being reported). I have tried changing the code, different variation and all i could see that these values report "nan". Have already broke my head on this - so desperately need a helping hand.
This is the code combined. What can it be? Just a tiny extra load on the chip and more power drawn which sets 7805 mad? Or some incompatability in the code? Memory problems?
Sketch uses 18744 bytes (61%) of program storage space. Maximum is 30720 bytes.
Global variables use 1391 bytes (67%) of dynamic memory, leaving 657 bytes for local variables. Maximum is 2048 bytes.
Any push in the direction of fixing it up is much appreciated
#define SN "Bedroom"
#define SV "2.1"
/*
#define MODE_AUTO 1
#define MODE_HEAT 2
#define MODE_COOL 3
#define MODE_DRY 4
#define MODE_FAN 5
#define MODE_MAINT 6
#define FAN_AUTO 0
#define FAN_1 1
#define FAN_2 2
#define FAN_3 3
#define FAN_4 4
#define FAN_5 5
#define VDIR_AUTO 0
#define VDIR_MANUAL 0
#define VDIR_SWING 1
#define VDIR_UP 2
#define VDIR_MUP 3
#define VDIR_MIDDLE 4
#define VDIR_MDOWN 5
#define VDIR_DOWN 6
#define HDIR_AUTO 0
#define HDIR_MANUAL 0
#define HDIR_SWING 1
#define HDIR_MIDDLE 2
#define HDIR_LEFT 3
#define HDIR_MLEFT 4
#define HDIR_MRIGHT 5
#define HDIR_RIGHT 6
*/
#define MY_NODE_ID 31
//Disable blinking
#define MY_DEFAULT_ERR_LED A10
#define MY_DEFAULT_TX_LED A10
#define MY_DEFAULT_RX_LED A10
#define MY_RADIO_NRF24
#define MY_RF24_CE_PIN 8
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#include <math.h>
#include <Wire.h>
#include <FujitsuHeatpumpIR.h>
//Define connections
#define CHILD_ID_HVAC 0
#define CHILD_ID_LIGHT 1
#define CHILD_ID_HUM 2
#define CHILD_ID_TEMP 3
#define CHILD_ID_MQ 4
#define DHT_PIN 7
const int MQ_Pin = A3;
DHT dht;
//MQ+DHT
long MQ_Millis = 0;
long MQ_interval = 60000;
long DHT_Millis = 0;
long DHT_interval = 60000;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgMQ(CHILD_ID_MQ, V_LEVEL);
//HVAC
//Some global variables to hold the states
int POWER_STATE;
int TEMP_STATE;
int FAN_STATE;
int MODE_STATE;
int VDIR_STATE;
int HDIR_STATE;
String HA_MODE_STATE = "Off";
String HA_FAN_STATE = "Min";
IRSenderPWM irSender(3); // IR led on Arduino digital pin 3, using Arduino PWM
HeatpumpIR *heatpumpIR = new FujitsuHeatpumpIR();
MyMessage msgHVACSetPointC(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
MyMessage msgHVACSpeed(CHILD_ID_HVAC, V_HVAC_SPEED);
MyMessage msgHVACFlowState(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
bool initialValueSent = false;
//RGB VARS AND PINS
#define REDPIN 6
#define GREENPIN 5
#define BLUEPIN 9
MyMessage lightMsg(CHILD_ID_LIGHT, V_LIGHT);
MyMessage rgbMsg(CHILD_ID_LIGHT, V_RGB);
MyMessage dimmerMsg(CHILD_ID_LIGHT, V_DIMMER);
//Global variables
byte red = 255;
byte green = 255;
byte blue = 255;
byte r0 = 255;
byte g0 = 255;
byte b0 = 255;
char rgbstring[] = "ffffff";
int on_off_status = 0;
int dimmerlevel = 100;
int fadespeed = 0;
void before()
{
dht.setup(DHT_PIN);
loadState(CHILD_ID_HVAC);
}
void setup()
{
Serial.begin(115200);
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
}
void presentation()
{
sendSketchInfo(SN, SV);
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
present(CHILD_ID_MQ, S_AIR_QUALITY);
present(CHILD_ID_LIGHT, S_RGB_LIGHT);
present(CHILD_ID_HVAC, S_HVAC, "");
}
void loop()
{
unsigned long DHT_Current_Millis = millis();
if((unsigned long)(DHT_Current_Millis - DHT_Millis) >= DHT_interval)
{
DHT_Millis = DHT_Current_Millis;
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
float humidity = dht.getHumidity();
if (isnan(temperature))
{Serial.println("Failed reading temperature from DHT");}
if (isnan(humidity))
{Serial.println("Failed reading humidity from DHT");}
else
{
send(msgTemp.set(temperature, 1));
send(msgHum.set(humidity, 1));
Serial.print("T: ");
Serial.println(temperature);
Serial.print("H: ");
Serial.println(humidity);
}
}
unsigned long MQ_Current_Millis = millis();
if((unsigned long)(MQ_Current_Millis - MQ_Millis) >= MQ_interval)
{
MQ_Millis = MQ_Current_Millis;
float mq_reading = analogRead(MQ_Pin);
if (isnan(mq_reading))
{ Serial.println("Failed mq_reading"); }
else
{
send(msgMQ.set(mq_reading, 1));
Serial.print("MQ: ");
Serial.println(mq_reading);
}
}
if (!initialValueSent)
{
Serial.println("Sending initial values");
POWER_STATE = 0;
MODE_STATE = MODE_AUTO;
FAN_STATE = 1;
TEMP_STATE = 24;
sendHeatpumpCommand();
sendNewStateToGateway();
request(CHILD_ID_HVAC, V_HVAC_SETPOINT_COOL);
wait(3000, C_SET, V_HVAC_SETPOINT_COOL);
request(CHILD_ID_HVAC, V_HVAC_SPEED);
wait(3000, C_SET, V_HVAC_SPEED);
request(CHILD_ID_HVAC, V_HVAC_FLOW_STATE);
wait(3000, C_SET, V_HVAC_FLOW_STATE);
//initialValueSent = true;
}
static bool first_message_sent = false;
if ( first_message_sent == false )
{
Serial.println( "Sending initial state..." );
set_hw_status();
send_status();
first_message_sent = true;
}
}
void receive(const MyMessage &message) {
if (message.isAck()) {
Serial.println("This is an ack from gateway");
//return;
}
Serial.print("Incoming message for: ");
Serial.print(message.sensor);
int val; //RGB VAR
String recvData = message.data;
recvData.trim();
Serial.print(", New status: ");
Serial.println(recvData);
switch (message.type)
{
case V_HVAC_SPEED:
Serial.println("V_HVAC_SPEED");
if(recvData.equalsIgnoreCase("auto"))
{
FAN_STATE = 0;
HA_FAN_STATE = "Auto";
}
else if(recvData.equalsIgnoreCase("min"))
{
FAN_STATE = 1;
HA_FAN_STATE = "Min";
}
else if(recvData.equalsIgnoreCase("normal"))
{
FAN_STATE = 2;
HA_FAN_STATE = "Normal";
}
else if(recvData.equalsIgnoreCase("max"))
{
FAN_STATE = 3;
HA_FAN_STATE = "Max";
}
break;
case V_HVAC_SETPOINT_COOL:
Serial.println("V_HVAC_SETPOINT_COOL");
TEMP_STATE = message.getFloat();
Serial.println(TEMP_STATE);
break;
case V_HVAC_FLOW_STATE:
Serial.println("V_HVAC_FLOW_STATE");
if (recvData.equalsIgnoreCase("coolon"))
{
POWER_STATE = 1;
MODE_STATE = MODE_COOL;
HA_MODE_STATE = "CoolOn";
}
else if (recvData.equalsIgnoreCase("heaton"))
{
POWER_STATE = 1;
MODE_STATE = MODE_HEAT;
HA_MODE_STATE = "HeatOn";
}
else if (recvData.equalsIgnoreCase("autochangeover"))
{
POWER_STATE = 1;
MODE_STATE = MODE_AUTO;
HA_MODE_STATE = "AutoChangeOver";
}
else if (recvData.equalsIgnoreCase("off"))
{
POWER_STATE = 0;
HA_MODE_STATE = "Off";
}
initialValueSent = true;
break;
case V_RGB:
{
Serial.println( "V_RGB command: " );
Serial.println(message.data);
long number = (long) strtol( message.data, NULL, 16);
// Save old value
strcpy(rgbstring, message.data);
// Split it up into r, g, b values
red = number >> 16;
green = number >> 8 & 0xFF;
blue = number & 0xFF;
send_status();
set_hw_status();
}
break;
case V_LIGHT:
{
Serial.println( "V_LIGHT command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val == 0 or val == 1)
{
on_off_status = val;
send_status();
set_hw_status();
}
}
break;
case V_DIMMER:
{
Serial.print( "V_DIMMER command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <=100)
{
dimmerlevel = val;
send_status();
set_hw_status();
}
}
break;
case V_VAR1:
{
Serial.print( "V_VAR1 command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <= 2000)
{
fadespeed = val;
}
}
break;
}
sendHeatpumpCommand();
sendNewStateToGateway();
}
void sendNewStateToGateway() {
send(msgHVACSetPointC.set(TEMP_STATE));
wait(1000, C_SET, V_HVAC_SETPOINT_COOL);
char fan_state[HA_FAN_STATE.length() + 1];
HA_FAN_STATE.toCharArray(fan_state, HA_FAN_STATE.length() + 1);
send(msgHVACSpeed.set(fan_state));
wait(1000, C_SET, V_HVAC_SPEED);
char mode_state[HA_MODE_STATE.length() + 1];
HA_MODE_STATE.toCharArray(mode_state, HA_MODE_STATE.length() + 1);
send(msgHVACFlowState.set(mode_state));
wait(1000, C_SET, V_HVAC_FLOW_STATE);
}
void sendHeatpumpCommand() {
Serial.println("Power = " + (String)POWER_STATE);
Serial.println("Mode = " + (String)MODE_STATE);
Serial.println("Fan = " + (String)FAN_STATE);
Serial.println("Temp = " + (String)TEMP_STATE);
heatpumpIR->send(irSender, POWER_STATE, MODE_STATE, FAN_STATE, TEMP_STATE, VDIR_AUTO, HDIR_AUTO);
}
void set_rgb(int r, int g, int b) {
analogWrite(REDPIN, r);
analogWrite(GREENPIN, g);
analogWrite(BLUEPIN, b);
}
void set_hw_status()
{
int r = on_off_status * (int)(red * dimmerlevel/100.0);
int g = on_off_status * (int)(green * dimmerlevel/100.0);
int b = on_off_status * (int)(blue * dimmerlevel/100.0);
if (fadespeed >0)
{
float dr = (r - r0) / float(fadespeed);
float db = (b - b0) / float(fadespeed);
float dg = (g - g0) / float(fadespeed);
for (int x = 0; x < fadespeed; x++)
{
set_rgb(r0 + dr*x, g0 + dg*x, b0 + db*x);
delay(100);
}
}
set_rgb(r, g, b);
r0 = r;
b0 = b;
g0 = g;
}
void send_status()
{
send(rgbMsg.set(rgbstring));
send(lightMsg.set(on_off_status));
send(dimmerMsg.set(dimmerlevel));
}
Well with this code
switch (message.type)
{
case V_RGB:
{
Serial.println( "V_RGB command: " );
Serial.println(message.data);
long number = (long) strtol( message.data, NULL, 16);
// Save old value
strcpy(rgbstring, message.data);
// Split it up into r, g, b values
red = number >> 16;
green = number >> 8 & 0xFF;
blue = number & 0xFF;
send_status();
set_hw_status();
}
break;
case V_LIGHT: case V_STATUS:
{
Serial.println( "V_LIGHT command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val == 0 or val == 1)
{
on_off_status = val;
send_status();
set_hw_status();
}
}
break;
case V_DIMMER: case V_PERCENTAGE:
{
Serial.print( "V_DIMMER command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <=100)
{
dimmerlevel = val;
send_status();
set_hw_status();
}
}
break;
Get the following errors
In function 'void receive(const MyMessage&)':
IR_TESTBED:232: error: duplicate case value
case V_LIGHT: case V_STATUS:
^
IR_TESTBED:232: error: previously used here
case V_LIGHT: case V_STATUS:
^
IR_TESTBED:245: error: duplicate case value
case V_DIMMER: case V_PERCENTAGE:
^
IR_TESTBED:245: error: previously used here
case V_DIMMER: case V_PERCENTAGE:
^
Using library MySensors at version 2.1.1
exit status 1
duplicate case value
else if (message.type == V_LIGHT || message.type == V_STATUS)
How to da that? Internet tells me a can use
case V_LIGHT:
case V_STATUS:
But that throws errors
Have tried to integrate your code and it's awesome except for one thing.
Fixing the PWM breaks the timer. So if i use it straight away my DHT22 and MQ-2 will not send any data.
Well not like that - DHT22 sends humidity but no temp
As soon as i comment out the below line everything starts to work out
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
The only exception that i use PWM pins 5,6,9 and pin3 is user for IR transmitter. Any ideas for an easy fix?
@mfalkvidd It's hard to catch. Otherwise usually looks normal
Have set up a mysensors relay node with DHT11.
Seems the sensor is sending quite erraneous data. It is powered by some phone charger and off the same 5V line as arduino.
The readings are taken every 60seconds
Green is humidity, yellow is temp from DHT and blue is outside temperature from weatherunderground.
There is a 10k pull up resistor in place. As can be seen the values for humidity some time spike into the unknown.
What can be the reason for that? Power supply? Maybe need to define in the code the sensor type?
#define SN "Vent Klapans"
#define SV "2.1"
//System settings
#define MY_NODE_ID 56
#define MY_RADIO_NRF24
#define MY_DEBUG
#include <Bounce2.h>
#include <DHT.h>
#include <math.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
//SETUP PINS
#define BUT1_PIN 7
#define BUTTON_PIN2 8
#define DHT_PIN 3
#define RELAY_1 5 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 2 // Total number of attached relays
//Define connections
#define CHILD_ID_HUM 3
#define CHILD_ID_TEMP 4
#define CHILD_BUT1_ID 7
#define CHILD_BUT2 8
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
DHT dht;
//MQ+DHT
long DHT_Millis = 0;
long DHT_interval = 60000;
//Buttons
Bounce debouncer1 = Bounce();
Bounce debouncer_2 = Bounce();
int oldValue1=-1;
int oldValue_2=-1;
bool state1;
bool state2;
MyMessage msgHumi(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgBut1(CHILD_BUT1_ID,V_STATUS);
MyMessage msgbut2(CHILD_BUT2,V_TRIPPED);
void before()
{
dht.setup(DHT_PIN);
pinMode(BUT1_PIN,INPUT_PULLUP);
pinMode(BUTTON_PIN2,INPUT);
digitalWrite(BUTTON_PIN2, HIGH);
debouncer1.attach(BUT1_PIN);
debouncer1.interval(5);
debouncer_2.attach(BUTTON_PIN2);
debouncer_2.interval(5);
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
{
pinMode(pin, OUTPUT); // Then set relay pins in output mode
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); // Set relay to last known state (using eeprom storage)
}
}
void setup()
{ Serial.begin(115200); }
void presentation()
{
sendSketchInfo(SN, SV);
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
present(CHILD_BUT1_ID, S_LIGHT);
present(CHILD_BUT2, S_DOOR);
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
{
present(sensor, S_LIGHT); // Register all sensors to gw (they will be created as child devices)
}
}
void loop()
{
int value_but_2 = debouncer_2.read();
unsigned long DHT_Current_Millis = millis();
if(DHT_Current_Millis - DHT_Millis > DHT_interval)
{
DHT_Millis = DHT_Current_Millis;
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
float humidity = dht.getHumidity();
if (isnan(temperature))
{
Serial.println("Failed reading temperature from DHT");
}
if (isnan(humidity))
{
Serial.println("Failed reading humidity from DHT");
}
else
{
send(msgTemp.set(temperature, 1));
send(msgHumi.set(humidity, 1));
Serial.print("T: ");
Serial.println(temperature);
Serial.print("H: ");
Serial.println(humidity);
}
}
debouncer1.update();
int value = debouncer1.read();
if (value != oldValue1)
{
// Send in the new value
send(msgBut1.set(value==HIGH ? 1 : 0));
oldValue1 = value;
}
debouncer_2.update();
if (value_but_2 != oldValue_2)
{
if ( value_but_2==0)
{
state2 = !state2;
send(msgbut2.set(state2));
}
oldValue_2 = value_but_2;
}
}
void receive(const MyMessage &message)
{
if (message.type==V_STATUS) // We only expect one type of message from controller. But we better check anyway.
{
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Change relay state
saveState(message.sensor, message.getBool()); // Store state in eeprom
Serial.print("Incoming change for sensor:"); // Write some debug info
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
Not a programmer so all the sensor through trial and error. Need to combien the codes from two nodes (RGB dimmer and Heatpump).
The first one uses case
void receive(const MyMessage &message) {
if (message.isAck()) {
Serial.println("This is an ack from gateway");
return;
}
Serial.print("Incoming message for: ");
Serial.print(message.sensor);
String recvData = message.data;
recvData.trim();
Serial.print(", New status: ");
Serial.println(recvData);
switch (message.type) {
case V_HVAC_SPEED:
Serial.println("V_HVAC_SPEED");
if(recvData.equalsIgnoreCase("auto")) FAN_STATE = 0;
else if(recvData.equalsIgnoreCase("min")) FAN_STATE = 1;
else if(recvData.equalsIgnoreCase("normal")) FAN_STATE = 2;
else if(recvData.equalsIgnoreCase("max")) FAN_STATE = 3;
break;
case V_HVAC_SETPOINT_COOL:
Serial.println("V_HVAC_SETPOINT_COOL");
TEMP_STATE = message.getFloat();
Serial.println(TEMP_STATE);
break;
case V_HVAC_FLOW_STATE:
Serial.println("V_HVAC_FLOW_STATE");
if (recvData.equalsIgnoreCase("coolon")) {
POWER_STATE = 1;
MODE_STATE = MODE_COOL;
}
else if (recvData.equalsIgnoreCase("heaton")) {
POWER_STATE = 1;
MODE_STATE = MODE_HEAT;
}
else if (recvData.equalsIgnoreCase("autochangeover")) {
POWER_STATE = 1;
MODE_STATE = MODE_AUTO;
}
else if (recvData.equalsIgnoreCase("off")){
POWER_STATE = 0;
}
break;
}
sendHeatpumpCommand();
sendNewStateToGateway();
}
The second one uses ifs
void receive(const MyMessage &message)
{
int val;
if (message.type == V_RGB) {
Serial.println( "V_RGB command: " );
Serial.println(message.data);
long number = (long) strtol( message.data, NULL, 16);
// Save old value
strcpy(rgbstring, message.data);
// Split it up into r, g, b values
red = number >> 16;
green = number >> 8 & 0xFF;
blue = number & 0xFF;
send_status();
set_hw_status();
} else if (message.type == V_LIGHT || message.type == V_STATUS) {
Serial.println( "V_LIGHT command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val == 0 or val == 1) {
on_off_status = val;
send_status();
set_hw_status();
}
} else if (message.type == V_DIMMER || message.type == V_PERCENTAGE) {
Serial.print( "V_DIMMER command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <=100) {
dimmerlevel = val;
send_status();
set_hw_status();
}
} else if (message.type == V_VAR1 ) {
Serial.print( "V_VAR1 command: " );
Serial.println(message.data);
val = atoi(message.data);
if (val >= 0 and val <= 2000) {
fadespeed = val;
}
} else {
Serial.println( "Invalid command received..." );
return;
}
}
Do i understand correctly that i should still with HVAC code and use cases and rewrite the rgb code just substituting
if (message.type == V_RGB)
with
case V_RGB:
Yes it was. Was powering the radio off an Arduino Nano's 3,3V and found that it didn't provide enough power to the radio. Switched to another nano and everything was fine. Thank you.
P.S. A capacitor on the nrf power line didn't help
Building a new project and i need 4PWM pins.
3 for RGB dimmer and one for IR transmitter.
Took the nano but PWM pins 9,10,11 are occupied by my sensors. Tried to move the CE pin to 8 via
#define MY_RF24_CE_PIN 8
But seems reception is a bit unreliable because of this.
Well took the plunge.
VCC 12V
GND - GND as shared on 7805 with arduino
IN - Digital pin of arduino to control. Works for now...
There are different schematics on the net. One pull the signal to the ground
Others the load.
So which one is better?
Have a kitchen hood which i've modified with some 12V LED strips controlled via a mosfet IRLB8721mysensors node.
I have some CREE xm-l led lying around which i want to use but can't find schematics as internet is full of the ones for flashlights.
So how can i power it up with a Mysensors nodei have with minimum soldering work?
Want to drive it at high amps at 1,5-2A
Took the picture from the internet. I have the same but it's SRD-12VDC instead of SRD-05VDC.
Well i do want to remove the jumper but wire it to arduio and use a 12V supply to power the coil.
Will something like this work without frying everything?
Jumper removed
VCC - +12V supply
GND - Arduino GND (powered from 12V supply via 7805)
IN - Arduino digital pin
Wanted to build myself another relay node. But when finished - the relay didn't work... Looking at the board discovered that relay is an SRD-12VDC so 12V are required as switching voltage.
Mysensord node is powered from a 12V source through a 7805 voltage regulator so i have 12V available for the relay so was happy for a short period of time as usually you can remove the jumper and power the relay board. But this time a hit a wall as the connectors are totally different and information from the internet is scarse.
So here is the relay board
So i wonder how can i wire it considering i have a 12V supply? On the other side of relay won't be any high voltage (dry contacts) just need to make it work
My mistake. 1.6.0 ofcourse.
Just remember previously there were some issues with 1.8.x
Currently have to use 1.8.3 - as hell breaks loose on 1.6... Seems it ignores half of the libraries placed under docs/arduino/libraries.
Needed to flash the Heatpump example from here https://github.com/mysensors/MySensorsArduinoExamples/blob/master/examples/HeatpumpIRController/HeatpumpIRController.ino
So tried it on my setup but failed. Thinking it was a long time i had the arduino IDE installation i've uninstalled it. Cleared all the folders (including the prefs roaming folder). Downloaded the mysensors lib 2.2 + the examples lib and reinstalled everything. Now whatever i try i get the following error below. What am i missing?
Installed the 1.8.3 and everything compiled nicely...
C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -IC:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\variants\standard -IArduino\libraries\HeatpumpIR -IArduino\libraries\Timer -IC:\Program Files (x86)\Arduino\libraries\SPI -IArduino\libraries\MySensors-master C:\Users\ilemur\AppData\Local\Temp\build5663999532552668519.tmp\sketch_jul18a.cpp -o C:\Users\ilemur\AppData\Local\Temp\build5663999532552668519.tmp\sketch_jul18a.cpp.o
In file included from Arduino\libraries\MySensors-master/MySensors.h:119,
from sketch_jul18a.ino:51:
Arduino\libraries\MySensors-master/drivers/ATSHA204/sha256.cpp:11: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/drivers/ATSHA204/sha256.cpp:24: warning: only initialized variables can be placed into program memory area
In file included from Arduino\libraries\MySensors-master/MySensors.h:257,
from sketch_jul18a.ino:51:
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stInitTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:62: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:62: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:80: error: 'hwReadConfigBlock' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stInitUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:87: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:87: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:91: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:91: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:104: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:108: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stParentTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:125: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:125: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stParentUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:158: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:158: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:167: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:167: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:172: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:172: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stIDTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:184: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:184: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:188: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stIDUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:198: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:198: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:209: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:209: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stUplinkTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:219: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:219: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stUplinkUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:232: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:234: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:234: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:236: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:248: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:248: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stReadyTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:263: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:263: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stReadyUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:288: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:288: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stFailureTransition()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:312: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:312: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:317: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void stFailureUpdate()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:326: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:326: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void transportSwitchSM(transportState_t&)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:342: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'uint32_t transportTimeInState()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:347: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportWaitUntilReady(uint32_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:395: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:395: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:396: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportCheckUplink(bool)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:418: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:419: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:419: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:427: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:428: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:428: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:431: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:437: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:437: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportAssignNodeID(uint8_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:449: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:450: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:450: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:453: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:453: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportRouteMessage(MyMessage&)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:466: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:466: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportSendRoute(MyMessage&)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:526: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:526: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportWait(uint32_t, uint8_t, uint8_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:534: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'uint8_t transportPingNode(uint8_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:550: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:550: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:566: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:566: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void transportProcessMessage()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:598: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:598: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:605: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:613: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:621: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:652: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:690: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:694: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:699: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:707: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:720: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:722: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:737: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:749: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:781: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:835: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void transportInvokeSanityCheck()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:843: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:843: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:846: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:846: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'bool transportSendWrite(uint8_t, MyMessage&)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:882: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:882: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp:897: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:897: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void transportClearRoutingTable()':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:931: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MyTransport.cpp:931: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'void transportSetRoute(uint8_t, uint8_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:955: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MyTransport.cpp: In function 'uint8_t transportGetRoute(uint8_t)':
Arduino\libraries\MySensors-master/core/MyTransport.cpp:965: error: 'hwReadConfig' was not declared in this scope
In file included from Arduino\libraries\MySensors-master/MySensors.h:290,
from sketch_jul18a.ino:51:
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'void RF24_csn(bool)':
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:39: error: 'hwDigitalWrite' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'void RF24_ce(bool)':
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:44: error: 'hwDigitalWrite' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'uint8_t RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool)':
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:53: error: 'class SPIClass' has no member named 'beginTransaction'
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:54: error: 'SPISettings' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:101: error: 'class SPIClass' has no member named 'endTransaction'
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp: In function 'bool RF24_initialize()':
Arduino\libraries\MySensors-master/drivers/RF24/RF24.cpp:388: error: 'hwPinMode' was not declared in this scope
In file included from Arduino\libraries\MySensors-master/core/MyTransportNRF24.cpp:25,
from Arduino\libraries\MySensors-master/MySensors.h:291,
from sketch_jul18a.ino:51:
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'void CircularBuffer<T>::clear()':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:53: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:53: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'bool CircularBuffer<T>::empty() const':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:66: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:66: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'bool CircularBuffer<T>::full() const':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:79: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:79: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'uint8_t CircularBuffer<T>::available() const':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:91: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:91: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:94: warning: no return statement in function returning non-void
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'T* CircularBuffer<T>::getFront() const':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:104: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:104: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:111: error: expected `}' at end of input
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'bool CircularBuffer<T>::pushFront(T*)':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:121: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:121: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:134: error: expected `}' at end of input
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:134: warning: no return statement in function returning non-void
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'T* CircularBuffer<T>::getBack() const':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:144: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:144: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:151: error: expected `}' at end of input
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h: In member function 'bool CircularBuffer<T>::popBack()':
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:159: error: 'MY_CRITICAL_SECTION' was not declared in this scope
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:159: error: expected `;' before '{' token
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:167: error: expected `}' at end of input
Arduino\libraries\MySensors-master/drivers/CircularBuffer/CircularBuffer.h:167: warning: no return statement in function returning non-void
In file included from Arduino\libraries\MySensors-master/MySensors.h:334,
from sketch_jul18a.ino:51:
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'void _begin()':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:85: error: 'hwWatchdogReset' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:91: error: 'hwInit' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:93: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:93: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:101: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:114: error: 'hwReadConfigBlock' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:123: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:150: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:154: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'void _registerNode()':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:168: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:168: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'bool send(MyMessage&, bool)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:300: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:300: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'bool _processInternalMessages()':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:367: error: 'hwReboot' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:373: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:373: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:380: error: 'hwWriteConfigBlock' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:418: error: 'hwCPUVoltage' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:421: error: 'hwCPUFrequency' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:424: error: 'hwFreeMem' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:428: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:431: error: 'hwReboot' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'void saveState(uint8_t, uint8_t)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:472: error: 'hwWriteConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'uint8_t loadState(uint8_t)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:476: error: 'hwReadConfig' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'void wait(uint32_t)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:482: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'bool wait(uint32_t, uint8_t, uint8_t)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:490: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'void doYield()':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:503: error: 'hwWatchdogReset' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:505: error: 'yield' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp: In function 'int8_t _sleep(uint32_t, bool, uint8_t, uint8_t, uint8_t, uint8_t)':
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:515: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:515: error: 'hwDebugPrint' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:541: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:542: error: 'hwMillis' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:552: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:567: warning: only initialized variables can be placed into program memory area
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:584: error: 'hwSleep' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:587: error: 'hwSleep' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:590: error: 'hwSleep' was not declared in this scope
Arduino\libraries\MySensors-master/core/MySensorsCore.cpp:594: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino: In function 'void setup()':
sketch_jul18a.ino:97: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:100: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino: In function 'void receive(const MyMessage&)':
sketch_jul18a.ino:132: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:134: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:141: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:145: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:146: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino: In function 'void sendHeatpumpIRCommand(const char*)':
sketch_jul18a.ino:168: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:171: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:198: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:208: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:209: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:210: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:211: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:212: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:220: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:224: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino:228: warning: only initialized variables can be placed into program memory area
sketch_jul18a.ino: In function 'void panasonicCancelTimer()':
sketch_jul18a.ino:241: warning: only initialized variables can be placed into program memory area
@gohan Thanks for helping out. Is SPI supposed to be enabled? Doesn't state it anywhere. Will try it out.
Yes i also believe ./configure shoul be one line - it's just that documentation is not that clear for not tech guys like me. So if maintainer of the page is reading this - it should be better done like for the Raspberry gateway page. It's more clear.
Will try the SPI - hope it helps.
P.S. Have just reconnected the radio to my RPi3... So it's not necessary problem with myself Will try to update the topic with OrangePi struggle
RPI3 output
sudo ./bin/mysgw -d
mysgw: Config file /etc/mysensors.dat does not exist, creating new config file.
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-beta
mysgw: MCO:BGN:INIT GW,CP=RNNG----,VER=2.2.0-beta
mysgw: TSF:LRT:OK
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
mysgw: TSM:INIT:TSP OK
mysgw: TSM:INIT:GW MODE
mysgw: TSM:READY:ID=0,PAR=0,DIS=0
mysgw: MCO:REG:NOT NEEDED
mysgw: Listening for connections on 0.0.0.0:5003
mysgw: MCO:BGN:STP
mysgw: MCO:BGN:INIT OK,TSP=1
@bjacobse Can you elaborate a little more on how you wired things up?
Also how you combined the libs and compiled everything for easyESP?
Have a sonoff with easyESP and docs are not that clear how to that stuff
I took the plunge. And now ready to give up.
Got out another sd card. Installed fresh armbian.
Ubuntu server – legacy kernel
Did nothing else to the installation. Than followed the guide step by step. No deviations. The only part that it is not clear in the manual - about configure options. I believe some will first run
./configure --spi-spidev-device=/dev/spidev1.0 --my-transport=nrf24 --my-rf24-ce-pin=2 --my-rf24-cs-pin=13
and then run
./configure --my-gateway=ethernet --my-port=5003
Won't this overwrite the first config file? So just ran the first one.
And no success.
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-beta
mysgw: MCO:BGN:INIT GW,CP=RNNG----,VER=2.2.0-beta
mysgw: TSF:LRT:OK
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
mysgw: !TSM:INIT:TSP FAIL
mysgw: TSM:FAIL:CNT=1
mysgw: TSM:FAIL:DIS
mysgw: TSF:TDI:TSL
mysgw: TSM:FAIL:RE-INIT
mysgw: TSM:INIT
mysgw: !TSM:INIT:TSP FAIL
mysgw: TSM:FAIL:CNT=2
mysgw: TSM:FAIL:DIS
mysgw: TSF:TDI:TSL
^Cmysgw: Received SIGINT
Put some more solder on the connectors of OrangePi. No success. Put a 10uF 50V capacitor on the nrf24 - no success.
Maybe something has change in the inner workings?
P.S. On fresh armbian
root@orangepizero:~/MySensors# gpio readall
-bash: gpio: command not found
# gpio readall
+-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 12 | 8 | SDA.0 | ALT5 | 0 | 3 || 4 | | | 5V | | |
| 11 | 9 | SCL.0 | ALT5 | 0 | 5 || 6 | | | 0v | | |
| 6 | 7 | GPIO.7 | ALT3 | 0 | 7 || 8 | 1 | OUT | TxD3 | 15 | 13 |
| | | 0v | | | 9 || 10 | 0 | ALT5 | RxD3 | 16 | 14 |
| 1 | 0 | RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1 | 1 | 110 |
| 0 | 2 | TxD2 | ALT5 | 0 | 13 || 14 | | | 0v | | |
| 3 | 3 | CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT3 | GPIO.4 | 4 | 68 |
| | | 3.3v | | | 17 || 18 | 0 | ALT3 | GPIO.5 | 5 | 71 |
| 64 | 12 | MOSI | ALT4 | 0 | 19 || 20 | | | 0v | | |
| 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | OUT | RTS2 | 6 | 2 |
| 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0 | 10 | 67 |
| | | 0v | | | 25 || 26 | 0 | ALT3 | GPIO.11 | 11 | 21 |
| 19 | 30 | SDA.1 | ALT4 | 0 | 27 || 28 | 0 | ALT4 | SCL.1 | 31 | 18 |
| 7 | 21 | GPIO.21 | ALT3 | 0 | 29 || 30 | | | 0v | | |
| 8 | 22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | RTS1 | 26 | 200 |
| 9 | 23 | GPIO.23 | ALT3 | 0 | 33 || 34 | | | 0v | | |
| 10 | 24 | GPIO.24 | OUT | 1 | 35 || 36 | 0 | ALT3 | CTS1 | 27 | 201 |
| 20 | 25 | GPIO.25 | OUT | 1 | 37 || 38 | 0 | ALT5 | TxD1 | 28 | 198 |
| | | 0v | | | 39 || 40 | 0 | ALT5 | RxD1 | 29 | 199 |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+
Tried to compile without IRQ pin. So there is no communication with the radio (tried different radio modules).
Seems some problem with GPIO pins on DietPI?
Have followed the instructions on creating the orange pi zero gateway.
The only difference - i am running a dietPi OS (couldn't install armbian).
Wired all as recommended and also have added the IRQ pin (GPIO10)
Strangely enough didn't have to alter the bin2fex /boot/script.bin /tmp/orange.fex as it already contained the necessary information.
Ran the config with the following options
./configure --spi-spidev-device=/dev/spidev1.0 --my-transport=nrf24 --my-rf24-ce-pin=2 --my-rf24-cs-pin=13 --my-rf24-irq-pin=10 --my-gateway=ethernet --my-port=5003
Everything compiled but upon launching got the
# sudo ./bin/mysgw -d
mysgw: Starting gateway...
mysgw: Protocol version - 2.2.0-beta
mysgw: MCO:BGN:INIT GW,CP=RNNG--Q-,VER=2.2.0-beta
mysgw: TSF:LRT:OK
mysgw: TSM:INIT
mysgw: TSF:WUR:MS=0
mysgw: Could not open /sys/class/gpio/gpio10/direction
Tried
#echo "10" |sudo tee /sys/class/gpio/export
10
tee: /sys/class/gpio/export: Device or resource busy
Any ideas on this would be much appreciated...
Have been running successfully mysensors for quite some time. Now building another sensor and have a nightmare. The manually set NODE_ID gets completly ignored and i don not why just gets itself from out of nowhere. My gateway is a version 2.0 ESP to MQTT
Code
#define SN "Vent Klapans"
#define SV "2.1"
//System settings
#define MY_RADIO_NRF24
#define MY_DEBUG
#include <Bounce2.h>
#include <DHT.h>
#include <math.h>
#include <MySensors.h>
#include <SPI.h>
#include <Wire.h>
#define MY_NODE_ID 56
//SETUP PINS
#define BUT1_PIN 7
#define BUT2_PIN 8
#define DHT_PIN 3
#define RELAY_1 5 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 2 // Total number of attached relays
//Define connections
#define CHILD_ID_HUM 3
#define CHILD_ID_TEMP 4
#define CHILD_BUT1_ID 7
#define CHILD_BUT2_ID 8
#define RELAY_ON 0 // GPIO value to write to turn on attached relay
#define RELAY_OFF 1 // GPIO value to write to turn off attached relay
DHT dht;
//MQ+DHT
long DHT_Millis = 0;
long DHT_interval = 60000;
//Buttons
Bounce debouncer1 = Bounce();
Bounce debouncer2 = Bounce();
int oldValue1=-1;
int oldValue2=-1;
MyMessage msgHumi(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
MyMessage msgBut1(CHILD_BUT1_ID,V_STATUS);
MyMessage msgBut2(CHILD_BUT2_ID,V_STATUS);
void before()
{
Serial.println( myNodeId );
dht.setup(DHT_PIN);
pinMode(BUT1_PIN,INPUT_PULLUP);
pinMode(BUT2_PIN,INPUT_PULLUP);
debouncer1.attach(BUT1_PIN);
debouncer1.interval(5);
debouncer2.attach(BUT2_PIN);
debouncer2.interval(5);
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
{
pinMode(pin, OUTPUT); // Then set relay pins in output mode
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF); // Set relay to last known state (using eeprom storage)
}
}
void setup()
{ Serial.begin(115200); }
void presentation()
{
sendSketchInfo(SN, SV);
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
present(CHILD_BUT1_ID, S_LIGHT);
present(CHILD_BUT2_ID, S_LIGHT);
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) // Fetch relay status
{
present(sensor, S_LIGHT); // Register all sensors to gw (they will be created as child devices)
}
}
void loop()
{
unsigned long DHT_Current_Millis = millis();
if(DHT_Current_Millis - DHT_Millis > DHT_interval)
{
DHT_Millis = DHT_Current_Millis;
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
float humidity = dht.getHumidity();
if (isnan(temperature))
{
Serial.println("Failed reading temperature from DHT");
}
if (isnan(humidity))
{
Serial.println("Failed reading humidity from DHT");
}
else
{
send(msgTemp.set(temperature, 1));
send(msgHumi.set(humidity, 1));
Serial.print("T: ");
Serial.println(temperature);
Serial.print("H: ");
Serial.println(humidity);
}
}
debouncer1.update();
int value = debouncer1.read();
if (value != oldValue1)
{
// Send in the new value
send(msgBut1.set(value==HIGH ? 1 : 0));
oldValue1 = value;
}
debouncer2.update();
int value2 = debouncer2.read();
if (value2 != oldValue2)
{
// Send in the new value
send(msgBut2.set(value==HIGH ? 1 : 0));
oldValue2 = value2;
}
}
void receive(const MyMessage &message)
{
if (message.type==V_STATUS) // We only expect one type of message from controller. But we better check anyway.
{
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF); // Change relay state
saveState(message.sensor, message.getBool()); // Store state in eeprom
Serial.print("Incoming change for sensor:"); // Write some debug info
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
Debug - Serial Print
15 TSF:SID:OK,ID=75
17 TSM:FPAR
53 TSF:MSG:SEND,75-75-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
1238 TSF:MSG:READ,0-0-75,s=255,c=3,t=8,pt=1,l=1,sg=0:0
1243 TSF:MSG:FPAR OK,ID=0,D=1
2060 TSM:FPAR:OK
2061 TSM:ID
2062 TSM:ID:OK
2064 TSM:UPL
2067 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
2179 TSF:MSG:READ,0-0-75,s=255,c=3,t=25,pt=1,l=1,sg=0:1
2184 TSF:MSG:PONG RECV,HP=1
2186 TSM:UPL:OK
2188 TSM:READY:ID=75,PAR=0,DIS=1
2192 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
2329 TSF:MSG:READ,0-0-75,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
2336 TSF:MSG:SEND,75-75-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
2345 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
4354 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=11,pt=0,l=12,sg=0,ft=0,st=OK:Vent Klapans
4363 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:2.1
4371 TSF:MSG:SEND,75-75-0-0,s=3,c=0,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
4378 TSF:MSG:SEND,75-75-0-0,s=4,c=0,t=6,pt=0,l=0,sg=0,ft=0,st=OK:
4420 !TSF:MSG:SEND,75-75-0-0,s=7,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
4461 !TSF:MSG:SEND,75-75-0-0,s=8,c=0,t=3,pt=0,l=0,sg=0,ft=1,st=NACK:
4502 !TSF:MSG:SEND,75-75-0-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=2,st=NACK:
4510 TSF:MSG:SEND,75-75-0-0,s=2,c=0,t=3,pt=0,l=0,sg=0,ft=3,st=OK:
4516 MCO:REG:REQ
4554 !TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=NACK:2
6561 TSF:MSG:SEND,75-75-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
6634 TSF:MSG:READ,0-0-75,s=255,c=3,t=27,pt=1,l=1,sg=0:1
6639 MCO:PIM:NODE REG=1
6641 MCO:BGN:STP
6642 MCO:BGN:INIT OK,TSP=1
6647 TSF:MSG:SEND,75-75-0-0,s=7,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
6654 TSF:MSG:SEND,75-75-0-0,s=8,c=1,t=2,pt=2,l=2,sg=0,ft=0,st=OK:1
Debug - this is what i see on the MQTT broker (connected to
mys-out/75/255/3/0/11 Vent Klapans
mys-out/75/255/3/0/12 2.1
mys-out/75/3/0/0/7 (null)
mys-out/75/4/0/0/6 (null)
mys-out/75/1/0/0/3 (null)
mys-out/75/7/1/0/2 1
mys-out/75/8/1/0/2 1
mys-out/71/6/1/0/37 626.0
Thanks for the library it's great. I can also confirm that it works with Fujitsu remote AR-REB1E out of the box.
Trying to integrate this into HomeAssistant and just do not know where to start. Is there any example how to post a whole string of commands for the air cond via mysensors-MQTT?
Sorry tp bump an old one but still haven't found a solution.
MQTT passes it as
mys-in/36/0/1/0/40 255,85,73
So the message payload can be passed directly to arduino as PWM values
I can see the topic is quite old but myabe a complete sensor 2.1 example?
I can see that this code for openhab is quite popular. But i'm facing an issue constructing the proper MQTT topic
As on my set up all my control messages look like
topic: "mys-in/41/2/1/0/2"
payload: "0"
So wonder which ones to use with this sketch?
@vorowski said:
https://github.com/mathertel/OneButton
This is what I use for this.
Mind sharing some mysensors code to see how you got it implemented?
Couldn't find any examples on utilising hold or double clicks for the buttons on my sensor nodes. With all the wifi lamps around it would be great to control them via the mysensor nodes and controller
Have around 5 nodes around the house and the latest one completed sends spikes from 50 to 800 ppm almost every minute. The only idea i have - it's happening because of the power supply (MQ-2 attached to the power supplies 5v and GND). Will adding a capacitor help out to smooth out the voltage? And what is the recommended capacity? Have tried already replacing the sensor
Not exactly...
Here we are awaiting a hex value
void receive(const MyMessage &message) {
if (message.type==V_RGB)
{
hexstring = message.getString();
....
And than process those to rgb values. But if via MQTT we will receive RGB values like 243,145,156 and not hex - how to change the code accordingly?
@dbemowsk said:
@moskovskiy82 Is the relay that you are replacing in the wall switch box or the breaker panel? Do you have any information on the Legrand relay that you are replacing?
Not exactly...
Here we are awaiting a hex value
void receive(const MyMessage &message) {
if (message.type==V_RGB)
{
hexstring = message.getString();
....
And than process those to rgb values. But if via MQTT we will receive RGB values like 243,145,156 and not hex - how to change the code accordingly?
Well we have a 3wire system. So N is neutral and PE is protective earth and is a separate ground connection.
I was discussing the use of PE as a possibility. Occurance of a strong potential here is almost impossible but i guess due to induction there can be some.
Currently have the following code (at the bottom - removed everything irrelevant) - followed by the examples on this great board which receives hex. Not very strong at programming and need to switch to receiving values like /36/0/1/0/40 249,255,218
Just do not know how to change the setColor(String hexstring) function
OLD CODE:
long RGB_values[3] = {0,0,0};
String hexstring;
int RValue;
int GValue;
int BValue;
int CurrentLevel;
void before()
{
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
}
void receive(const MyMessage &message) {
if (message.type==V_RGB)
{
hexstring = message.getString();
Serial.print("RGB command: ");
Serial.println(hexstring);
setColor(hexstring);
}
else if (message.type==V_PERCENTAGE)
{
int dimLevel = message.getInt(); //0-100%
Serial.print("Dim command: ");
Serial.println(dimLevel);
setDimLevel(dimLevel);
saveState(SAVE_DIMMER_LEVEL, dimLevel);
}
else if (message.type==V_STATUS)
{
if(message.getBool() == RELAY_ON)
{
setColor("FFF1E0");
saveState(SAVE_LIGHT_STATE, RELAY_ON);
}
if(message.getBool() == RELAY_OFF)
{
analogWrite(RED_PIN, 0);
analogWrite(GREEN_PIN, 0);
analogWrite(BLUE_PIN, 0);
saveState(SAVE_LIGHT_STATE, RELAY_OFF);
}
}
}
void setDimLevel(int level)
{
level = level > 100 ? 100 : level;
level = level < 0 ? 0: level;
int delta = ( level - CurrentLevel) < 0 ? -1 : 1;
RValue = (int)(level / 100. * RValue);
BValue = (int)(level / 100. * BValue);
GValue = (int)(level / 100. * GValue);
analogWrite(RED_PIN, RValue);
analogWrite(GREEN_PIN, GValue);
analogWrite(BLUE_PIN, BValue);
CurrentLevel = level;
}
void setColor(String hexstring)
{
long number = (long) strtol( &hexstring[0], NULL, 16);
Serial.print("Color long: ");
Serial.println(number);
RValue = number >> 16;
GValue = number >> 8 & 0xFF;
BValue = number & 0xFF;
Serial.print("Color: ");
Serial.println(hexstring);
Serial.print("Red: ");
Serial.println(RValue);
Serial.print("Green: ");
Serial.println(GValue);
Serial.print("Blue: ");
Serial.println(BValue);
analogWrite(RED_PIN, RValue);
analogWrite(GREEN_PIN, GValue);
analogWrite(BLUE_PIN, BValue);
}
Well it works with low stability. Only half of the pressings get activated. Maybe something to do with debounce settings?
Currently have them at debouncer[i].interval(5);
@mfalkvidd said:
@moskovskiy82 N is NOT gnd/earth. It carries AC power. So connecting the button to that will be very dangerous.
As i am running short of wires. What if the push button will connect one end to the digital pin on arduino and the second one go to the mains ground (PE). Wonder if that will work and will not cause the circuit breaker to activate. Any ideas on this?
Anybody has a sketch where multiple buttons are put up on single wire and voltage drop is used to distinguish between them?
Currently have the lights in my home connected to Legrand relays (installed the switch box).
Decided to change them to mysensor nodes (also installed in the switch box).
Currently in the socket under the momentary switch i have L and N going to the lamp.
So after integrating mysensors in place the question is - how to connect the mometary buttons. Do i have to use 2 wires - one for N (GND) from arduino and one connected to the digital pin. Or i can use just one wire connected to the digital pin and the second connect to the N which is already in the socket?
Just for clarification. V2.0 gateway (MQTT client esp8266) - will it work with the 1.5/1.6 sensors? Or everything needs to be flashed as soon as possible?
And if my loop statement consists only of
void loop()
{ gw.process(); }
Rewrite like
void loop() { }
or exclude loop completely?
Little bit confused. reading through the release notes...
Deprecated variables: V_DIMMER (use V_PERCENTAGE), V_HEATER (use V_HVAC_FLOW_STATE), V_LIGHT (use V_STATUS)
Now back to the API page for 2.0...
S_DIMMER 4 Dimmable device of some kind V_STATUS (on/off), V_DIMMER (dimmer level 0-100), V_WATT
WHICH ONE TRUST?!
I have the following code for my sensor and was wondering if it is possilbe to send the average value collected for the
DHT_interval which is set in the beginning?
unsigned long DHT_Current_Millis = millis();
if(DHT_Current_Millis - DHT_Millis > DHT_interval)
{
DHT_Millis = DHT_Current_Millis;
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
if (isnan(temperature))
{ Serial.println("Failed reading temperature from DHT"); }
else if (temperature != lastTemp)
{
lastTemp = temperature;
gw.send(msgTemp.set(temperature, 2));
Serial.print("T: ");
Serial.println(temperature);
}
float humidity = dht.getHumidity();
if (isnan(humidity))
{ Serial.println("Failed reading humidity from DHT"); }
else if (humidity != lastHum)
{
lastHum = humidity;
gw.send(msgHum.set(humidity, 2));
Serial.print("H: ");
Serial.println(humidity);
}
}```
Wonder if anybody has a rule checking if mysensors are suppliying data? Somehtin like haven't changed since nominus 1hour than...
i have several example rule but seems cannot get it to work
What is also strange i tried to start mosquitto with
sudo mosquitto -c /etc/mosquitto/mosquitto.conf -v
Than on the second console i tried
mosquitto_sub -v -t 'mygateway1-out/#'
and also
mosquitto -c /etc/mosquitto/mosquitto.conf -v
Strange thing is that id didn't see any messages in cosole. In the log file
1465242491: mosquitto version 1.4.8 (build date Tue, 17 May 2016 11:26:59 +0100) starting
1465242491: Config loaded from /etc/mosquitto/mosquitto.conf.
1465242491: Opening ipv4 listen socket on port 1883.
1465242491: Opening ipv6 listen socket on port 1883.
1465242495: New connection from ::1 on port 1883.
1465242495: New client connected from ::1 as mosqsub/1848-homepi (c1, k60).
1465242495: Sending CONNACK to mosqsub/1848-homepi (0, 0)
1465242495: Received SUBSCRIBE from mosqsub/1848-homepi
1465242495: mygateway1-out/# (QoS 0)
1465242495: mosqsub/1848-homepi 0 mygateway1-out/#
1465242495: Sending SUBACK to mosqsub/1848-homepi
1465242527: Socket error on client mosqsub/1848-homepi, disconnecting.
1465242530: New connection from ::1 on port 1883.
1465242530: New client connected from ::1 as mosqpub/1850-homepi (c1, k60).
1465242530: Sending CONNACK to mosqpub/1850-homepi (0, 0)
1465242530: Received PUBLISH from mosqpub/1850-homepi (d0, q0, r0, m0, 'mygateway1-in/99/0/1/0/40', ... (6 bytes))
1465242530: Received DISCONNECT from mosqpub/1850-homepi
1465242530: Client mosqpub/1850-homepi disconnected.
1465242536: mosquitto version 1.4.8 terminating
This i what i did above to solve the old version problem
Installed from http://repo.mosquitto.org/debian/mosquitto-jessie.list
With no luck.
Turning debug i see the following only
1465240376: mosquitto version 1.4.8 terminating
1465240386: New connection from 127.0.0.1 on port 1883.
1465240386: New client connected from 127.0.0.1 as mosqsub/1948-homepi (c1, k60).
1465240386: Sending CONNACK to mosqsub/1948-homepi (0, 0)
1465240386: Received SUBSCRIBE from mosqsub/1948-homepi
1465240386: mygateway1-out/# (QoS 0)
1465240386: Sending SUBACK to mosqsub/1948-homepi
1465240419: Socket error on client mosqsub/1948-homepi, disconnecting.
Not that much of a help...
I tried. But i don't have any username/password
Strange thing is that this is a fresh raspbian install (downloaded yesterday)
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
Well now i have a hedache as well..
Updated to 1.4.8 freom http://repo.mosquitto.org/debian/mosquitto-jessie.list (as it seems the latest avail)
Upgraded mosquitto and mosquitto clients
$ apt-show-versions | grep mosquitto
libmosquitto1:armhf/jessie 1.4.8-0mosquitto2 uptodate
mosquitto:armhf/jessie 1.4.8-0mosquitto2 uptodate
mosquitto-clients:armhf/jessie 1.4.8-0mosquitto2 uptodate
And still i get
1465238048: Config loaded from /etc/mosquitto/mosquitto.conf.
1465238048: Opening ipv4 listen socket on port 1883.
1465238048: Opening ipv6 listen socket on port 1883.
1465238066: New connection from 127.0.0.1 on port 1883.
1465238066: New client connected from 127.0.0.1 as mosqsub/1282-homepi (c1, k60).
1465238078: Socket error on client mosqsub/1282-homepi, disconnecting.
Touche... Will try to install a new one. Wonder if it is worth going MQTT path after this...
Ubuntu
libmosquitto0:amd64/trusty 0.15-2ubuntu1 uptodate
libmosquitto1:amd64/trusty 1.4.9-0mosquitto1 uptodate
mosquitto:amd64/trusty 1.4.9-0mosquitto1 uptodate
mosquitto-clients:amd64/trusty 1.4.9-0mosquitto1 uptodate
Raspbian
libmosquitto1:armhf/jessie 1.3.4-2 uptodate
mosquitto:armhf/jessie 1.3.4-2 uptodate
mosquitto-clients:armhf/jessie 1.3.4-2 uptodate
python-mosquitto:all/jessie 1.3.4-2 uptodate
python3-mosquitto:all/jessie 1.3.4-2 uptodate
In the logs i notice
1465234765: New connection from ::1 on port 1883.
1465234765: New client connected from ::1 as mosqsub/1701-homepi (c1, k60).
1465234774: Socket error on client mosqsub/1701-homepi, disconnecting.
1465234789: mosquitto version 1.3.4 terminating
1465234789: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
Not really related to mysensors but many are using MQTT so the question goes like this.
Currently moving from UBUNTU 14 server to the latest RASPBIAN on raspberry. The gateway is the MQTT client ESP12
Installed mosquitto, mosquitto-clients and mosquitto python (both)
Running tcommand on ubuntu
$ mosquitto_sub -v -t 'mygateway1-out/#'
gives me output from mysensors
running
$ mosquitto_sub -v -t 'mygateway1-out/#'
on raspbian gives me silence
Mosquitto is up and running and i can see it on the sockets
And yes i have a loopback in interfaces.
auto lo
iface lo inet loopback
Any help will be appreciated
I am currently planning on switching from WiFi MQTT to serial gateway and will be using arduino nano connected to raspberry3
So arduino will receive it's power from the USB port.
Than there will be an NRF24PA version so planning on powering it from a separate 5V source converted via 1117 to 3,3V
My question is on the ground. The ground pin from NRF24 should be connected to the power supply and in parallel to the GND pin of arduino?
Wondered if i should update a really old thread.
There is a dust sample example on the build page. The photo looks exactly like GP2Y1010.
But for wiring only 3 pins are supposed to be used which is completely different from the pin out. Is some middle board used in this example?
Than what should be the correct wiring for the raw sensor?
Thank you didn't notice that it was a decimal point one.
So is it reasonable to enable ack for switches? And leave it disabled for sensors reporting data?
On one of my nodes i have ack message set for the MQ sensor as can be seen in the code
gw.send(msgMQ.set(mq_reading, 1));
On the controller (Openhab) i see the message like
mygateway1-out/71/6/1/0/37 309.0
This sensor conencts to the MQTT client gateway and the structure of MQTT is supposed to be
MY_MQTT_PUBLISH_TOPIC_PREFIX/FROM-NODE-ID/SENSOR-ID/CMD-TYPE/ACK-FLAG/SUB-TYPE
So shouldn't the message have 1 before 37 at the end like below?
mygateway1-out/71/6/1/1/37 309.0
Strangly i have a sketch with the following
float mq_reading = analogRead(MQ_Pin);
if (isnan(mq_reading))
{ Serial.println("Failed mq_reading"); }
else if (mq_reading != last_mq_reading)
{ last_mq_reading = mq_reading;
gw.send(msgMQ.set(mq_reading, 1));
And on the controller (MQTT client gateway on NODEMcu) i never see ACK enabled
mygateway1-out/71/6/1/0/37 309.0
I've read through the api, several forum topics and it is still unclear to me.
By default acks are disabled.
Is it a good practice to enable them on sensors with switches and dimmers?
If yes.
In the api it says - * if you want destination node *
Destination node in this case is the gateway which must send the ack upon the receipt of data?
@epierre
It still detects concentration. Both state CO detection. So in case of fire won't they detect the increase in concentration much faster that the particle sensor like Sharp’s GP2Y1010AU0F or alternative?
What about mq2 or mq135? Any experience? As a gas sensor will be more suitable detecting early fire
Which one to use for detection of fire smoke? Currently have got several MQ-7 but they don't seem so good at it
I can confirm this fixing the flickering problem. The only problem it introduces - some high pitch whine from arduino.
Ok got it working. But now i see the main problem. When you change the colour - there is a lag so othe colours are seen. Same goes to switching off. For example we were at white light fullbrightness than switched off.
You can first see the light becoming yelow, than blue than off.
How can this be fixed? If i understand correctly - you have to pass all these HSB value processing to arduino and have the controller send 3 values at once. Are there any examples?
There seems to be an example already in the 1.5 for the RGB 3D dimmer.
So if i use it - how do i connect to openhab via MQTT?
Found a solution like below but that seems only for a sinble item... Maybe there is a solution on this forum i missed?
// WiFi RGB 2
Group WIFI_RGB_2 "WiFi RGB 2" (All)
Color fWIFI_RGB_2 "RGB" <slider> (WIFI_RGB_2)
String WIFI_RGB_2_RGB (WIFI_RGB_2) {mqtt=">[broker:/openHAB/RGB_2/Color:command:*:default]"}
Switch WIFI_RGB_2_Switch1 "W1" (WIFI_RGB_2) {mqtt=">[broker:/openHAB/RGB_2/SW1:command:ON:100],>[broker:/openHAB/RGB_2/SW1:command:OFF:0]"}
And than a rule like
import org.openhab.core.library.types.*
var HSBType hsbValue
var int redValue
var int greenValue
var int blueValue
var String RGBvalues
rule "Set RGB 2 value"
when
Item fWIFI_RGB_2 changed
then
hsbValue = fWIFI_RGB_2.state as HSBType
redValue = hsbValue.red.intValue
greenValue = hsbValue.green.intValue
blueValue = hsbValue.blue.intValue
RGBvalues= redValue.toString + ";" + greenValue.toString + ";" + blueValue.toString
sendCommand( WIFI_RGB_2_RGB, RGBvalues )
logInfo( "fWIFI_RGB_2", RGBvalues )
end```
Check out the other topic http://forum.mysensors.org/topic/3664/mqtt-dimmer-message/7
By the way. What is the correct wiring?
The example on mysensors page shows no resistors. While the scematics on the internet state clearly that resistors are recommended.. Pic on the right...
No it's the stable one downloaded from the "API & Download" page. So i guess it's 1.5.4
In my sketch i found the
#define MY_LEDS_BLINKING_FEATURE
Is there a way to disable this completely or shall i define all 3 to the same unused pin?
//#define MY_DEFAULT_ERR_LED x
//#define MY_DEFAULT_TX_LED x
//#define MY_DEFAULT_RX_LED x
It goes off like it should. But than after 10 minutes or even more several flashes occur. Wiring is like on the mysensors page. The only thing under question should i interconnect the ground before the 12 to 5v converter and after? Or maybe add a resistor between the digital pin and mosfet
I've built the LED dimmer with the scheme on mysensors page. The only difference - i have 3 dimmers on pins D3,5,6 + MQ7 (A5) and DHT11 (D8).
Everything is working fine. But one of the led strips (not the longest one) flashes once in a while while switched off. 4-6 flashes of with different frequency and light power. Quite fast. Why is this happening? And how can this be fixed? Maybe some resistance to be added on the pin?
I'm running several sketches. DHT22 reports just fine values like xx.xx
But DHT11 reports 0 decimals. So it is always like xx.00
Is that standart for dht11?