Problems worh using mysensors
Moderator: leecollings
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Problems worh using mysensors
Hello,
A few days ago I installed domoticz on a raspberry pi 3, because I was inspired by mysensors.org. Building cheap sensors and controlling them with an easy to handle controller sounded very interesting.
But, now I am very frustrated.
I uploaded the serial gateway sketch from mysesnors examples to my serial gateway (not serialgateway485 sketch, running on arduino nano clone and a nrf24L01) using arduino IDE. I just modified the baud rate to 115200. domoticz recognizes the gateway as version 2.0.
I also uploaded the motion sketch from examples to a new arduino nano/nrf24L01 with antenna/PA and modified nothing.
Domoticz now is able to see the node, but it is named unknown. The child ID 255 (that must be wrong) is named S_ARDUINO_REPEATER_NODE - that is wrong, too. It has to be S_MOTION. Despite I was using the newest sketch, domoticz calls it version 1.0.
Could someone tell me the solution, please?
A few days ago I installed domoticz on a raspberry pi 3, because I was inspired by mysensors.org. Building cheap sensors and controlling them with an easy to handle controller sounded very interesting.
But, now I am very frustrated.
I uploaded the serial gateway sketch from mysesnors examples to my serial gateway (not serialgateway485 sketch, running on arduino nano clone and a nrf24L01) using arduino IDE. I just modified the baud rate to 115200. domoticz recognizes the gateway as version 2.0.
I also uploaded the motion sketch from examples to a new arduino nano/nrf24L01 with antenna/PA and modified nothing.
Domoticz now is able to see the node, but it is named unknown. The child ID 255 (that must be wrong) is named S_ARDUINO_REPEATER_NODE - that is wrong, too. It has to be S_MOTION. Despite I was using the newest sketch, domoticz calls it version 1.0.
Could someone tell me the solution, please?
- gizmocuz
- Posts: 2492
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Problems worh using mysensors
node child 255 is used internally, this is not a real sensor
Looks you programmed your child as repeater here....
Looks you programmed your child as repeater here....
Quality outlives Quantity!
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
But, how is that possible ?
I uploaded the mysensors example sketch for motion sensors to the nano. The sketch contains child ID 1 und S_MOTION.
Could it be a bug by domoticz in recognition of motion sensors ?
I uploaded the mysensors example sketch for motion sensors to the nano. The sketch contains child ID 1 und S_MOTION.
Could it be a bug by domoticz in recognition of motion sensors ?
- gizmocuz
- Posts: 2492
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Problems worh using mysensors
You always get child id 255
Now i suggest you do not mention 'bug' ... as we developers don't like that
No it is no bug
Now i suggest you do not mention 'bug' ... as we developers don't like that

