I've been able to get MySensors working with HomeGenie using the MQTT gateway. It doesn't have two-way communication or software-based pairing yet, but I'll work on those in the future.
@ericvdb
Yes, I know about the 5V. But the adapter brings it down to 3.3V for the radio, that is the reason for using it and the adapter is equipped with the AMS 1117 3.3V chip. Seems to work OK but I really do not have any hard facts to prove it.
One thing I may test is to wire the 5V also directly to this adapter instead of taking it out from the Arduino 5V pin. This is to find out if this Arduino Nano clone might have too small capacity for feeding the radio at certain occasions.
Sorry. Hek, I using this code. Vera3 find relay and it works, but also appears 3 door sensors instead of 3 temp sensors.
I try to use the my arduino board only with sd18b20 sketch and it work's and show temperature. Is it sketch suitale for vera?
@Gambituk said:
and here is the modified relay/temp sketch
// Running DS temperature sensor(s) and relay(s) on one mysensor arduino node
// Combines Onewire and Relay code
// 2014-10-14 Pego: Tested and Running on Uno/Clone and MQTT gateway
// Example sketch showing how to send in OneWire temperature readings
// Example sketch showing how to control physical relays.
// This example will remember relay state even after power failure.
#include <MySensor.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>presen
#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected
#define MAX_ATTACHED_DS18B20 16
#define RELAY_1 4 // 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 RELAY_ON 1 // GPIO value to write to turn on attached relay
#define RELAY_OFF 0 // GPIO value to write to turn off attached relay
unsigned long SLEEP_TIME = 30000; // Sleep time between reads (in milliseconds) 30000 orig
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
MySensor gw;
float lastTemperature[MAX_ATTACHED_DS18B20];
int numSensors=0;
boolean receivedConfig = false;
boolean metric = true;
// Initialize temperature message
MyMessage msg(0,V_TEMP);
void setup()
{
// Startup OneWire
sensors.begin();
// Startup and initialize MySensors library. Set callback for incoming messages.
//gw.begin();
gw.begin(incomingMessage, AUTO, true);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Temp and Relays", "1.0");
// Fetch the number of attached temperature sensors
numSensors = sensors.getDeviceCount();
// Present all sensors to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
gw.present(i, V_TEMP);
}
// Fetch relay status
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()
{
// Process incoming messages (like config from server)
gw.process();
// Fetch temperatures from Dallas sensors
sensors.requestTemperatures();
// Read temperatures and send them to controller
for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {
// Fetch and round temperature to one decimal
float temperature = static_cast<float>(static_cast<int>((gw.getConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;
// Only send data if temperature has changed more then 1 degC and no error
if (int(lastTemperature[i]) != int(temperature) && temperature != -127.00) { //added integer
// Send in the new temperature
gw.send(msg.setSensor(i).set(temperature,1));
lastTemperature[i]=temperature;
}
}
//gw.sleep(SLEEP_TIME); //no sleep for relays!!!!
}
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
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());
}
}
Actually, it's not 100% MySensors-related, but I have a working setup consisting of iBeacon (either HM10-based or PI-based) and Beecon app.
When Beecon senses the iBeacon it can trigger various actions, eg make http requests or call IFTTT recipes
@kunall the best recommendation against openhab for me was ugly interface and problems with running it (java). I was using domoticz since early version with own interface on arduino,now I've switched everything for MySensors.
It still lacks some functions but Inwait for further development as even programmers of domoticz start to use MyS hardware
@micah said in Can't get OpenHAB2 to see my MQTT messages:
I'm still not sure if the second and third line in the mqtt-eventbus.cfg is correct. I don't have MyMQTT anywhere else, so I think I may try different combinations to see what works.
MyMQTT should be replaced with brokername (mysensors in this example). openhab will then publish the event to the mqtt broker on its topics (useful if you use f.eks. node-red for openhab rules)
After more investigations I believe the problem is caused by a mqtt server connection timeout.
By default the gateway tries to send the radio message 5 times. If I lower the number of retries , 2 for example, no more loop. Probably now much more then 25 messages cause a loop.
For testing I added _MQTT_client.loop() in transportSendWrite() (MyTransport.cpp) and, no more loop with default 5 retries.
Hey there @Chaotic ! This is Fay from codebender.cc Thank you for using codebender! I just wanted to let you know that one of the sketches you are using in this comment has been deleted and so it is not available for users to view it. Let me know if you have any question.