Echoing what @emc2 said. RCSwitch worked great for my 433 project a few months ago.
https://forum.mysensors.org/topic/4962/laser-christmas-light-control-433mhz/14
Echoing what @emc2 said. RCSwitch worked great for my 433 project a few months ago.
https://forum.mysensors.org/topic/4962/laser-christmas-light-control-433mhz/14
Yep. I think it's the default icon that's used when the JSON points to the wrong image, or the image is not available.
Are you using UI7? Can you send me a screenshot of Temperature node? Maybe the XML/JSON behind it? I'd like to compare it to what I'm running.
Hey Hek!
Thanks for responding on a rather mundane issue. Browser connectivity is OK. In fact, your smiling guy (also your avatar here) loads OK on the "main" plugin. Also, the "integrated circuit" icon loads on each of the node definitions.
However, the devices themselves (relays, meters, etc) don't appear to be loading.
Hello All -
I did download the newest Vera files and uploaded them. However, I'm missing icons on some of my devices. Can someone give me some ideas?!
I thought I'd report back with my code. The sensor is up and running. I don't like that I just had to present switches but I'm not skilled enough to use the "custom" field and make a control in Vera. (On/Off, Blue, Red, Green, Motion) So this will have to do for now. It's probably OK as I'm just going to use automation to actuate the switches.
/**
* 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 <henrik.ekblad@mysensors.org>
* 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.
*
*******************************
*
*
*Power= 010101101010010100000001
*Red= 010101101010010100000010
*Green= 010101101010010100001000
*Blue= 010101101010010100001110
*down = 010101101010010100000100
*up= 010101101010010100010110
Decimal: 5678338 (24Bit) Binary: 010101101010010100000010 Tri-State: not applicable PulseLength: 310 microseconds Protocol: 1
Raw data: 9624,192,1032,808,416,232,988,840,384,256,964,872,360,876,340,288,936,884,336,288,936,888,336,284,936,284,940,884,340,284,936,884,340,284,936,288,936,284,940,284,936,284,940,284,936,884,336,288,936,
*
*
*
*
*
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
//#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#include <RCSwitch.h>
#define POWER_BUTTON 1
#define RED_BUTTON 2
#define GREEN_BUTTON 3
#define BLUE_BUTTON 4
#define NoMotion_BUTTON 5
#define MedMotion_BUTTON 6
#define FastMotion_BUTTON 7
unsigned long delay_time = 500;
bool state;
MyMessage msg_power(POWER_BUTTON,V_LIGHT);
MyMessage msg_red(RED_BUTTON,V_LIGHT);
MyMessage msg_green(GREEN_BUTTON,V_LIGHT);
MyMessage msg_blue(BLUE_BUTTON,V_LIGHT);
MyMessage msg_NoMotion(NoMotion_BUTTON,V_LIGHT);
MyMessage msg_MedMotion(MedMotion_BUTTON,V_LIGHT);
MyMessage msg_FastMotion(FastMotion_BUTTON,V_LIGHT);
RCSwitch mySwitch = RCSwitch();
void before() {
}
void setup() {
mySwitch.enableTransmit(8);
mySwitch.setPulseLength(298);
mySwitch.setRepeatTransmit(2);
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Christmas Laser Control", "1.0");
present (POWER_BUTTON, S_LIGHT);
present (RED_BUTTON, S_LIGHT);
present (GREEN_BUTTON, S_LIGHT);
present (BLUE_BUTTON, S_LIGHT);
present (NoMotion_BUTTON, S_LIGHT);
present (MedMotion_BUTTON, S_LIGHT);
present (FastMotion_BUTTON, S_LIGHT);
}
void loop() {
// if (state) {
// Serial.println("State is true");
//send(msg.set(state?false:true), false); // Send new state and request ack back
// send(msg.setSensor(RED_CONTROLLER).set(0));
// state = false;
// }
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.isAck()) {
Serial.println("This is an ack from gateway");
}
if (message.type==V_LIGHT) {
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
if (message.getBool()){
if (message.sensor == POWER_BUTTON) {
Serial.println ("Sending POWER data");
mySwitch.send("010101101010010100000001");
Serial.println ("Turn POWER_BUTTON off in Vera");
send(msg_power.setSensor(POWER_BUTTON).set(0), true);
}
else if (message.sensor == RED_BUTTON) {
Serial.println ("Sending RED data");
mySwitch.send("010101101010010100000010");
Serial.println ("Turn RED_BUTTON off in Vera");
send(msg_red.setSensor(RED_BUTTON).set(0), true);
}
else if (message.sensor == GREEN_BUTTON) {
Serial.println ("Sending GREEN data");
mySwitch.send("010101101010010100001000");
Serial.println ("Turn GREEN_BUTTON off in Vera");
send(msg_green.setSensor(GREEN_BUTTON).set(0), true);
}
else if (message.sensor == BLUE_BUTTON) {
Serial.println ("Sending BLUE data");
mySwitch.send("010101101010010100001110");
Serial.println ("Turn BLUE_BUTTON in Vera");
send(msg_blue.setSensor(BLUE_BUTTON).set(0), true);
}
else if (message.sensor == NoMotion_BUTTON) {
Serial.println ("Sending No Motion data");
mySwitch.send("010101101010010100000100");
delay(delay_time);
mySwitch.send("010101101010010100000100");
delay(delay_time);
mySwitch.send("010101101010010100000100");
Serial.println ("Turn No Motion in Vera");
send(msg_blue.setSensor(NoMotion_BUTTON).set(0), true);
}
else if (message.sensor == MedMotion_BUTTON) {
Serial.println ("Sending Medium Motion data");
mySwitch.send("010101101010010100000100");//down
delay(delay_time);
mySwitch.send("010101101010010100000100");//down
delay(delay_time);
mySwitch.send("010101101010010100010110");//up
Serial.println ("Turn Medium Motion in Vera");
send(msg_blue.setSensor(MedMotion_BUTTON).set(0), true);
}
else if (message.sensor == FastMotion_BUTTON) {
Serial.println ("Sending Fast Motion data");
mySwitch.send("010101101010010100010110");
delay(delay_time);
mySwitch.send("010101101010010100010110");
delay(delay_time);
mySwitch.send("010101101010010100010110");
Serial.println ("Turn Fast Motion in Vera");
send(msg_blue.setSensor(FastMotion_BUTTON).set(0), true);
}
}
// Store state in eeprom
// saveState(message.sensor, message.getBool());
}
}
@petewill ARGH! Of course! That was it! OK, this should get me going for a bit. Thanks so much!
I will work on this more and report back! Love these forums and how helpful they are. Hopefully, I will be able to return the favor someday!
With the help of @petewill in a chat session, I was able to figure out why I couldn't send messages back.
I was failing to instantiate:
MyMessage msg(RED_CONTROLLER,S_LIGHT);
I'm only concentrating on the "red" case at the moment. As you can see from the log, I'm sending a "0" back to Vera but Vera is not showing off in the console. ** Am I not resetting the state correctly?**
Incoming change for sensor:2, New status: 1
Get ready to send radio message
Sending RED data
Turn RED_CONTROLLER off in Vera
TSP:MSG:SEND 1-1-6-0 s=2,c=1,t=3,pt=2,l=2,sg=0,ft=0,st=ok:0
// Enable debug prints to serial monitor
#define MY_DEBUG
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
//#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#define POWER_CONTROLLER 1
#define RED_CONTROLLER 2
#define GREEN_CONTROLLER 3
#define BLUE_CONTROLLER 4
bool state;
MyMessage msg(RED_CONTROLLER,S_LIGHT);
void before() {
}
void setup() {}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Christmas Laser Control", "1.0");
present (POWER_CONTROLLER, S_LIGHT);
present (RED_CONTROLLER, S_LIGHT);
present (GREEN_CONTROLLER, S_LIGHT);
present (BLUE_CONTROLLER, S_LIGHT);
}
void loop() {
// if (state) {
// Serial.println("State is true");
//send(msg.set(state?false:true), false); // Send new state and request ack back
// send(msg.setSensor(RED_CONTROLLER).set(0));
// state = false;
}
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.isAck()) {
Serial.println("This is an ack from gateway");
}
if (message.type==V_LIGHT) {
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
if (message.getBool()){
//send data for appropriate "button" and then toggle controller back to "off"/false
Serial.println ("Get ready to send radio message");
//send appropriate data here
if (message.sensor == POWER_CONTROLLER) {
Serial.println ("Sending POWER data");
//send 433 mhz RF data and turn switch back off
}
else if (message.sensor == RED_CONTROLLER) {
Serial.println ("Sending RED data");
//send data here
wait (5000);
Serial.println ("Turn RED_CONTROLLER off in Vera");
send(msg.setSensor(RED_CONTROLLER).set(0));
}
else if (message.sensor == GREEN_CONTROLLER) {
Serial.println ("Sending GREEN data");
//send 433 mhz RF data and turn switch back off
}
else if (message.sensor == BLUE_CONTROLLER) {
Serial.println ("Sending BLUE data");
//send 433 mhz RF data and turn switch back off
}
}
// Store state in eeprom
// saveState(message.sensor, message.getBool());
}
}
@petewill Because when the V_LIGHT sensor is switched "on" in Vera, I will fall in to the proper "if" condition above. However, I need to switch it back off after I send the data so I can later toggle it again. I wish there was a "button device" so I didn't have to worry about it.
else if (message.sensor == RED_CONTROLLER) {
Serial.println ("Sending RED data");
//send 433 mhz RF data and turn switch back off
}
@petewill Good question. I meant the home controller. The remote is completely out of the picture now. Using your ideas, I was able to figure out all the codes and can send them successfully via a test script. The hard part is done, ironically!
I'm just not a great code guy.....
I haven't put that logic in to my script yet. Instead, I'm trying to figure out how to "bounce" a light switch. When the home automation controller sends an "on" for a certain function, I'll send the RF data and then switch it back "off" to be ready for the next command/"button press" later. That's the part I'm having trouble with....
I'm forging ahead with multiple switches (lights) until someone can help me think through the best way to present to the controller. I'm trying to work out the logic to simulate a button-press.
When someone/something presses "on" in the controller, the sensor will determine which button/light was pressed, send the appropriate data and then toggle the device back off. I've never updated a switch status back to the controller. My use of "send" below is clearly invalid.
#define MY_DEBUG
#define MY_RF24_PA_LEVEL RF24_PA_LOW
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
//#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensors.h>
#define POWER_CONTROLLER 1
#define RED_CONTROLLER 2
#define GREEN_CONTROLLER 3
#define BLUE_CONTROLLER 4
void before() {}
void setup() {}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Christmas Laser Control", "1.0");
present (POWER_CONTROLLER, S_LIGHT);
present (RED_CONTROLLER, S_LIGHT);
present (GREEN_CONTROLLER, S_LIGHT);
present (BLUE_CONTROLLER, S_LIGHT);
}
void loop() {}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
if (message.getBool()){
//send data for appropriate "button" and then toggle controller back to "off"/false
Serial.println ("Get ready to send radio message");
//send appropriate data here
if (message.sensor == POWER_CONTROLLER) {
Serial.println ("Sending POWER data");
//send 433 mhz RF data and turn switch back off
}
else if (message.sensor == RED_CONTROLLER) {
Serial.println ("Sending RED data");
//send 433 mhz RF data and turn switch back off
}
else if (message.sensor == GREEN_CONTROLLER) {
Serial.println ("Sending GREEN data");
//send 433 mhz RF data and turn switch back off
}
else if (message.sensor == BLUE_CONTROLLER) {
Serial.println ("Sending BLUE data");
//send 433 mhz RF data and turn switch back off
}
// delay (1000);
// send(message.set(0));
}
// Store state in eeprom
// saveState(message.sensor, message.getBool());
}
}
Well, I made some progress today. I was able to sniff the traffic, determine the pulse width, and put together a simple sketch to test it. I had to modify the antenna on the transmitter as well as the one on the receiver inside the light. I'm now able to control it from anywhere in the house. Prior, only a few feet would work.
However, I'm still not clear on how I'll present this to the controller.
Here are the codes for the record:
Power= 010101101010010100000001
Red= 010101101010010100000010
Green= 010101101010010100001000
Blue= 010101101010010100001110
down = 010101101010010100000100
up= 010101101010010100010110
Pulse width was measured at 310 ms. However, using my ear, it sounds and works better if set at 298ms.
Any more thoughts on the controller side? Would really be helpful. I'm just not a very creative coder.
Thanks!
Hey All -
I'm working on a sensor where I will want to actuate something momentarily. Specifically, I want to send a stream of data via a 433mhz transmitter. But this could be as something as simple as latching/un-latching a relay (simulating a button-push, etc).
I'm not sure what device to use from a controller perspective.
Should I just use a switch that is normally in a state of "off"? When Vera sets the device to "on", do "whatever" in the sketch (set a bit in the sketch, etc), and then have the sketch turn the switch status back off in Vera? Seems like kind of a hack. Is there a "push button" device type?
@petewill Ah! I didn't think of exposing multiple sensors/devices! Ugh! I will think on this. The problem is, each button is momentary (not a switch/dimmer) so I'm not sure I have the experience to handle that. (good with electronics - not so good in the coding world) Although, I seem to remember others talking about momentary actions in the forums..... I'm sure it has been tackled.
@hek I didn't know about that device..... I'm going to check in to that as well.
Thanks!
Hello All -
I recently purchased a pretty neat laser/projector from: http://www.laserchristmaslights.com/
I control my annual display by a few Z-Wave Outlets/Modules and Vera Scenes. The problem with this laser (I knew this when purchasing) is that it doesn't "remember" the mode it was in prior to shutdown. While I purchased the "moving lasers" product, I knew that I initially intended to use it in its static mode to keep things less busy. The problem is it comes up in "moving mode" regardless of initial settings.
No problem, I figured. I originally thought it was going to be an IR remote and was going to use a blaster to remind it to not move. Short of that, I also considered manually hacking the remote (bought an extra one!) and just momentarily close the button (relay, etc) to set the correct state.
After receiving the product, I realized that it was a 433MHZ remote. I remember reading a thread by @petewill to control his RF blinds: https://forum.mysensors.org/topic/7/controlling-blinds-com-rf-dooya-motors-with-arduino-and-vera
While I haven't completely finished sniffing the remote's traffic, I have successfully been able to "hear" it with a receiver as outlined by Pete.
I want to mimic 7 different buttons:
My Main Issue/Question at the Moment
I'm not entirely clear how to present the sensor to the gateway/controller. Again, I'm using Vera and everything I'm reading at https://www.mysensors.org/download/serial_api_20#sensor-type doesn't show a clear match for what I'm trying to achieve.
Any thoughts?
I'm including @petewill 's thread for appropriate credit as I'm generally modeling his methods: https://forum.mysensors.org/topic/7/controlling-blinds-com-rf-dooya-motors-with-arduino-and-vera
It would be great if there was a version of this that had line level converters built in. (For those of us using non 3.3v Arduinos)
Last night I found that I could put my thumb on the sensor's antenna and the sensor would then work flawlessly. After switching radios on both the sensor and gateway without luck, I reduced the power on the sensor. This has seemed to fix the issue for now.
By the way, I'm using a separate 3.3v supply, capacitor on the radios - the works.
Thanks for the quick response. I will enable debug on the sensor and see if I can capture some errors. The problem with debugging on the gateway-side is this is controller-induced. There's no way (to my knowledge) to see gateway debug messages while connected to the controller. I wish the Vera plugin had an inherent way to log to the Vera filesystem.
Hello Friends -
I have a rather strange issue that I'd like to float by you. I will hold up on sending sketch information, etc unless we feel it's necessary (just don't want to confuse the situation).
I have a sensor that does pulse counting (water flow) and also controls one relay. Using Vera as my controller and an ethernet gateway, I've noticed on many occasions that when I actuate the relay, the relay moves as commanded but the status doesn't always get updated in Vera. I sometimes have to click the on/off button several times to get the state to update correctly. (The "light bulb" on the Vera GUI.)
Any thoughts on where I should start troubleshooting? I'm guessing it's radio/comms issues on either the sensor or gateway. I do have several "one way" sensors (temperature, etc) around the home that seem to work just fine. My relay sensors are the only ones where I command "MySensors" to do something via the controller.
Thanks for any starts you can provide.
I'm interested in what you learn here. I'm not much of developer (ok - I'm NOT a developer! haha!) but would like to do something similar and posted a thread about it a few months ago. I think I was in the wrong section as I never got a response.
Hey there. Sorry for the delay. I never get notifications on this board for some reason.
I'm using one of these:
http://www.amazon.com/dp/B00EVKVM02/ref=pe_385040_30332190_TE_3p_dp_1
And one of these for my sprinkler 3/4 line:
http://www.amazon.com/dp/B00EVKOK6A/ref=pe_385040_30332190_TE_3p_dp_2
http://www.amazon.com/gp/product/B009YVCMX4?psc=1&redirect=true&ref_=oh_aui_search_detailpage
I couldn't find the 1" valve to go with the sensor but you get the idea. I'm just switching those with normal relays tied to the appropriate pins.
Funny you should ask about this, however. I'm actually not overly thrilled with the flow sensors (especially the 1" model). It doesn't seem to detect low flow rates. Either my sketch isn't sensitive enough (maybe my debounce is screwed up) or it doesn't pulse for lower speeds.
I'm considering another type of flow meter but 1) haven't found one yet 2) not looking forward to re-plumbing everything.
@mfalkvidd said in Step-by-step procedure to connect the NRF24L01 to the GPIO pins and use the Raspberry as a Serial Gateway.:
@Eawo Yes, it should work. I ran Domoticz and MySensors Gateway on my Raspberry Pi 1 when I first tried MySensors. If I remember correctly I had to connect CE to pin 15 instead of 22 but I am not sure why. Try using the same connections as on your Raspberry Pi 2 first, and switch CE pin if you get "check wires". Please report back here how it goes, so I can add the necessary information to the original post.
For what it's worth, this is correct. I'm currently running on a Pi 1 and put CE on 15.
I followed these instructions and it worked perfectly with no fuss: http://forum.mysensors.org/topic/1151/tutorial-raspberry-pi-nrf24l01-direct-connection
@martinhjelmare said:
Doesn't the provided init script in the library already have logging? I didn't get around to testing this setup after my initial attempt failed, so I might be wrong.
https://github.com/mysensors/Raspberry/blob/master/initscripts/PiGatewaySerial
Ugh! Correct. Also, @mfalkvidd did cover this with his "MAKE THE GATEWAY AUTOSTART" section.....If I only could read! I will test this soon to see how the logging works.
Finally, by enabling ser2net and adding something like this to /etc/ser2net.conf:
5003:raw:600/dev/ttyMySensorsGateway
....you have yourself an Ethernet Gateway! Great stuff! Thanks again!
Great write-up! Should we consider instructions on how to create an init.d start/stop script so it can run as a daemon? I've done this, however, I'm having a hard time getting the output to log to syslog. (would be nice for monitoring/diagnostics purposes) The logging doesn't happen until I stop/kill the service.
pi@homeauto01 ~ $ cat /etc/init.d/PiGatewaySerial
#! /bin/sh
# /etc/init.d/PiGatewaySerial
### BEGIN INIT INFO
# Provides: PiGatewaySerial
# Required-Start: $all
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop PiGatewaySerial
# Description: PiGatewaySerial
### END INIT INFO
# The following part carries out specific functions depending on arguments.
case "$1" in
start)
echo "Starting PiGatewaySerial"
/root/Raspberry/PiGatewaySerial 2>&1 | logger &
;;
stop)
echo "Stopping PiGatewaySerial"
killall PiGatewaySerial
;;
*)
echo "Usage: /etc/init.d/PiGatewaySerial {start|stop}"
exit 1
;;
esac
exit 0
To close the loop on this (and to help future dwellers), a new board solved the issue. Not sure what wasn't working properly on the old board but I'm up and running again (with the same old radio, supply, etc).
Also, since I've learned a little and now understand a few of the configs better since my original iBoard build, I was able to do this WITHOUT the hardware mod.
I set the following in MyConfig.H:
const uint8_t SOFT_SPI_MISO_PIN = 6;
const uint8_t SOFT_SPI_MOSI_PIN = 5;
const uint8_t SOFT_SPI_SCK_PIN = 7;
My failure from several months ago was not setting the CE and SS pins properly in my sketch. I also took @Dwalt 's advice and updated my inclusion and LED pins (even though I didn't use them):
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN 14 // Digital pin used for inclusion mode button A0
#define RADIO_CE_PIN 3 // radio chip enable
#define RADIO_SPI_SS_PIN 8 // radio SPI serial select
#define RADIO_ERROR_LED_PIN 15 // Error led pin A1
#define RADIO_RX_LED_PIN 16 // Receive led pin A2
#define RADIO_TX_LED_PIN 17 // the PCB, on board LED A3
Hello everyone! Great work here! I see this is still running the 1.4 protocol, is that right? I was able to get this working but only my temp sensors would respond. Anything where I had to send data wouldn't work.
Any chance of moving to 1.5 in the near future?
Thanks!
Thanks @Dwalt I'm pulling my hair out here.
Pin 5 should matter (nor should the others) as it is freed up with the "hardware mod" of @gregl 's engineering.
I changed all four settings anyway, just in case. No go.
Starting to wonder if something is going on with the board.......
Hello Everyone. Sorry to bother you. I somehow screwed up my iBoard (hardware / trace modification) sketch/config today and was hoping someone could help me think through this.
I was having a problem with one of my far away sensors from hearing the gateway so I thought I'd increase power. When I compiled and uploaded the code, I started getting: "0;0;3;0;9;radio init fail"
I thought maybe my MyConfig.H file was incorrect. However, I referenced this schematic (and took in to account @gregl 's wiring changes), and my values look OK. The original setup URL referenced by Greg no longer exists on the MySensor page. Mysensors Ethernet
I tried changing the radio and supply on a whim. That didn't make a difference (not surprised as it has been working fine for months before trying to change the power setting)
Here's my sketch followed by my config file. Please help.....
Sketch
/**
* 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 <henrik.ekblad@mysensors.org>
* 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
* Contribution by a-lurker and Anticimex,
* Contribution by Norbert Truchsess <norbert.truchsess@t-online.de>
*
*
* DESCRIPTION
* The EthernetGateway sends data received from sensors to the ethernet link.
* The gateway also accepts input on ethernet interface, which is then sent out to the radio network.
*
* The GW code is designed for Arduino 328p / 16MHz. ATmega168 does not have enough memory to run this program.
*
*
* COMPILING WIZNET (W5100) ETHERNET MODULE
* > Edit MyConfig.h in (libraries\MySensors\) to enable softspi (remove // before "#define SOFTSPI").
*
* COMPILING ENC28J60 ETHERNET MODULE
* > Use Arduino IDE 1.5.7 (or later)
* > Disable DEBUG in Sensor.h before compiling this sketch. Othervise the sketch will probably not fit in program space when downloading.
* > Remove Ethernet.h include below and include UIPEthernet.h
* > Remove DigitalIO include
* Note that I had to disable UDP and DHCP support in uipethernet-conf.h to reduce space. (which means you have to choose a static IP for that module)
*
* VERA CONFIGURATION:
* Enter "ip-number:port" in the ip-field of the Arduino GW device. This will temporarily override any serial configuration for the Vera plugin.
* E.g. If you want to use the defualt values in this sketch enter: 192.168.178.66:5003
*
* LED purposes:
* - To use the feature, uncomment WITH_LEDS_BLINKING 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
*
* See http://www.mysensors.org/build/ethernet_gateway for wiring instructions.
*
*/
#define NO_PORTB_PINCHANGES
#include <DigitalIO.h> // This include can be removed when using UIPEthernet module
#include <SPI.h>
#include <MySigningNone.h>
#include <MyTransportRFM69.h>
#include <MyTransportNRF24.h>
#include <MyHwATMega328.h>
#include <MySigningAtsha204Soft.h>
#include <MySigningAtsha204.h>
#include <MyParserSerial.h>
#include <MySensor.h>
#include <stdarg.h>
#include <PinChangeInt.h>
#include "GatewayUtil.h"
// Use this if you have attached a Ethernet ENC28J60 shields
// #include <UIPEthernet.h>
// Use this for WizNET W5100 module and Arduino Ethernet Shield
#include <Ethernet.h>
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN 5 // Digital pin used for inclusion mode button
#define RADIO_CE_PIN 3 // radio chip enable
#define RADIO_SPI_SS_PIN 8 // radio SPI serial select
#define RADIO_ERROR_LED_PIN 11 // Error led pin
#define RADIO_RX_LED_PIN 12 // Receive led pin
#define RADIO_TX_LED_PIN 13 // the PCB, on board LED
// NRFRF24L01 radio driver (set low transmit power by default)
MyTransportNRF24 transport(RADIO_CE_PIN, RADIO_SPI_SS_PIN, RF24_PA_LEVEL_GW);
//MyTransportRFM69 transport;
// Message signing driver (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
//MySigningNone signer;
//MySigningAtsha204Soft signer;
//MySigningAtsha204 signer;
// Hardware profile
MyHwATMega328 hw;
// Construct MySensors library (signer needed if MY_SIGNING_FEATURE is turned on in MyConfig.h)
// To use LEDs blinking, uncomment WITH_LEDS_BLINKING in MyConfig.h
#ifdef WITH_LEDS_BLINKING
MySensor gw(transport, hw /*, signer*/, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);
#else
MySensor gw(transport, hw /*, signer*/);
#endif
#define IP_PORT 5003 // The port you want to open
IPAddress myIp (192, 168, 34, 13); // Configure your static ip-address here COMPILE ERROR HERE? Use Arduino IDE 1.5.7 or later!
// The MAC address can be anything you want but should be unique on your network.
// Newer boards have a MAC address printed on the underside of the PCB, which you can (optionally) use.
// Note that most of the Ardunio examples use "DEAD BEEF FEED" for the MAC address.
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // DEAD BEEF FEED
// a R/W server on the port
EthernetServer server = EthernetServer(IP_PORT);
// handle to open connection
EthernetClient client = EthernetClient();
char inputString[MAX_RECEIVE_LENGTH] = ""; // A string to hold incoming commands from serial/ethernet interface
int inputPos = 0;
bool sentReady = false;
void output(const char *fmt, ... ) {
va_list args;
va_start (args, fmt );
vsnprintf_P(serialBuffer, MAX_SEND_LENGTH, fmt, args);
va_end (args);
Serial.print(serialBuffer);
server.write(serialBuffer);
}
void setup()
{
Ethernet.begin(mac, myIp);
setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
// Add interrupt for inclusion button to pin
PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
// give the Ethernet interface a second to initialize
delay(1000);
// Initialize gateway at maximum PA level, channel 70 and callback for write operations
gw.begin(incomingMessage, 0, true, 0);
// start listening for clients
server.begin();
}
void loop() {
gw.process();
checkButtonTriggeredInclusion();
checkInclusionFinished();
// if an incoming client connects, there will be
// bytes available to read via the client object
EthernetClient newclient = server.available();
// if a new client connects make sure to dispose any previous existing sockets
if (newclient) {
if (client != newclient) {
client.stop();
client = newclient;
output(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
}
}
if (client) {
if (!client.connected()) {
client.stop();
} else if (client.available()) {
// read the bytes incoming from the client
char inChar = client.read();
if (inputPos<MAX_RECEIVE_LENGTH-1) {
// if newline then command is complete
if (inChar == '\n') {
Serial.println("Finished");
// a command was issued by the client
// we will now try to send it to the actuator
inputString[inputPos] = 0;
// echo the string to the serial port
Serial.print(inputString);
parseAndSend(gw, inputString);
// clear the string:
inputPos = 0;
} else {
// add it to the inputString:
inputString[inputPos] = inChar;
inputPos++;
}
} else {
// Incoming message too long. Throw away
inputPos = 0;
}
}
}
}
Config File
/**
* 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 <henrik.ekblad@mysensors.org>
* 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.
*/
#ifndef MyConfig_h
#define MyConfig_h
#include <stdint.h>
// Enable debug flag for debug prints. This will add a lot to the size of the final sketch but good
// to see what is actually is happening when developing
#define DEBUG
// Disable this line, If you are using TX(1), RX(0) as normal I/O pin
#define ENABLED_SERIAL
// Serial output baud rate (for debug prints and serial gateway)
#define BAUD_RATE 115200
/**********************************
* Over the air firmware updates
***********************************/
// The following define enables the safe over-the-air firmware update feature
// which requires external flash and the DualOptiBoot bootloader.
// Note: You can still have OTA FW updates without external flash but it
// requires the MYSBootloader and disabled MY_OTA_FIRMWARE_FEATURE
//#define MY_OTA_FIRMWARE_FEATURE
// Slave select pin for external flash
#define MY_OTA_FLASH_SS 8
// Flash jdecid
#define MY_OTA_FLASH_JDECID 0x1F65
/**********************************
* Information LEDs blinking
***********************************/
// This feature enables LEDs blinking on message receive, transmit
// or if some error occured. This was commonly used only in gateways,
// but now can be used in any sensor node. Also the LEDs can now be
// disabled in the gateway.
// #define WITH_LEDS_BLINKING
// The following setting allows you to inverse the blinking feature WITH_LEDS_BLINKING
// When WITH_LEDS_BLINKING_INVERSE is enabled LEDSs are normally turned on and switches
// off when blinking
//#define WITH_LEDS_BLINKING_INVERSE
// default LEDs blinking period in milliseconds
#define DEFAULT_LED_BLINK_PERIOD 300
// The RX LED default pin
#define DEFAULT_RX_LED_PIN 6
// The TX LED default pin
#define DEFAULT_TX_LED_PIN 5
// The Error LED default pin
#define DEFAULT_ERR_LED_PIN 4
/**********************************
* Message Signing Settings
***********************************/
// Disable to completly disable signing functionality in library
//#define MY_SIGNING_FEATURE
// Define a suitable timeout for a signature verification session
// Consider the turnaround from a nonce being generated to a signed message being received
// which might vary, especially in networks with many hops. 5s ought to be enough for anyone.
#define MY_VERIFICATION_TIMEOUT_MS 5000
// Enable to turn on whitelisting
// When enabled, a signing node will salt the signature with it's unique signature and nodeId.
// The verifying node will look up the sender in a local table of trusted nodes and
// do the corresponding salting in order to verify the signature.
// For this reason, if whitelisting is enabled on one of the nodes in a sign-verify pair, both
// nodes have to implement whitelisting for this to work.
// Note that a node can still transmit a non-salted message (i.e. have whitelisting disabled)
// to a node that has whitelisting enabled (assuming the receiver does not have a matching entry
// for the sender in it's whitelist)
//#define MY_SECURE_NODE_WHITELISTING
// MySigningAtsha204 default setting
#define MY_ATSHA204_PIN 17 // A3 - pin where ATSHA204 is attached
// MySigningAtsha204Soft default settings
#define MY_RANDOMSEED_PIN 7 // A7 - Pin used for random generation (do not connect anything to this)
// Key to use for HMAC calculation in MySigningAtsha204Soft (32 bytes)
#define MY_HMAC_KEY 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
/**********************************
* NRF24L01 Driver Defaults
***********************************/
#define RF24_CE_PIN 9 //norm
#define RF24_CS_PIN 10 //norm
//#define RF24_CE_PIN 3 //gateway
//#define RF24_CS_PIN 8 //gateway
//#define RF24_CE_PIN 17 //lcd controller
//#define RF24_CS_PIN 18 //lcd controller
#define RF24_PA_LEVEL RF24_PA_LOW
#define RF24_PA_LEVEL_GW RF24_PA_LOW
// RF channel for the sensor net, 0-127
#define RF24_CHANNEL 76
//RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
#define RF24_DATARATE RF24_250KBPS
// This is also act as base value for sensor nodeId addresses. Change this (or channel) if you have more than one sensor network.
#define RF24_BASE_RADIO_ID ((uint64_t)0xA8A8E1FC00LL)
// Enable SOFTSPI for NRF24L01 when using the W5100 Ethernet module
#define SOFTSPI
#ifdef SOFTSPI
// Define the soft SPI pins used for NRF radio
//const uint8_t SOFT_SPI_MISO_PIN = 16; //norm - scene controller
//const uint8_t SOFT_SPI_MOSI_PIN = 15; //norm - scene controller
//const uint8_t SOFT_SPI_SCK_PIN = 14; //norm - scene controller
const uint8_t SOFT_SPI_MISO_PIN = 12; //gateway
const uint8_t SOFT_SPI_MOSI_PIN = 11; //gateway
const uint8_t SOFT_SPI_SCK_PIN = 13; //gateway
#endif
/**********************************
* RFM69 Driver Defaults
***********************************/
// Default network id. Use the same for all nodes that will talk to each other
#define RFM69_NETWORKID 100
// Default frequency to use. This must match the hardware version of the RFM69 radio (uncomment one):
// #define RFM69_FREQUENCY RF69_433MHZ
#define RFM69_FREQUENCY RF69_868MHZ
//#define FREQUENCY RF69_915MHZ
// Enable this for encryption of packets
//#define RFM69_ENABLE_ENCRYPTION
#define RFM69_ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
#endif
Here's my code in case you're interested:
//
// Use this sensor to measure volume and flow of your house watermeter.
// You need to set the correct pulsefactor of your meter (pulses per m3).
// The sensor starts by fetching current volume reading from gateway (VAR 1).
// Reports both volume and flow back to gateway.
//
// Unfortunately millis() won't increment when the Arduino is in
// sleepmode. So we cannot make this sensor sleep if we also want
// to calculate/report flow.
//
// Sensor on pin 3
#include <MySensor.h>
#include <SPI.h>
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your sensor. (Only 2 and 3 generates interrupt!)
//#define PULSE_FACTOR 12500 // Nummber of blinks per m3 of your meter (One rotation/liter)
#define PULSE_FACTOR 288000
#define SLEEP_MODE false // flowvalue can only be reported when sleep mode is false.
#define MAX_FLOW 25 // Max flow (l/min) value to report. This filetrs outliers.
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
#define CHILD_ID 0 // Id of the sensor child
#define RELAY_1 4 // Arduino Digital I/O pin number for first relay
#define NUMBER_OF_RELAYS 1
#define RELAY_ON 1
#define RELAY_OFF 0
unsigned long SEND_FREQUENCY = 10000; // Minimum time between send (in miliseconds). We don't want to spam the gateway.
MySensor gw;
double ppl = ((double)PULSE_FACTOR)/1000; // Pulses per liter
volatile unsigned long pulseCount = 0;
volatile unsigned long lastBlink = 0;
volatile double flow = 0;
boolean pcReceived = false;
unsigned long oldPulseCount = 0;
unsigned long newBlink = 0;
double oldflow = 0;
double volume;
double oldvolume;
unsigned long lastSend;
unsigned long lastPulse;
unsigned long currentTime;
boolean metric;
MyMessage flowMsg(CHILD_ID,V_FLOW);
MyMessage volumeMsg(CHILD_ID,V_VOLUME);
MyMessage pcMsg(CHILD_ID,V_VAR1);
void setup()
{
//gw.begin(incomingMessage, AUTO, true);
//gw.begin(incomingMessage, AUTO, false, AUTO, RF24_PA_LOW);
gw.begin(incomingMessage, AUTO, false, AUTO);
// gw.send(pcMsg.set(0));
// gw.send(volumeMsg.set(0.000, 3));
//Water meter setup
//Serial.print("PPL:");
//Serial.print(ppl);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Water Meter and Valve", "1.0");
// Register this device as Waterflow sensor
gw.present(CHILD_ID, S_WATER);
// Fetch last known pulse count value from gw
gw.request(CHILD_ID, V_VAR1);
//pulseCount = oldPulseCount = 0;
//Serial.print("Last pulse count from gw:");
//Serial.println(pulseCount);
attachInterrupt(INTERRUPT, onPulse, RISING);
lastSend = millis();
//RELAY SETUP
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
}
}
void loop()
{
gw.process();
currentTime = millis();
bool sendTime = currentTime - lastSend > SEND_FREQUENCY;
if (pcReceived && (SLEEP_MODE || sendTime)) {
// New flow value has been calculated
if (!SLEEP_MODE && flow != oldflow) {
// Check that we dont get unresonable large flow value.
// could hapen when long wraps or false interrupt triggered
if (flow<((unsigned long)MAX_FLOW)) {
gw.send(flowMsg.set(flow, 2)); // Send flow value to gw
}
//Serial.print("g/min:");
// Serial.println(flow);
oldflow = flow;
}
// No Pulse count in 2min
if(currentTime - lastPulse > 20000){
flow = 0;
}
// Pulse count has changed
if (pulseCount != oldPulseCount) {
gw.send(pcMsg.set(pulseCount)); // Send volumevalue to gw VAR1
double volume = ((double)pulseCount/((double)PULSE_FACTOR)*264.172);
//double volume = ((double)pulseCount/((double)PULSE_FACTOR));
oldPulseCount = pulseCount;
if (volume != oldvolume) {
gw.send(volumeMsg.set(volume, 3)); // Send volume value to gw
oldvolume = volume;
}
}
lastSend = currentTime;
}
else if (sendTime) {
// No count received. Try requesting it again
gw.request(CHILD_ID, V_VAR1);
lastSend=currentTime;
}
if (SLEEP_MODE) {
gw.sleep(SEND_FREQUENCY);
}
}
void onPulse()
{
if (!SLEEP_MODE) {
unsigned long newBlink = micros();
unsigned long interval = newBlink-lastBlink;
lastPulse = millis();
if (interval < 2080) { // Sometimes we get interrupt on RISING, 500000 = 0.5sek debounce ( max 120 l/min) WAS 2080
return;
}
flow = ((60000000.0 /interval) / ppl)*.264172;
//flow = ((60000000.0 /interval) / ppl);
// Serial.print("interval:");
// Serial.println(interval);
lastBlink = newBlink;
// Serial.println(flow, 4);
}
pulseCount++;
}
void incomingMessage(const MyMessage &message) {
if (message.type==V_VAR1) {
pulseCount = oldPulseCount = message.getLong();
Serial.print("Received last pulse count from gw:");
Serial.println(pulseCount);
pcReceived = true;
}
if (message.type==V_LIGHT) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
I built an identical sketch. (Control a valve if water is flowing and shouldn't be - busted pipe, stuck sprinkler, etc)
I'm posting to remind myself to send you my sketch when I have access to my IDE at home.
Thought I'd try this again. Perhaps this would be better in another section of the forum?
Hello Everyone -
This may be an inappropriate question due to my lacking of understanding of MQTT however I thought I'd give it a shot.
I was at an AWS/Amazon conference a few weeks ago and they announced a new offering for IoT primarily using MQTT as a protocol (not surprising).
I already happily have an ethernet gateway interfaced to my Vera with several sensors around the house and deeply integrated to my zWave network, PLEG actions, etc. I thought it'd be neat to also stream my sensor data to AWS to do various Lambda functions and data analysis.
Does anyone think it's possible to run a dual-purpose gateway? One for the home automation controller + another for data analysis plus possible sensor control in the future?
Thanks.
@awi , not surprisingly, this worked as expected.
I changed the following in Hek's script and it worked fine:
MyTransportNRF24 transport(17, 18);
MySensor gw(transport);
@awi - you know, I looked everywhere for that page last night. It has always been a great resource. It wasn't until this morning, with a clear head, that all I had to do was click on the "API" button. sigh
Sorry about that......little embarrassed.
Thanks @awi. I meant to come back and correct my post. I did see that after going back and looking at the old 1.4 API (you are correct). It has been many months since I've looked at this sketch. However, I'm not using the default PINs here so I guess I have to change MyConfig for this sketch?
/**********************************
* NRF24L01 Driver Defaults
***********************************/
#define RF24_CE_PIN 9
#define RF24_CS_PIN 10
Hello All -
In 1.4, I used to sometimes use the following to setup my sensors:
gw.begin(incomingMessage, AUTO, false, AUTO, RF24_PA_LOW);
However, I see that the new 1.5 MySensor.H file no longer supports that many parameters.
Am I correct that this ability has been removed? Any suggestions on how to do this on 1.5 if needed?
Bringing back an old thread. As you can tell, I'm not much of a developer. ..... apologies....
I'm updating all of my sensors to 1.5 but am having issues with this one. When I compile (using IDE 1.6.5) and a new libraries directory, I get the following error.
Any ideas?
TouchDisplaySceneControllerSensor:67: error: no matching function for call to 'MySensor::MySensor(int, int)'
TouchDisplaySceneControllerSensor.ino:67:18: note: candidates are:
In file included from TouchDisplaySceneControllerSensor.ino:37:0:
C:\Users\tbully\Documents\Arduino\libraries\MySensors/MySensor.h:158:2: note: MySensor::MySensor(MyTransport&, MyHw&)
MySensor(MyTransport &radio =*new MyTransportNRF24(), MyHw &hw=*new MyHwDriver()
^
C:\Users\tbully\Documents\Arduino\libraries\MySensors/MySensor.h:158:2: note: no known conversion for argument 1 from 'int' to 'MyTransport&'
C:\Users\tbully\Documents\Arduino\libraries\MySensors/MySensor.h:149:7: note: MySensor::MySensor(const MySensor&)
class MySensor
^
C:\Users\tbully\Documents\Arduino\libraries\MySensors/MySensor.h:149:7: note: candidate expects 1 argument, 2 provided
no matching function for call to 'MySensor::MySensor(int, int)'
I ended up having to use two. But honestly I didn't try that hard because I also had to switch a relay on each sensor. It made both programming and wiring easier to run two in my scenario.
Let us know if you find a better solution!
Still trying to find a case while tinkering and came up with another question.
Has anyone figured out how to "toggle" a scene? I think it'd be cool to have it somehow know if a scene was active and if so run an "off" version of that scene. Likewise, if the scene is "off", run an "on" version.
Maybe another way is to abandon the scene functionality altogether and just somehow control the zwave switch individually.
Just thinking out loud.
Very cool project.
I've been playing around with this quite a bit and have it working great. That said, I know I remember seeing a thread where cases (3D printed) were being discussed . However, I can't find the link.
Anyone have it handy?
@olaeke I would think you may be pushing it. Any way to use a few separate supplies for a short time to see if that helps? If you decide to just upgrade your supply, you may want to put caps on the radios to help stabilize the bus.
@epierre said:
Hello,
have you contacted Itead support on this ?
I bought one too but had no time to test it yet (In fact I was waiting for you
No worries, @epierre . I put a test webserver on the iBoard to make sure it was working OK. I was able to browse an SD card over ethernet so I didn't want to bother their support people. I never heard from @nneeoo and just decided to go the hardware route. It seems to be working just fine. I recommend it. It's more stable than the serial gateway I was running.
@gregl said:
Hi @tbully - i personally never bothered with leds/inclusion button.
My gatway is underneath my staircase near vera and my wifi router, so other than when i make a change, i never see it - so leds wouldnt help me.
When i do an inclusion i do so via software..so no button needed either...
I would like a nice 3d printed case for it one day...still havent boxed the iboard up!
Same here, @gregl . I appreciate your write-ups above. They really helped out. I'd like to find a printer and user @jtm312 's design but would like to know how he got the LEDs and Button wired up. Soldering directly to the chip could be difficult without a steady hand.
Hello everyone. I gave up on the software method and just did the hardware mod. I highly recommend it. It only too 10-15 minutes and a steady hand.
Now to figure out how to do the TX/RX/ERR/Inclusion stuff.......
As an update....I gave up on the software method and just did the hardware modification.
All is well now.
One question: How did you guys do the LED and inclusion buttons? Did you carefully solder right to the Atmega chip or is there a better place to grab the needed pins?
What pins did you use for TX/RX/ERR/Inclusion?
It appears I may have had my pin assignments incorrect. I looked at the iBoard schematic and came up with this:
RH24_Config
const uint8_t SOFT_SPI_MISO_PIN = 6;
const uint8_t SOFT_SPI_MOSI_PIN = 5;
const uint8_t SOFT_SPI_SCK_PIN = 7;
Gateway Sketch:
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN 10 // Digital pin used for inclusion mode button
#define RADIO_CE_PIN 3 // radio chip enable
#define RADIO_SPI_SS_PIN 8 // radio SPI serial select
#define RADIO_ERROR_LED_PIN 11 // Error led pin
#define RADIO_RX_LED_PIN 12 // Receive led pin
#define RADIO_TX_LED_PIN 13 // the PCB, on board LED
I'm now getting "Gateway Startup Complete" but I'm still unable to ping the board from another host on my network. I see the Tx and Rx lights flashing (as well as the Link) but no joy.
0;0;3;0;14;Gateway startup complete.
Any help?
Hello Everyone -
Apologies for starting a new thread on this but the build thread where I posted my question isn't getting much traffic these days.
I'm trying to convert to an Ethernet Gateway using an iBoard as seen in this thread:
iBoard Build
I'm attempting to use @nneeoo 's method of not making hardware modifications. (Not that I'm against that, but if I could leave it alone - all the better)
When I make the below changes, I'm getting the "check wires" message. So I'm either doing something wrong with my config or I'm going to have to make the HW modification anyway.
Any thoughts?
Here's my relevant RH24_Config settings:
const uint8_t SOFT_SPI_MISO_PIN = 6;
const uint8_t SOFT_SPI_MOSI_PIN = 5;
const uint8_t SOFT_SPI_SCK_PIN = 7;
const uint8_t SPI_MODE = 0;
And here's my setup in my gateway sketch:
#include <Ethernet.h>
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
#define RADIO_CE_PIN 5 // radio chip enable
#define RADIO_SPI_SS_PIN 6 // radio SPI serial select
#define RADIO_ERROR_LED_PIN 10 // Error led pin
#define RADIO_RX_LED_PIN 8 // Receive led pin
#define RADIO_TX_LED_PIN 9 // the PCB, on board LED
#define IP_PORT 5003 // The port you want to open
IPAddress myIp (192, 168, 34, 169);
To be clear, I'm not afraid to do the hardware modification but it appears that @nneeoo got it to work without doing so. If that's true, I'd like to go that route........
Hello. I too tried @nneeoo 's edits and am getting check wires.
Here's my relevant RH24_Config settings:
const uint8_t SOFT_SPI_MISO_PIN = 6;
const uint8_t SOFT_SPI_MOSI_PIN = 5;
const uint8_t SOFT_SPI_SCK_PIN = 7;
const uint8_t SPI_MODE = 0;
And here's my setup in my gateway sketch:
#include <Ethernet.h>
#define INCLUSION_MODE_TIME 1 // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN 3 // Digital pin used for inclusion mode button
#define RADIO_CE_PIN 5 // radio chip enable
#define RADIO_SPI_SS_PIN 6 // radio SPI serial select
#define RADIO_ERROR_LED_PIN 10 // Error led pin
#define RADIO_RX_LED_PIN 8 // Receive led pin
#define RADIO_TX_LED_PIN 9 // the PCB, on board LED
#define IP_PORT 5003 // The port you want to open
IPAddress myIp (192, 168, 34, 169);
Hello,
I've been looking in to this for quite some time. Here in the US, our residential wiring is usually 220V "split-phase" where we have a neutral/ground connection that allows us to get 120V from either "leg" (not to be confused with phase) to "ground". If you go "leg to leg", you'll get the full 220V of the phase.
I've been searching quite a bit and am a little confused so I was hoping that you could expand on your solution a bit. (schematics, part numbers, full sketch) Your efforts look great. I'm wondering how you've integrated in to MySensors (and your controller, Vera?)
In my case, I think that I will need to do the following:
Most US based solutions call for only one transformer/leg-measurement. However, I have seen an imbalance in my utility power. I'm not sure if this is due to underground resistance, faulty utility transformers, etc. But my point is, I think it'd be safer to measure both, do my calculations separately, and then add them accordingly (in software) to get total power consumption.
Can you expand a bit on my thoughts? Has anyone in the US been successful in my above approach?
I know it's a bit off topic but does anyone have a good idea of a general purpose printer? It seems like the 3D forums are full of people that love their own purchase/decision but have little constructive feedback.
@jtm312 - What do you use for small projects like this? Do you like it?
@hek I've rebooted several times over the past few days while working on other sensors. However, your idea sounds valid.
So you're saying that I should be able to have multiple sensors running the example relay sketch on my network without issue, correct?
This should be fine because each individual node/arduino gets it's own ID so the relays on each Arduino should not conflict with its neighbors.
Any thoughts? It's working OK with this hack but will not scale if I start adding more (10+) relays.
The fix certainly fixed the random "spamming" issue for me. I was tearing my hair out on that one.
I have not had the hang yet but have only been running my water sensors (pulse, just like the power) for 4-5 days.
Thanks @blacey . I was trying to configure it per sensor without having to remember to go in to the library each time.
This works fine, though.
Can someone explain how to call gw.begin(); in a sensor to adjust the power level?
I read the troubleshooting page but it wasn't clear how the parameters would look.
When calling the function, do you have to call all the parameters or just the power level?
gw.begin(RF24_PA_LOW); ?
Is it the same for a gateway?
Thanks guys. Nice catch. I also had this problem with the water version.
@samppa - Interesting. I've actually found the 1.4 protocol to be more reliable. (I'm using high-frequency pulse detection for water flow and also valve control) I'm having the sensors send my gateway several times per minute and it never fails.
I've found that powering the Arduino/Radio combination with USB (PC, hub, etc) to not be ideal and always opted for a "wall wart" or my own supply and 5V external regulator. I've always used caps on the 3.3V Radio Supply so I don't have much to compare it with. I'm contemplating going to an ethernet gateway so I can power it with an external source as well. (it's currently being powered by a USB hub connected to Vera)
Just personal experience - it sounds like you've had good luck in the past.
Cheers!
Hello All -
I ran in to an interesting issue over the weekend that I'm hoping I can get some help with.
I have two identical nodes/sensors. Each Arduino has a water pulse meter and a relay (to control an actuator/valve).
I used the same forloop logic found in the relay example at: http://www.mysensors.org/build/relay
However, the relay was not discovered/added by Vera on the second node. The only way I could get it to include was if I started the forloop with sensor=2. This will give the first relay on the second node an ID of "2". This seemed like an odd necessity to me as it was coming from a different sensor/node.
Is this expected behavior?
for (int sensor=2, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
gw.present(sensor, S_LIGHT);
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, gw.loadState(sensor)?RELAY_ON:RELAY_OFF);
}
All is well and both nodes are up and functioning. It just seemed like an ugly way to handle this situation and could cause trouble down the road as I add relays/sensors.
For what it's worth, a lot of what you've been complaining about can be caused by poor power to either the gateway or the sensor.
Take it from me. I had this issue a few weeks ago and had a skull that was too thick to admit it until I was frustrated and tried another power source.
Then, just last night, I was up until 1:30AM fighting "strange issues" and again it turned out to be power related. (And again, I ignored the possibility for hours! Ugh!)
Good luck, Samppa.
New status: I found that by using an external 5v power source for the sensor (instead of plugging it in to the USB port), yields perfect results. I'm not sure why it'd matter. My guess is it was interfering with the radio's operation when running the relay. I'm going to add a filter tonight to see if it helps - just for education purposes. However, it won't be powered by a PC in production anyway.........
This did cross my mind. Having it at the top shouldn't matter but - "why not!?".
My gateway is currently only a few feet from my sensor so I don't think it's a reception issue.
I will report back, of course. Thanks for the idea.
I was FINALLY able to back in to the correct formula and PULSE_FACTOR to get accurate data displayed!
Now I'm trying to combine this Arduino node to do both the pulse counting AND control a relay. What I'm finding is that I'm getting very poor response/performance from controlling the relay. Sometimes I have to click on the ON (or OFF) button successively multiple times to get it to react. I've also noticed that while I'm clicking (and the relay is not responding) that the gateway is giving a red error light for each click.
The performance is even worse if I'm running the serial monitor on the sensor side. As you can see from my sketch, I even tried to disable interrupts thinking that maybe I'm falling in to the onPulse routine too often due to the high frequency on the PIN.
Thoughts?
As an update, I found my issue with missing flow data. My function generator was running at 10Hz (to simulate 48 L/min).
I'm struggling to get this sensor (listed above) to work with this sketch. I was blowing by the MAX FLOW check in the sketch.
If anyone has the time to check out the sensor I'm trying to use, It'd be great.
I also have a tread going HERE that main contain more helpful data.
I'm happy to report that I have made some headway.
Even though I set the following in the WaterMeterPulseSensor sketch:
#define SLEEP_MODE false
I still cannot see flow values in Vera.
Thoughts?
I see all of the Serial.print lines commented out in the example sketch. When I uncomment them, the data is not printed to the serial monitor. I'm not working in a Vera Environment at the moment (testing without it) and would like to see this data.
Thanks again.
Got it. I downloaded the beta and got the gateway going but seeing the following when trying to load the Dallas Temp Sensor:
DallasTemperatureSensor:15: error: 'Sensor' does not name a type
DallasTemperatureSensor.ino: In function 'void setup()':
DallasTemperatureSensor:24: error: 'gw' was not declared in this scope
DallasTemperatureSensor:33: error: 'S_TEMP' was not declared in this scope
DallasTemperatureSensor.ino: In function 'void loop()':
DallasTemperatureSensor:47: error: 'gw' was not declared in this scope
DallasTemperatureSensor:49: error: 'V_TEMP' was not declared in this scope
DallasTemperatureSensor:56: error: 'gw' was not declared in this scope
Great idea on the sniffer! I have an amateur radio background as well as a lot of experience on tcpdumps/snoops/wireshark so I'm not afraid to go digging. Moving around doesn't seem to change much.
How do I know what version I'm running? I thought I downloaded the latest version already......
Thanks guys...loving this site!
Hello All -
I've been struggling with this issue for the past several hours. I've tried new radios, adding capacitors, switching to low power, etc (all the stuff I could find by reading) and I'm out of ideas......
Both the DallasTemp sensor and my gateway are sitting just a few feet a part on my bench. However, I often get the following when looking at the sensor's serial output. Further, this causes Vera to go to an incorrect temperature.
Any help/ideas would be great.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=0,cr=240: 77.3
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=0,cr=90: 78.0
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=0,cr=178: 78.5
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=0,cr=8: 79.0
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=0,cr=167: 79.3
Ack: received OK
Thanks for the response but I'm not sure I follow. Can you elaborate?
I'm in for one or two if there's an opportunity.
Hello All -
One of my first "MySensors" projects will be a water flow sensor to detect water usage when not expected. I will be using Vera for my logic/controller. Example:
Something like that...... you get the picture.
I have tested the following sensor/sketch on the bench and it works great:
http://www.seeedstudio.com/wiki/G1"_Water_Flow_Sensor
I would like to incorporate a MySensor in to Vera but I do not see a pre-built MySensor Sketch that does what I want.
I thought about perhaps using the existing Water Flow sketch (http://www.mysensors.org/build/pulse_water) and putting the logic from seeedstudio but I'm not sure I'm competent enough to do this.
Does anyone have an ideas for this newb?
Thanks!
I think you are implying that the Uno is overkill. I completely agree with this.
I just happen to have a few on hand and figured "why not?"
I should have some sensors to test with soon. I guess I'll know if my solution is viable or not........
I may have solved this myself.
Can someone check me on this?
In "Edit Startup Lua", I entered the following:
os.execute("ser2net -C 5000:raw:0:/dev/ttyACM0:115200")
I then went to the MySensors Plugin in the Advanced tab and entered the following in the "IP" line:
127.0.0.1:5000
I don't currently have any sensors to attach to. However, when I click on the "start" button for inclusion, I can see the inclusion LED illuminate.
Does this seem like a viable solution?
Hello All -
Just getting started with Arduino (been around Vera for a while). I'm able to get my Nanos working as a gateway. (Excellent documentation!)
However, I do have a few Unos kicking around that I'd like to use as a gateway (serial). Is this possible with Vera? I see that dmesg shows the following when the Uno is connected:
usb 1-2.2: new full speed USB device using rt3883-ehci and address 10
cdc_acm 1-2.2:1.0: ttyACM0: USB ACM device
Is there a way to expose this as a serial port? I understand that if I use an ethernet gateway, it'd likely work. However, lacking an ethernet shield at the moment, I'd like to stick to serial if possible.
By the way, I did test the Uno<->Radio integration with an example sketch and it seems solid in my case. (I did read about the 3.3v power issue with some Unos)
Any ideas for the Arduino newb would be helpful.
Thanks.