No it is no bug
Quality outlives Quantity!
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Okay, not a bug...
Uploaded 1 unmodified sketch to the serial gateway -> domoticz recognizes it as gateway version 2.
Uploaded 1 unmodified motion-sketch to the arduino motion-nano -> domoticz names it unknown node and S_Arduino_Repeater_node.
I need help with this...
Uploaded 1 unmodified sketch to the serial gateway -> domoticz recognizes it as gateway version 2.
Uploaded 1 unmodified motion-sketch to the arduino motion-nano -> domoticz names it unknown node and S_Arduino_Repeater_node.
I need help with this...
- gizmocuz
- Posts: 2492
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Problems worh using mysensors
I dont know the original sketch... did you send a trigger to domoticz? Will this be recognized?
Quality outlives Quantity!
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Don´t really understand "trigger".
In a few hours I will me home again. Would like to post sketches of serial gateway and motion sensor.
In a few hours I will me home again. Would like to post sketches of serial gateway and motion sensor.
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Now, this is the code for my serial gateway to domoticz (arduino nano, NRF24L01+PA+ANTENNA)...
And this sketch is for the motion sensor (arduino nano, HC-SR501 and NRF24L01+PA+ANTENNA)...
Domoticz recognizes the motion sensor as "unknow" and S_ARDUINO_REPEATER.
Here´s the seriell monitor:
Hope, someone can help.
Code: Select all
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <[email protected]>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* DESCRIPTION
* The ArduinoGateway prints data received from sensors on the serial link.
* The gateway accepts input on seral which will be sent out on radio network.
*
* The GW code is designed for Arduino Nano 328p / 16MHz
*
* Wire connections (OPTIONAL):
* - Inclusion button should be connected between digital pin 3 and GND
* - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
*
* LEDs (OPTIONAL):
* - To use the feature, uncomment MY_LEDS_BLINKING_FEATURE in MyConfig.h
* - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
* - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
* - ERR (red) - fast blink on error during transmission error or recieve crc error
*
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Set LOW transmit power level as default, if you have an amplified NRF-module and
// power your radio separately with a good regulator you can turn up PA level.
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable serial gateway
#define MY_GATEWAY_SERIAL
// Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
#if F_CPU == 8000000L
#define MY_BAUD_RATE 115200
#endif
// Flash leds on rx/tx/err
#define MY_LEDS_BLINKING_FEATURE
// Set blinking period
#define MY_DEFAULT_LED_BLINK_PERIOD 300
// Inverses the behavior of leds
//#define MY_WITH_LEDS_BLINKING_INVERSE
// Enable inclusion mode
#define MY_INCLUSION_MODE_FEATURE
// Enable Inclusion mode button on gateway
#define MY_INCLUSION_BUTTON_FEATURE
// Inverses behavior of inclusion button (if using external pullup)
//#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
// Set inclusion mode duration (in seconds)
#define MY_INCLUSION_MODE_DURATION 60
// Digital pin used for inclusion mode button
#define MY_INCLUSION_MODE_BUTTON_PIN 3
// Uncomment to override default HW configurations
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <SPI.h>
#include <MySensors.h>
void setup() {
// Setup locally attached sensors
}
void presentation() {
// Present locally attached sensors
}
void loop() {
// Send locally attached sensor data here
}
And this sketch is for the motion sensor (arduino nano, HC-SR501 and NRF24L01+PA+ANTENNA)...
Code: Select all
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <[email protected]>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Motion Sensor example using HC-SR501
* http://www.mysensors.org/build/motion
*
*/
// Enable debug prints
// #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#include <SPI.h>
#include <MySensors.h>
unsigned long SLEEP_TIME = 120000; // Sleep time between reports (in milliseconds)
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define CHILD_ID 1 // Id of the sensor child
// Initialize motion message
MyMessage msg(CHILD_ID, V_TRIPPED);
void setup()
{
pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Motion Sensor", "1.0");
// Register all sensors to gw (they will be created as child devices)
present(CHILD_ID, S_MOTION);
}
void loop()
{
// Read digital motion value
boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
Serial.println(tripped);
send(msg.set(tripped?"1":"0")); // Send tripped value to gw
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
}
Here´s the seriell monitor:
Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
!TSM:FPAR:FAIL
!TSM:FAILURE
TSM:PDT
Hope, someone can help.
- gizmocuz
- Posts: 2492
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: Problems worh using mysensors
Try sending a V_TRIPPED like i said above, also make sure 'accept new hardware' is enabled in the settings
Quality outlives Quantity!
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Allowing new hardware is allowed.
But, could you please tell me how to send v_tripped.
But, could you please tell me how to send v_tripped.
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Do you mean serialprintln("V_TRIP") ?
I have attached what domoticz looks like.
Little help ?
I have attached what domoticz looks like.
Little help ?
- Attachments
-
- IMG_1021.jpg (352.03 KiB) Viewed 6835 times
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Okay, I have...
The motion sensor connected to the Arduino IDE. The output of the serial monitor (at this time the gateway was connected to the controller):
And at this point I had the gateway connected to the arduino IDE (the motion sensor was not connected to the computer):
I never had both, gateway and sensor, connected to the monitor at the same time. I am afraid, I didn´t understand to use MYScontroller. Did not find the com-port settings etc. So I can´t connect gateway and motion sensor at the same time to the pc to monitor output.
Does the output help ? Hope to get this work... it is frustrating.
The motion sensor connected to the Arduino IDE. The output of the serial monitor (at this time the gateway was connected to the controller):
Code: Select all
Starting sensor (RNNNA-, 2.0.0)
TSM:INIT
TSM:RADIO:OK
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
!TSM:FPAR:FAIL
!TSM:FAILURE
Code: Select all
0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
0;255;3;0;9;TSM:INIT
0;255;3;0;9;TSM:RADIO:OK
0;255;3;0;9;TSM:GW MODE
0;255;3;0;9;TSM:READY
0;255;3;0;14;Gateway startup complete.
0;255;0;0;18;2.0.0
0;255;3;0;9;No registration required
0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:SANCHK:OK
0;255;3;0;9;TSP:SANCHK:OK
Does the output help ? Hope to get this work... it is frustrating.
Re: Problems worh using mysensors
You need the output from the gateway when the node is conneccting to it.
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Okay, done it... both connected, gw on MYScontroller, motion sensor monitored using IDE...
Sensor output:
MYScontroller debug:
That´s strange, because there is no repeater... just a motion sensor sketch.
Sensor output:
And gateway output:TSM:INIT
TSM:RADIO:OK
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
TSM:FPAR
TSP:MSG:SEND 255-255-255-255 s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=bc:
!TSM:FPAR:FAIL
!TSM:FAILURE
TSM:PDT
MYScontroller debug:
MySensors debug:16.07.2016 19:43:42 INFO Flushing FIFO
16.07.2016 19:43:42 INFO Connected to COM7
16.07.2016 19:43:44 RX 0;255;3;0;9;Starting gateway (RNNGA-, 2.0.0)
16.07.2016 19:43:44 CHILD New child discovered, node id=0, child id=internal
16.07.2016 19:43:44 RX 0;255;3;0;9;TSM:INIT
16.07.2016 19:43:44 RX 0;255;3;0;9;TSM:RADIO:OK
16.07.2016 19:43:44 RX 0;255;3;0;9;TSM:GW MODE
16.07.2016 19:43:44 RX 0;255;3;0;9;TSM:READY
16.07.2016 19:43:44 RX 0;255;3;0;14;Gateway startup complete.
16.07.2016 19:43:44 RX 0;255;0;0;18;2.0.0
16.07.2016 19:43:44 DEBUG Update child id=255, type=S_ARDUINO_REPEATER_NODE
16.07.2016 19:43:44 RX 0;255;3;0;9;No registration required
16.07.2016 19:43:44 RX 0;255;3;0;9;Init complete, id=0, parent=0, distance=0, registration=1
16.07.2016 19:44:44 RX 0;255;3;0;9;TSP:SANCHK:OK
16.07.2016 19:45:44 RX 0;255;3;0;9;TSP:SANCHK:OK
Nodes debug: this message was shown before I connected the sensor to power8 16.07.2016 19:43:44 TX -1 -1 -1 -1 NA (-1) N/A NA (-1) -1 required
And messages tab:7 16.07.2016 19:43:44 0 - Gateway S_ARDUINO_REPEATER_NODE S_ARDUINO_REPEATER_NODE 2.0.0
Okay, hope, this helps now.6 16.07.2016 19:43:44 RX 0 - Gateway INTERNAL C_INTERNAL NO I_GATEWAY_READY Gateway startup complete.
7 16.07.2016 19:43:44 RX 0 - Gateway INTERNAL C_PRESENTATION NO S_ARDUINO_REPEATER_NODE 2.0.0
That´s strange, because there is no repeater... just a motion sensor sketch.
Re: Problems worh using mysensors
Do you have any other sensors you can test with?
A button or a temperature sensor?
Or just upload a random sketch to your node and see if it still present it selfe as a repeater.
It makes no sense taht it is presented as a repeaternode when you use the code you have posted.
A button or a temperature sensor?
Or just upload a random sketch to your node and see if it still present it selfe as a repeater.
It makes no sense taht it is presented as a repeaternode when you use the code you have posted.
-
- Posts: 11
- Joined: Tuesday 12 July 2016 22:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
Think, this is a problem of mysensors new library 2.0.
But, I have different other sensors like distance etc, but at the moment there are no example sketches for mysensors 2.0.
Think, the using of a NRF24L01 with amplifier is a cause. I do not have other than NRF amplified.
But, I have different other sensors like distance etc, but at the moment there are no example sketches for mysensors 2.0.
Think, the using of a NRF24L01 with amplifier is a cause. I do not have other than NRF amplified.
-
- Posts: 2
- Joined: Monday 01 August 2016 14:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
I got the same issue and i have the solution for it
I soldered a capacitor, 470uf 16v on the power supply pins on the rf24 board
the 470 uf is just what i had just around, any value between 47 uf and 470 uf is okay
put it at any node and gateway
Important is soldered, not put a capacitor loose in the jumper connections as a wacky connection is just plain bad
I soldered a capacitor, 470uf 16v on the power supply pins on the rf24 board
the 470 uf is just what i had just around, any value between 47 uf and 470 uf is okay
put it at any node and gateway
Important is soldered, not put a capacitor loose in the jumper connections as a wacky connection is just plain bad
-
- Posts: 2
- Joined: Monday 01 August 2016 14:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Problems worh using mysensors
for your other sensors like "distance" there are example sketches and libraries
https://github.com/mysensors/MySensorsArduinoExamples
copy those examples and libs to your arduino directory
But keep in mind there is some fiddling to do
this is a working sketch of a DHT temp and humidity sensor for mysensors 2.0
#include <DHT.h>
DHT dht;
// Enable debug prints
// #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
#include <SPI.h>
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 8
#include <MyConfig.h>
#include <MySensors.h>
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
float lastTemp;
float lastHum;
boolean metric = true;
boolean failedHum = false;
boolean failedTemp = false;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup()
{
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
metric = getConfig().isMetric;
}
void presentation()
{
// Present locally attached sensors
sendSketchInfo("garden2", "1.0");
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
}
void loop()
{
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
if (isnan(temperature)) {
failedTemp = true;
} else if (temperature != lastTemp) {
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
send(msgTemp.set(temperature, 1));
failedTemp = false;
}
float humidity = dht.getHumidity();
if (isnan(humidity)) {
failedHum = true;
} else if (humidity != lastHum) {
lastHum = humidity;
send(msgHum.set(humidity, 1));
failedHum = false;
}
sleep(SLEEP_TIME);
}
https://github.com/mysensors/MySensorsArduinoExamples
copy those examples and libs to your arduino directory
But keep in mind there is some fiddling to do
this is a working sketch of a DHT temp and humidity sensor for mysensors 2.0
#include <DHT.h>
DHT dht;
// Enable debug prints
// #define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
#include <SPI.h>
#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 8
#include <MyConfig.h>
#include <MySensors.h>
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds)
float lastTemp;
float lastHum;
boolean metric = true;
boolean failedHum = false;
boolean failedTemp = false;
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup()
{
dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);
metric = getConfig().isMetric;
}
void presentation()
{
// Present locally attached sensors
sendSketchInfo("garden2", "1.0");
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
}
void loop()
{
delay(dht.getMinimumSamplingPeriod());
float temperature = dht.getTemperature();
if (isnan(temperature)) {
failedTemp = true;
} else if (temperature != lastTemp) {
lastTemp = temperature;
if (!metric) {
temperature = dht.toFahrenheit(temperature);
}
send(msgTemp.set(temperature, 1));
failedTemp = false;
}
float humidity = dht.getHumidity();
if (isnan(humidity)) {
failedHum = true;
} else if (humidity != lastHum) {
lastHum = humidity;
send(msgHum.set(humidity, 1));
failedHum = false;
}
sleep(SLEEP_TIME);
}
Re: Problems worh using mysensors
The gateway is a repeater node in mysensors 2.
My radio's got working with a 47uF 16v. And it does not matter if I use the one with the big antenna or not. And yes solder it.
I also used
https://github.com/mysensors/MySensors/ ... Config.ino
To get a clean eeprom. Just to make sure no traces are left from my experimenting.
If you have problems with the radio try installing the RF24 library and test the radio's with the pingpair_ack example.
The pinouts i have
Gateway Advanced Gateway Gateway code
Bare Sensor (Pro mini 3.3v on battery, no sensors attached)
Sensor code with DHT attached to pin 3 on the pro mini 3.3v with battery level
probably want to change: wait(30000);
My radio's got working with a 47uF 16v. And it does not matter if I use the one with the big antenna or not. And yes solder it.
I also used
https://github.com/mysensors/MySensors/ ... Config.ino
To get a clean eeprom. Just to make sure no traces are left from my experimenting.
If you have problems with the radio try installing the RF24 library and test the radio's with the pingpair_ack example.
The pinouts i have
Gateway Advanced Gateway Gateway code
Code: Select all
#define MY_RADIO_NRF24
//#define MY_RF24_ENABLE_ENCRYPTION
#define MY_RF24_PA_LEVEL RF24_PA_LOW
#define MY_GATEWAY_SERIAL
#if F_CPU == 8000000L
#define MY_BAUD_RATE 38400
#endif
//#define MY_LEDS_BLINKING_FEATURE
//#define MY_DEFAULT_LED_BLINK_PERIOD 300
//#define MY_DEFAULT_ERR_LED_PIN 4 // Error led pin
//#define MY_DEFAULT_RX_LED_PIN 6 // Receive led pin
//#define MY_DEFAULT_TX_LED_PIN 5 // the PCB, on board LED
#include <SPI.h>
#include <MySensors.h>
void setup() {}
void presentation() {
sendSketchInfo("MySensors Gateway", "2.01");
}
void loop() {}
probably want to change: wait(30000);
Code: Select all
#define MY_RADIO_NRF24
#define MY_RF24_PA_LEVEL RF24_PA_LOW
//#define MY_RF24_ENABLE_ENCRYPTION
#if F_CPU == 8000000L
#define MY_BAUD_RATE 38400
#endif
#include <SPI.h>
#include <MySensors.h>
#include <DHT.h>
#define BATTERY_FULL 3143 // 2xAA usually give 3.143V when full
#define BATTERY_ZERO 2340 // 2.34V limit for 328p at 8MHz. 1.9V, limit for nrf24l01 without step-up. 2.8V limit for Atmega328 with default BOD settings.
#define CHILD_ID_BATTERY 0
#define CHILD_ID_HUM 1
#define CHILD_ID_TEMP 2
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
#define DHTTYPE DHT22
DHT dht(HUMIDITY_SENSOR_DIGITAL_PIN,DHTTYPE);
float lastTemp;
float lastHum;
// was too lazy to correct that...
boolean metric = true;
long oldvoltage = 0;
MyMessage voltage_msg(CHILD_ID_BATTERY, V_VOLTAGE);
MyMessage msgHum(CHILD_ID_HUM, V_HUM);
MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
void setup() {
}
void presentation() {
sendSketchInfo("MySensors TempHum", "2.02");
present(CHILD_ID_BATTERY, S_CUSTOM);
present(CHILD_ID_HUM, S_HUM);
present(CHILD_ID_TEMP, S_TEMP);
metric = true; //gw.getConfig().isMetric;
}
void loop() {
// Send locally attached sensor data here
long voltage = readVcc();
if (oldvoltage != voltage) { // Only send battery information if voltage has changed, to conserve battery.
send(voltage_msg.set(voltage / 1000.0, 3)); // redVcc returns millivolts. Set wants volts and how many decimals (3 in our case)
sendBatteryLevel(round((voltage - BATTERY_ZERO) * 100.0 / (BATTERY_FULL - BATTERY_ZERO)));
oldvoltage = voltage;
}
float temperature = dht.readTemperature();
if (isnan(temperature)) {
Serial.println("Failed reading temperature from DHT");
} else if (temperature != lastTemp) {
lastTemp = temperature;
// if (!metric) {
// temperature = dht.toFahrenheit(temperature);
// }
send(msgTemp.set(temperature, 1));
//Serial.print("T: ");
//Serial.println(temperature);
}
float humidity = dht.readHumidity();
if (isnan(humidity)) {
Serial.println("Failed reading humidity from DHT");
} else if (humidity != lastHum) {
lastHum = humidity;
send(msgHum.set(humidity, 1));
//Serial.print("H: ");
//Serial.println(humidity);
}
wait(30000);
}
long readVcc() {
// From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/
// Read 1.1V reference against AVcc
// set the reference to Vcc and the measurement to the internal 1.1V reference
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
ADMUX = _BV(MUX5) | _BV(MUX0);
#elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
ADMUX = _BV(MUX3) | _BV(MUX2);
#else
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
#endif
wait(2);
//delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Start conversion
while (bit_is_set(ADCSRA, ADSC)); // measuring
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
uint8_t high = ADCH; // unlocks both
long result = (high << 8) | low;
result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
return result; // Vcc in millivolts
}
Last edited by trixwood on Monday 01 August 2016 20:33, edited 4 times in total.
Re: Problems worh using mysensors
This is the result.
Where you can delete the lonely Temp or Hum sensor (temp in this case) those do not get updated.
Use the combined one. (the voltage and battery is wrong but I ran it on an uno
Anyway no idea why I post this, maybe I am just happy the started working a couple of days ago.
Where you can delete the lonely Temp or Hum sensor (temp in this case) those do not get updated.
Use the combined one. (the voltage and battery is wrong but I ran it on an uno

Anyway no idea why I post this, maybe I am just happy the started working a couple of days ago.
Last edited by trixwood on Monday 01 August 2016 19:16, edited 2 times in total.
Who is online
Users browsing this forum: No registered users and 1 guest