I'm getting following error while compiling, any solution?
Posts made by kunall
-
RE: MQTT Client gateway
-
RE: Receive Battery percentage via MQTT on OpenHab?
@FotoFieber I followed the sketch that you provided in your link above called "MQTT Client Gateway". however, while compiling that sketch I'm getting following error?
Any solution or suggestion for that? -
RE: Receive Battery percentage via MQTT on OpenHab?
@FotoFieber I'm using THIS MQTT Gateway. Is there a better MQTT gateway solution available? Sorry i'm new to all this.
-
RE: MQTT and batterylevel
@gadu How did you implement V_Var1 ? and assign it to child ID 1 ?
Like this? if so, what did you use for gw.present(CHILD_ID, S_XXX) ?
#define CHILD_ID 1 myMessage msg(CHILD_ID, V_VAR1);
-
RE: MQTT and batterylevel
Thanks alot @gadu . I will give this a try and get back to you!
-
RE: MQTT and batterylevel
@gadu Can you post your working battery level send sketch for openhab? I would really appreciate it. I'm facing the same issue. Thanks!
-
Receive Battery percentage via MQTT on OpenHab?
Hello
I'm trying to receive battery percentage over MQTT on openHab. So far i'm dont have any luck. I'm confused, because there is no such V_Battery or something like that.
I would really appreciate any help as i'm trying to finish my project before my final exam starts.
Here is my serial output. I was testing the battery sketch on Nano powerd via USB 5.0v. I know i'm getting incorrect reading, but thats okay for now, I just need to receive battery percentage via MQTT first.
-
RE: Ethernet gateway doesn't work with Domoticz.
@hek Thats right, I only get one way communication. Domoticz doesn't send cmd via Ethernet for some reason.
-
RE: Ethernet gateway doesn't work with Domoticz.
@hek You mean this isn't an issue with the ethernet gateway but Domoticz itself? I will open a support ticket with domoticz. Thanks!
-
RE: Checking if the air conditioning is on
Do you have an air conditioning duct? What about using a temperature sensor?
-
RE: RelayWithButtonActuator
I second that. I have exactly the same issue. I have to physically toggle the switch before operating it from OpenHab.
-
Ethernet gateway doesn't work with Domoticz.
Hello,
I wanted to report my or some other members issues with Ethernet Gw and Domoticz. It seems that Ethernet gateway only works one way and not other with Domoticz.
I was able to get status updates on Domoticz via Ethernet gateway but I couldn't send any command to any nodes.
Ex. I could see all the sensor data, relay's physical button status update but I could not send a on/off command to the relay. There's just no response from Ethernet Gw if issues a command from Domoticz UI.I tested serial gateway, it worked without any issue.
Thanks!
-
RE: Relay Outlet + Button + OpenHab + Tasker + Android Wear = Freaking Awesome!
@mikeones I apologize to get back to you so late. You might already have figured out a way but I wanted to let you know that after many days of testing my relay actuator with OpenHab, I'm very happy to tell you that it's working flawless. No issues with the stuffing inside the gand box whatsoever. I have not seen any other option to power the arduino thru 110V - 240V. Using a cellphone charger seems to be common.
Please let me know if you have any other solution, I would certainly give it a try.
Thanks!
Edit : gang box
-
RE: Ethernet Gateway hangs up
@andriej this is off topic but I wanted to ask you if are able to turn off/on relay actuator thru domoticz UI via Ethernet gateway?
It's not working with mine!
-
RE: Domoticz wont toggle light switch via ethernet gateway?
@Striffster Before this, I was running OpenHab via MQTT gateway. It works flawless.
I wanted to give Domoticz a try but the ethernet gateway wont work. -
RE: Domoticz Beta for MySensors official support?
@blacey Are you running Serial or Ethernet gateway for Domoticz?
-
Domoticz wont toggle light switch via ethernet gateway?
For my light switch i'm using the example relay actuator sketch. When I try to turn on/off light from Domoticz UI via ethernet gateway it wont work. However, it does update state On/Off light if I toggle the physical push button on the relay.
On the contrary, everything works fine on Serial gateway. I just tried it and it worked.Any solution please? I really want to use ethernet gateway!
Thanks!
-
RE: Domoticz Beta for MySensors official support?
@raditv @hek I can confirm that the Light turns on/off with Serial gateway. Just tried it and it works. However it does not work with ethernet gateway sketch. Any solution to make it work with ethernet?
-
RE: Domoticz Beta for MySensors official support?
@hawk_2050 I had few crashing issues today when I installed from source code. It ran fine for a while, got me excited and then started crashing. So I went ahead and installed from stable binary. So far no issues except I can not turn on/off light from the UI. Not sure if its the ethernet gateway issue or domoticz'.
-
RE: Domoticz Beta for MySensors official support?
@raditv Yeah, let me know if you face any issues with ethernet gateway. I will give a try to serial gateway, right now!
-
RE: Domoticz Beta for MySensors official support?
@raditv I used the default sketch given in examples for Relay actuator on mysensors. I checked my ethernet gateways debug log, it seems that its not receiving any command from Domoticz at all.
-
RE: Domoticz Beta for MySensors official support?
@jeylites After success with OpenHab, I wanted to give a try to Domoticz. Lets see how it goes. I will keep you updated!
-
RE: Domoticz Beta for MySensors official support?
@raditv @AWI Thats what I thought about On/Off action. I'm trying to on/off mysensors relay actuator. My relay actuator has a physical button. Domoticz detects my relay actuator and also updates the state if I toggle the physical button. But it does not turn on / off the relay actuator from domoticz UI. Any idea why?
Here is my Domoticz log
-
RE: Domoticz Beta for MySensors official support?
@blacey Thanks!! I followed your instruction. Works great. It detected some of my sensor noted out of the box. However, I'm not sure how to send a command to Turn On/Off light? It is asking me Action ON and Action OFF like shown here:
-
Domoticz Beta for MySensors official support?
Do i need to install Domoticz beta version to get official mysensors support? Does anyone have a tutorial to setup ethernet gateway with domoticz?
Thanks!
-
RE: State of the physical switch
I have achieved it using MQTT with OpenHab. So if some one toggles the physical button on the relay switch, the soft switch on OpenHAB will toggle to match the state.
Not sure if that's what you are looking for.
-
Relay Outlet + Button + OpenHab + Tasker + Android Wear = Freaking Awesome!
This is my very first fully functional project! Yay!! Most of the credit goes to mysensors and all the amazing people here. I thank you all.
So, I wanted to control my home appliances/lights with Voice and/or OpenHab rules. I made this relay switch outlet. May not look pretty at all but it surely works with OpenHab and "Ok Google - Turn On Switch" command from my Android phone and Android watch . It also hides behinds the couch, hehe. For right now, I just turns on/off and with commands. I will be setting it up to fully automate with iftt conditions in next few days.Note: I have used 2 relay module because thats the one I had for now. Also I'm planning to make both female power outlets to operate separately.
Project cost: $7.5 USD including Nano V3.0, Relay, NRF transmitter, power outlet socket, and casing. (Power cable, button, 5.0V charger, AutoVoice, Auto-wear and Tasker not included, I already had them.)
I searched for cheapest required item on eBay and purchased hem.
Nano V3.0 = $2.56
NRF transmitter = $0.97
Relay module (You may use 1 relay module) = $1.3
Female powerOutlet socket + blue casing + faceplate = aprx. $3 from Home Depot.
PowerCable = n/a (used old PC power supply cable.)
Button = n/a (Already had it.)
5.0V charger = n/a (Already had it, just use old phone charger)
Tasker = n/a (Already had it.)
AutoVoice = n/a (Already had it.)
AutoWear = n/a (Already had it.)
My OpenHab & Tasker
Hope you liked my project. Please feel free to comment, post any suggests, and questions.
Thanks!
-
RE: Raspberry Pi2 + MQTT Gateway in one box!
@andriej I'm using OpenHab and I was wondering about domoticz. Many people seem to be using it. Have you used OpenHab? Do you like domoticz better?
-
RE: Raspberry Pi2 + MQTT Gateway in one box!
@andriej This is awesome! Thank you very much. Im going to try this.
-
RE: Which IDE is better to use?
@raditv I use mbp too. I boot camped Windows 8 in it. It runs great.
You can also use Xcode as Arduino IDE.
-
RE: Raspberry Pi2 + MQTT Gateway in one box!
@andriej is there any link or tutorial on this? I'm fairly new so it would really help.
If I understand right, I can connect a transistor that you mentioned to rpi gpio and reset pin on arduino to achieve a rest when gateway is frozen? I'm correct?
-
RE: Which IDE is better to use?
I use Visual Studio with Arduino IDE plug in, Visual Micro. It's pretty good. It has intellisense and code completion.
-
RE: Operate two relays with one node individually + with a button?
@raditv Thanks alot. I will look into it and get back with results.
-
MQTT gateway freezes on reboot/powering off and back on.
I have been facing this issue for quit a while. Every time I turn power off and on my mqtt gateway, it freezes. I have to reset the arduino uno to fix it. I'm using 1.4b version, arduino uno and w5100 ethernet shield if that helps.
I will appreciate your help with this issue. It's really annoying to rest it every time I reboot the gateway.
Thanks.
-
RE: Operate two relays with one node individually + with a button?
@raditv can you please elaborate on using eeprom to store button value? Any example link may be? Thanks!
-
Operate two relays with one node individually + with a button?
I have been trying to control a two relay module using MQTT and openhab. So far I was able to control them individually. I can turn on relay one or turn off relay two and so on but I want to implement a single button which would control both also, in-case I want to turn on a light/device physically. Example: 1 press will trun on relay1, second press will turn on relay2 and third press will turn all relays off. or something like this.
I'm not very good at programming and still learning. Below is my code:
Note: my relay module is weird. Its Off on 1 (the led turns Off) and ON on 0 (LED turn On).#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define SN "Relay Outlet" #define SV "1.0" #define NODE_ID 22 #define RELAY_PIN_1 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define RELAY_PIN_2 6 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define BUTTON_PIN 3 // Arduino Digital I/O pin number for button #define RELAY_1_CHILD 0 #define RELAY_2_CHILD 1 //#define NUMBER_OF_RELAYS 2 // Total number of attached relays #define RELAY_ON 0 // GPIO value to write to turn on attached relay #define RELAY_OFF 1 // GPIO value to write to turn off attached relay Bounce debouncer = Bounce(); //for Button int oldValue=1; bool state; MySensor gw; MyMessage msg(RELAY_1_CHILD,V_LIGHT); MyMessage msg2(RELAY_2_CHILD,V_LIGHT); void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, NODE_ID); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo(SN, SV); // Setup the button pinMode(BUTTON_PIN,INPUT); // Activate internal pull-up digitalWrite(BUTTON_PIN,HIGH); // After setting up the button, setup debouncer debouncer.attach(BUTTON_PIN); debouncer.interval(5); // Register all sensors to gw (they will be created as child devices) gw.present(RELAY_1_CHILD, S_LIGHT); gw.present(RELAY_2_CHILD, S_LIGHT); // Make sure relays are off when starting up digitalWrite(RELAY_PIN_1, RELAY_OFF); digitalWrite(RELAY_PIN_2, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN_1, OUTPUT); pinMode(RELAY_PIN_2, OUTPUT); } void loop() { // Alway process incoming messages whenever possible gw.process(); debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue && value==1) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back gw.send(msg2.set(state?false:true), true); // Send new state and request ack back } oldValue = value; } void incomingMessage(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.sensor == RELAY_1_CHILD) { if (message.type == V_LIGHT && strlen(msg.getString()) != 1) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN_1, state ? RELAY_ON : RELAY_OFF); // Store state in eeprom gw.saveState(RELAY_1_CHILD, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } if (message.type == V_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN_1, state ? RELAY_ON : RELAY_OFF); // Store state in eeprom gw.saveState(RELAY_1_CHILD, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } if (message.sensor == RELAY_2_CHILD) { if (message.type == V_LIGHT && strlen(msg2.getString()) != 1) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN_2, state ? RELAY_ON : RELAY_OFF); // Store state in eeprom gw.saveState(RELAY_2_CHILD, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } if (message.type == V_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(RELAY_PIN_2, state ? RELAY_ON : RELAY_OFF); // Store state in eeprom gw.saveState(RELAY_2_CHILD, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } } }
I would really appreciate any help you can give me. Thank You
-
RE: Raspberry Pi2 + MQTT Gateway in one box!
@andriej I have not encountered any issues and its working perfectly for past 2 days. Also i'm still looking into resetting Arduino via GPIO.. Please feel free to share recommends or any ideas. Meanwhile, I will be adding an external arduino reset switch on my ArduPi Gateway .
-
RE: Radio doesn't work properly powered by 3.3V - only 5V
Have you tried it with a different radio? It is possible that this radio may have been partially damaged when you powered it with 5v?
I look forward for the result.
-
Raspberry Pi2 + MQTT Gateway in one box!
I decided to put my RPi and MQTT gateway in one box so made this. First time doing this, so it isnt that perfect. I will soon be adding LEDs to it too.
-
RE: Which gateway to choose Serial, Ethernet or MQTT?
@TimO Thanks, I will try this.
-
RE: MQTT Broker gateway
@Chaotic Thanks! I will try this and get back with result.
-
RE: MQTT Broker gateway
How can I implement MQTT for MQ-2 Gas sensor the correct way? In the mysensor sketch there is only one child ID and one V_VAR1 but 3 different outputs: LPG, CO and Smoke? I'm only receiving CO value and not all 3 in openhab.
-
RE: Which gateway to choose Serial, Ethernet or MQTT?
@kolaf If you could find, that would be very helpful. Thanks!
-
RE: Which gateway to choose Serial, Ethernet or MQTT?
@rvendrame That is definitely a plus point. For me the question is, if serial gateway works with RPi + OpenHab?
-
RE: Which gateway to choose Serial, Ethernet or MQTT?
@kolaf Great, Thanks for the response. The serial gateway sound a good option to me. I'm using RPi2 with OpenHab. Would you happen to have any tutorial link where I can look learn the to connect serial gateway to RPi with Openhab? Do I still need MQTT with serial gateway?
PS: I'm new to all this and do not hesitate to ask questions. Hope thats okay.
Thanks
-
RE: Motion & Relay Sensor issue
I'm using OpenHab. So not sure about Vera. But I have the same issue. After using the code you provided, The node constantly sends messages 1 (Motion) or 0 (No motion). So I conclude, as Hek mentioned, the node can not sleep because it is waiting for incoming messages, I guess.
-
Which gateway to choose Serial, Ethernet or MQTT?
I'm currently running OpenHab on RPi2. I was looking at some other controller option just out of curiosity. Some of them support Serial and/or Ethernet gateway.
I'm wondering for ex. I want to try out Domoticz. It supports Serial and Ethernet. So, which one should I choose? Does it matter? Serial is better choice over ethernet or vice-versa?
would be great if you can shed some light on this. Thanks!
-
RE: Motion & Relay Sensor issue
Got it. Thank you for your response. So I simply removed the sleep function and put if - else statement to stop my Motion sensor flooding my console window.
-
Motion & Relay Sensor issue
I'm attempting to merge Relay & Motion Sensor sketches, and so far i'm partially succeeded. But..
Here is the code that works for me: Relay and Motion both work.
/* // Example sketch showing how to control physical relays. // This example will remember relay state even after power failure. REVISION HISTORY Version 1.0 - December 29, 2014 - Pete B - Adapted from MySensors Relay Code */ #define NODE_ID 20 #define SN "Motion&LED" #define SV "1.0" #include <MySensor.h> #include <SPI.h> #define RELAY_PIN 4 // Arduino Digital I/O pin number for first relay (second on pin+1 etc) #define MOTION_PIN 3 #define RELAY_CHILD 2 #define MOTION_CHILD 1 #define NUMBER_OF_RELAYS 1 // 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 #define INTERRUPT MOTION_PIN -2 //unsigned long SLEEP_TIME = 120000; MySensor gw; MyMessage msgRLY(RELAY_CHILD,V_LIGHT); MyMessage msgMO(MOTION_CHILD, V_TRIPPED); void setup() { // Initialize library and add callback for incoming messages gw.begin(incomingMessage, NODE_ID); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo(SN, SV); pinMode(MOTION_PIN, INPUT); // Register all sensors to gw (they will be created as child devices) gw.present(RELAY_CHILD, S_LIGHT); gw.present(MOTION_CHILD, S_MOTION); // Make sure relays are off when starting up digitalWrite(RELAY_PIN, RELAY_OFF); // Then set relay pins in output mode pinMode(RELAY_PIN, OUTPUT); } void loop() { // Alway process incoming messages whenever possible gw.process(); // Read digital motion value boolean tripped = digitalRead(MOTION_PIN) == HIGH; Serial.println(tripped); gw.send(msgMO.set(tripped?"1":"0")); // Send tripped value to gw // Sleep until interrupt comes in on motion sensor. Send update every two minute. // gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME); } 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(RELAY_PIN, 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()); } }
However, My problem is that Motion Sensor continuously sends the message and does not sleep like the following log shows: I want the motion sensor to only send message when triggered.
If I uncomment the following line in the sketch, The Motion sensor sends message only when triggered (Perfect, thats what I want) but the Relay does not operate:
gw.sleep(INTERRUPT,CHANGE, SLEEP_TIME);
I would really appreciate any help with this issue.
Thank You
-
Need help with Turning a LED On/Off with OpenHab and MQTT.
How to Turn On/Off a LED light on Arduino using OpenHAB and MQTT?
I'm fairly new to this and can not seem to understand how to send a command from MQTT to Arduino and make it to Turn ON and OFF a LED.
I'm able to read sensor data on OpenHab via MQTT. Following is my .items file:
Number Node01Temperature "Temperature [%.1f F]" <temperature> (GF_Living) { mqtt="<[mymosquitto:home/temperature:state:default]" } Number Node01Humidity "Humidity [%.1f %%]" <bath> (GF_Living) { mqtt="<[mymosquitto:home/humidity:state:default]" } Number Node01Light "Light [%d %%]" <sun> (GF_Living) { mqtt="<[mymosquitto:home/light:state:default]" } Number Node01Motion "Motion [MAP(motion.map):%s]" <shield> (GF_Living) { mqtt="<[mymosquitto:home/motion:state:default]" } Number Node01Door "Door [MAP(door.map):%s]" <lock> { mqtt="<[mymosquitto:home/door:state:default]" } Switch Node01LED "LED [%s]" <switch> (GF_Living) { mqtt=“>[mymosquitto:home/led:command:ON:1],>[mymosquitto:home/led:command:OFF:0”]
The problem is, I'm not able to figure out how to receive this On / Off command on an Arduino sensor node?
Here is my Arduino sensor node sketch: I'm using RF24 library from Tmrh20.
#include <RF24Network.h> #include <RF24.h> #include <SPI.h> #include <DHT.h> // The DHT data line is connected to pin 2 on the Arduino #define DHTPIN 2 // Leave as is if you're using the DHT22. Change if not. //#define DHTTYPE DHT11 // DHT 11 #define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); // PIR variables byte pirPin = 9; int pirCalibrationTime = 30; // Photocell variable byte photocellPin = A3; // Magnetic Door Sensor variable byte switchPin = 12; // Radio with CE & CSN connected to pins 7 & 8 RF24 radio(7, 8); RF24Network network(radio); // Constants that identify this node and the node to send data to const uint16_t this_node = 1; const uint16_t parent_node = 0; // Time between packets (in ms) const unsigned long interval = 1000; // every sec // Structure of our message struct message_1 { float temperature; float humidity; byte light; bool motion; bool dooropen; }; message_1 message; // The network header initialized for this node RF24NetworkHeader header(parent_node); void setup(void) { // Set up the Serial Monitor Serial.begin(9600); // Initialize all radio related modules SPI.begin(); radio.begin(); delay(5); network.begin(90, this_node); // Initialize the DHT library dht.begin(); // Activate the internal Pull-Up resistor for the door sensor pinMode(switchPin, INPUT_PULLUP); // Sensor Type 1 header.type = '1'; // Calibrate PIR pinMode(pirPin, INPUT); digitalWrite(pirPin, LOW); Serial.print("Calibrating PIR "); for(int i = 0; i < pirCalibrationTime; i++) { Serial.print("."); delay(1000); } Serial.println(" done"); Serial.println("PIR ACTIVE"); delay(50); } void loop() { // Update network data network.update(); // Read humidity (percent) float h = dht.readHumidity(); // Read temperature as Celsius float t = dht.readTemperature(); // Read temperature as Fahrenheit float f = dht.readTemperature(true); // Read photocell int p = analogRead(photocellPin); // Testing revealed this value never goes below 50 or above 1000, // so we're constraining it to that range and then mapping that range // to 0-100 so it's like a percentage p = constrain(p, 50, 1000); p = map(p, 50, 1000, 0, 100); // Read door sensor: HIGH means door is open (the magnet is far enough from the switch) bool d = (digitalRead(switchPin) == HIGH); // Read motion: HIGH means motion is detected bool m = (digitalRead(pirPin) == HIGH); // Only send values if any of them are different enough from the last time we sent: // 0.5 degree temp difference, 1% humdity or light difference, or different motion state if (abs(f - message.temperature) > 0.5 || abs(h - message.humidity) > 1.0 || abs(p - message.light) > 1.0 || m != message.motion || d != message.dooropen) { // Construct the message we'll send message = (message_1){ f, h, p, m, d }; // Writing the message to the network means sending it if (network.write(header, &message, sizeof(message))) { Serial.print("Message sent\n"); } else { Serial.print("Could not send message\n"); } } // Wait a bit before we start over again delay(interval); }
I'm using Raspberry Pi 2 as my Gateway: Here is the sketch for RPi Gateway
#include <RF24/RF24.h> #include <RF24Network/RF24Network.h> #include <iostream> #include <ctime> #include <stdio.h> #include <stdlib.h> #include <time.h> /** * g++ -L/usr/lib main.cc -I/usr/include -o main -lrrd **/ // CE Pin, CSN Pin, SPI Speed RF24 radio(RPI_BPLUS_GPIO_J8_15,RPI_BPLUS_GPIO_J8_24, BCM2835_SPI_SPEED_8MHZ); RF24Network network(radio); // Constants that identifies this node const uint16_t pi_node = 0; // Time between checking for packets (in ms) const unsigned long interval = 2000; // Structure of our message struct message_t { float temperature; float humidity; unsigned char light; bool motion; bool dooropen; }; int main(int argc, char** argv) { // Initialize all radio related modules radio.begin(); delay(5); network.begin(90, pi_node); // Print some radio details (for debug purposes) radio.printDetails(); printf("Ready to receive...\n"); // Now do this forever (until cancelled by user) while(1) { // Get the latest network info network.update(); printf(".\n"); // Enter this loop if there is data available to be read, // and continue it as long as there is more data to read while ( network.available() ) { RF24NetworkHeader header; message_t message; // Have a peek at the data to see the header type network.peek(header); // We can only handle type 1 sensor nodes for now if (header.type == '1') { // Read the message network.read(header, &message, sizeof(message)); // Print it out in case someone's watching printf("Data received from node %i: Temp = %f, Hum = %f, Light = %i, Motion = %i, Door Open = %i \n", header.from_node, message.temperature, message.humidity, message.light, message.motion ? 1 : 0, message.dooropen ? 1 : 0); // "sprintf" is a way to format a text string and then write he result to char array // (an array of characters is virtually the same as a string) // The string we're making is a command to push the temperature data on a mosquitto channel // And "system" is how you execute a shell command from a C program char buffer [50]; sprintf (buffer, "mosquitto_pub -t home/temperature -m \"%f\"", message.temperature); system(buffer); sprintf (buffer, "mosquitto_pub -t home/humidity -m \"%f\"", message.humidity); system(buffer); sprintf (buffer, "mosquitto_pub -t home/light -m \"%i\"", message.light); system(buffer); sprintf (buffer, "mosquitto_pub -t home/motion -m \"%i\"", message.motion ? 1 : 0); system(buffer); sprintf (buffer, "mosquitto_pub -t home/door -m \"%i\"", message.dooropen ? 1 : 0); system(buffer); } else { // This is not a type we recognize network.read(header, &message, sizeof(message)); printf("Unknown message received from node %i\n", header.from_node); } } // Wait a bit before we start over again delay(2000); } // last thing we do before we end things return 0; }
This is how my Openhab looks like
Please ignore temperature reading, It should be in Celsius. I will fix it later.
I really need help to implement the OpenHab On/OFF Led switch --> to MQTT mosquito --> Arduino.
I would really appreciate your help.
Thank You.