Cool project! Following.
Posts made by gadu
-
RE: MQTT and batterylevel
First these two rows before setup..
int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point int oldBatteryPcnt = 0;
and in the loop i have these rows...
// get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); //Serial.println(sensorValue); // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep gw.sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt;
in OpenHab items i have this row...
Number node2_batt "Battery [%.1f %%]" <energy> (node2,All) {mqtt="<[MySensor:MyMQTT/21/1/V_VAR1:state:default]"}
hope this helps....
-
RE: 230V power supply to Arduino
I've seen these and also got interested. Any input on these is appreciated.
-
RE: Gerber/Eagle files and then...?
Great, thanx! I have to look into this, so tired of the experimentboards
-
Gerber/Eagle files and then...?
Well, I see some of you creating great custom boards in many (very interesting) sizes and shapes.
But for a n00b in that area... if i would get hold of a gerber/eagle file, how and where do you go about to order them? Is there any "how-to"? -
RE: MQTT controller - ping but Connection timeout on MQTT clients
@TommySharp
Hmm dont really remember, but I think this was the solution
https://github.com/knolleary/pubsubclient/issues/46 -
RE: Arduino Pro Mini adapter card and nice box from "biltema"
When you order, lรคgg till 5st
-
RE: Arduino Pro Mini adapter card and nice box from "biltema"
Where can one find these boards?
-
RE: Humidity / Temperature Sensor
Cool!
Perhaps a noob question, but how do you program the Atmega? -
RE: Sensor shield for Arduino Pro Mini 3.3V with boost up regulator
I like the formfactor and if the price is right i'd buy a couple (5-10pcs).
-
RE: Small wall outlet sensor node
It would be cool with a 90degree angled version as well
-
RE: Strange value being sent from controller using mixed temp/relay node
Here goes...
This is the ProMini output from the monitor when I turn on and off the relay...
send: 23-23-0-0 s=1,c=1,t=2,pt=2,l=2,st=ok:1 read: 0-0-23 s=1,c=1,t=2,pt=2,l=2:1 This is an ack from gateway Incoming change for sensor:1, New status: 1 read: 0-0-23 s=1,c=1,t=2,pt=0,l=4:1.6r Incoming change for sensor:1, New status: 1 send: 23-23-0-0 s=1,c=1,t=2,pt=2,l=2,st=ok:0 read: 0-0-23 s=1,c=1,t=2,pt=2,l=2:0 This is an ack from gateway Incoming change for sensor:1, New status: 0 read: 0-0-23 s=1,c=1,t=2,pt=0,l=4:0.6r Incoming change for sensor:1, New status: 0
This what I see on the gateway when I turn on and off the relay....
publish: MyMQTT/23/1/V_LIGHT 1 0;0;3;0;9;send: 0-0-23-23 s=1,c=1,t=2,pt=0,l=4,st=ok:1sor 0;0;3;0;9;read: 23-23-0 s=1,c=1,t=2,pt=2,l=2:0 0;0;3;0;9;send: 0-0-23-23 s=1,c=1,t=2,pt=2,l=2,st=ok:0 publish: MyMQTT/23/1/V_LIGHT 0 0;0;3;0;9;send: 0-0-23-23 s=1,c=1,t=2,pt=0,l=4,st=ok:0sor 0;0;3;0;9;read: 23-23-0 s=1,c=1,t=2,pt=2,l=2:1 0;0;3;0;9;send: 0-0-23-23 s=1,c=1,t=2,pt=2,l=2,st=ok:1
I hope it helps.
-
RE: Strange value being sent from controller using mixed temp/relay node
I'll get tomorrow. No worries
-
RE: MQTT Gateway and Relay Status
I'm thinking outside the box (shouldn't do that) so here goes...
This would require another type of relay with dual connections.
If you combine the doorsensor with the relay sketch the arduino if "forced" to send activity (V_TRIPPED) from the relay.Here's a poor painted sketch...
Or something similar...
-
RE: Strange value being sent from controller using mixed temp/relay node
@Gambituk said:
@gadu if you have a setup running, could you publish a message on your mosquitto server just like this?
MyMQTT/25/1/V_LIGHT 1 MyMQTT/25/1/V_LIGHT 0
I don't think it matters if you have any relays connected or defined, it's just to see what value it tries to send to the node... (assuming you have your gateway connected to a pc to be able to see the serial output)?
No problems if this is not possible.
Actually yes, I have a relay sketch that BulldogLowell helped me with in this thread:
http://forum.mysensors.org/topic/901/relaywithbuttonactuator-another-n00b-question/7The idea behind the sketch is written in the thread, but the short story is that I needed two relays and when the button is pressed one goes on for a sec (then off) and the other goes on until i push the button again. So it's actually only controlling one relay, nothing else.
By publishing...pi@raspberrypi ~ $ mosquitto_pub -r -t MyMQTT/23/1/V_LIGHT -m "1" pi@raspberrypi ~ $ mosquitto_pub -r -t MyMQTT/23/1/V_LIGHT -m "0"
I can see the following...
pi@raspberrypi ~ $ mosquitto_sub -v -t MyMQTT/# MyMQTT/23/1/V_LIGHT 1 MyMQTT/23/1/V_LIGHT 0
-
RE: Strange value being sent from controller using mixed temp/relay node
Interesting findings, if you find any solution for this in the MQTT gateway I would really appreciate if you post it. I'm about to start implementing relays as well.
(it's actually not my version, I think @ntruchsess is the one who created it)
-
RE: Strange value being sent from controller using mixed temp/relay node
Just guessing here, have you different child id's on the temp and relay?
-
RE: RelayWithButtonActuator - another n00b question
@BulldogLowell
Well, the idea is actually simple. I have today a HTPC hidden on the other side of the livingroom wall (where the tv is). Both are connected to a Master (HTPC) and Slave (TV) power strip (are they called so?)
When I start the HTPC with a button the PC boots and and the power strip turns on the TV.
These are a bit pricey and now it has started to give me trouble, so why not let a cheaper arduino with two relays take care of it?
One relay starts the PC (toggle) and the other relay starts the TV. This gives me also the option to start the HTPC/TV remote as well using OpenHAB and MQTT.
Before shutting down the PC it can simply publish a command to turn off the TV using mosquitto_pub.Perhaps not the most optimal solution, but it's simple which means a higher WAF as well
Hope it made any sense...
-
RE: RelayWithButtonActuator - another n00b question
Omg, works just perfect! Thanks alot!!
-
RE: Reed Switch normally open or normally closed
Really nice! But can't you buy reed-switches for doors already?
Like these (sorry for the swedish links)?http://www.clasohlson.com/se/Magnetisk-larmkontakt/Pr325329000
-
RE: RelayWithButtonActuator - another n00b question
I'm still at this trying to create a sketch.
Been playing around with millis() without any luck, ran into a example while google for a solution, however this uses delay.
Not an issue though that delay is stops the processing, just trying to understand how this works. I've come this far (using led instead of relay), the idea is that when pressing the button the led = high for 1sec then led = low.
In MQTT I need to see both V_LIGHT=1 and then V_LIGHT=0.Any ideas or pinpointers? I know i'm wandering the dark here..
This is the sketch so far, cut&paste from all over...#include <MySensor.h> #include <SPI.h> #include <Bounce2.h> #define BUTTON_PIN 3 #define CHILD_ID 1 // Id of the sensor child #define RELAY_ON 1 #define RELAY_OFF 0 // constants won't change. Used here to // set pin numbers: const int ledPin = 4; // the number of the LED pin int oldValue=1; // Variables will change: int ledState = LOW; // ledState used to set the LED Bounce debouncer = Bounce(); bool state; MySensor gw; MyMessage msg(CHILD_ID,V_LIGHT); // the follow variables is a long because the time, measured in miliseconds, // will quickly become a bigger number than can be stored in an int. void setup() { gw.begin(incomingMessage, AUTO, true); // Send the sketch version information to the gateway and Controller gw.sendSketchInfo("RelayDelay with button", "1.0"); // 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(CHILD_ID, S_LIGHT); // set the digital pin as output: pinMode(ledPin, OUTPUT); // Make sure relays are off when starting up digitalWrite(ledPin, ledState); // Set relay to last known state (using eeprom storage) state = gw.loadState(CHILD_ID); //digitalWrite(ledPin, state?RELAY_ON:RELAY_OFF); } void loop() { debouncer.update(); int value = debouncer.read(); if(value == 0 && oldValue == 1) { if(ledState == HIGH) { digitalWrite(ledPin, LOW); } else { digitalWrite(ledPin, HIGH); //gw.send(msg.set(state?false:true), true); delay(1000); digitalWrite(ledPin, LOW); gw.send(msg.set(state?false:true), true); } } } 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.type == V_LIGHT) { // Change relay state state = message.getBool(); digitalWrite(ledPin, state?RELAY_ON:RELAY_OFF); // Store state in eeprom gw.saveState(CHILD_ID, state); // Write some debug info Serial.print("Incoming change for sensor:"); Serial.print(message.sensor); Serial.print(", New status: "); Serial.println(message.getBool()); } }
-
RE: RelayWithButtonActuator - another n00b question
@olaeke hehe yup, google helped me out there... Sometimes you get stuck on silly things...
-
RE: RelayWithButtonActuator - another n00b question
This was actually useful....
http://playground.arduino.cc/Code/AvoidDelay -
RelayWithButtonActuator - another n00b question
So here we go again with the n00b questions...
Setup:
Two relays and one buttonUse case:
- Press button
1.1) Relay_1 ON
1.2) Relay_2 ON
1.3) delay(1000) then Relay_2 OFF - Press button
4.1) Relay_1 OFF
Been trying this a couple of hours today and nothing worked, if I add some delay or change anything in the sketch the button instantly stops working. I have no sketch to share since nothing has been even close. I've searched the forum and nothing.
Anyone have any pinpointers where to start looking? Links? Anything?I tried different versions like this with only one relay and trying to get it to turn off after 1sec, but with no success....
void loop() { gw.process(); debouncer.update(); // Get the update value int value = debouncer.read(); if (value != oldValue && value==0) { gw.send(msg.set(state?false:true), true); // Send new state and request ack back } oldValue = value; delay(1000); digitalWrite(RELAY_PIN, RELAY_OFF); }
- Press button
-
RE: MQTT Gateway and Relay Status
I have exactly the same question after playing around with a relay and MQTT today.
Following this thread... -
Keypads
Did a quick search and could not find anything about keypads.
Anyone who's worked on a project using MySensor and keypads?The idea I have is to combine a RFID and keypad.
-
RE: OpenHab mqtt binding only one topic
Not sure about this, but could it be the syntax for the mapping that don't work?
Switch item=itm_office_mqtt_string label="What my Raspberry Pi said:" mappings=[1=Yes, 2=No, 3=Maybe]Got this from here... Note the spaces and quotes.
Mappings can be used to let the user chose an item from a list.
Syntax:
mappings = [ "value1"="name1", "value2"="name2" ]Quotes can be omitted if the value string and name string do not contain spaces.
Examples:
mappings = [ "1"="ON", "0"="OFF" ]
mappings = [ 1="BBC", 2="CNN", 3="BLOOMBERG" ] -
RE: OpenHab mqtt binding only one topic
What does your items and your sitemap config look like?
-
RE: MQTT controller - ping but Connection timeout on MQTT clients
great!
My working setup is
Sensors -> ETH MQTT ClientGateway -> Mosquitto -> OpenHAB(sorry for the swedish)
-
RE: Multiple interuppts: One Arduino with two door sensors?
How about 3 doorsensors? Just +1 on everything?
-
RE: MQTT controller - ping but Connection timeout on MQTT clients
I use the latest 1.0.6 IDE on Win7 and loaded the latest MySensor libraries
https://github.com/mysensors/Arduino/
Added the attached libraries and they compiled just fine for me...MyMQTTGateway.zip
Note1: Included is MyMQTTGateway and Pubsubclient.Note2: This will make the gateway act as a MQTT client so you need Mosquitto (or similar) where you publish the topics from the gateway.
Note3: Remember to change the IP and Mac.
-
RE: MQTT controller - ping but Connection timeout on MQTT clients
I'm pretty far from my computer today and tomorrow,but I'll check.
I have the latest IDE at least.Meanwhile perhaps @ntruchsess himself can help?
-
RE: MQTT controller - ping but Connection timeout on MQTT clients
@cayco Have you tried ntruchsess gateway sketch? Worked fine for me.
-
RE: Battery power sensor acting strange
@kalle aah... that could be the reason!
noobish question perhaps, but what's the tap point?
-
Battery power sensor acting strange
So, I hooked up a Pro Mini with a DS18B20 and Battery Sensor resistors from the guide here. I have not yet cut off the LED or regulator and the complete sensor is running on 2xAA batteries.
Everything is working just fine, but today I noticed some strange behaviour where the battery percentage bounched to 87%, back to 83% and up to 89%... is this normal? What could be the reasons behind it?
This is how it looks like
Code I'm using
#include <MySensor.h> #include <SPI.h> #include <DallasTemperature.h> #include <OneWire.h> #define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point MySensor gw; int oldBatteryPcnt = 0; float lastTemperature[MAX_ATTACHED_DS18B20]; int numSensors=0; boolean receivedConfig = false; boolean metric = true; // Initialize temperature message MyMessage msg(0,V_TEMP); MyMessage msgvolt(1,V_VAR1); void setup() { // Startup OneWire sensors.begin(); // use the 1.1 V internal reference analogReference(INTERNAL); // Startup and initialize MySensors library. Set callback for incoming messages. gw.begin(); // Send the sketch version information to the gateway and Controller //gw.sendSketchInfo("Temperature Sensor", "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, S_TEMP); } } 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 and no error if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature gw.send(msg.setSensor(i).set(temperature,1)); lastTemperature[i]=temperature; } } // get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); //Serial.println(sensorValue); // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep //gw.sendBatteryLevel(batteryPcnt); gw.send(msgvolt.set(batteryPcnt)); oldBatteryPcnt = batteryPcnt; } gw.sleep(SLEEP_TIME); }
-
RE: rboard - Cheap relay/radio/arduino board ~$10
Cool, this one is also interesting!
-
RE: Raspberry Pi Ethernet Gateway
I believe TMRh20 mentions this on his blog, could be worth reading
http://tmrh20.github.io/RF24Ethernet/ -
RE: MQTT and batterylevel
If anything, let me know! Dunno if I can be of any help, but i could try
Odd thing happend though, When the Mini is connected to the FTDI the serial monitor says "Check Wires", but on battery it sends everything correct?
Well, that's another issue to look at later... -
RE: MQTT and batterylevel
@mbj saved my day!!
publish: MyMQTT/21/0/V_TEMP 23.5 0;0;3;0;9;send: 0-0-21-21 s=0,c=1,t=0,pt=0,l=5,st=ok:23.5r 0;0;3;0;9;read: 21-21-0 s=1,c=1,t=24,pt=2,l=2:87 publish: MyMQTT/21/1/V_VAR1 87
And you called yourself a beginner?
-
RE: MQTT and batterylevel
Big thanks @mbj
I'm more of a beginner than you. Trust me.I'll do some experiments using you pointers.
-
RE: MQTT and batterylevel
Nope, I cant get this to work...
I really would appreciate if someone could help me with an working example where batterylevel can be presented as a MQTT topic.Help!
-
RE: MQTT and batterylevel
Like this?
// Initialize temperature message MyMessage msg(0,V_TEMP); MyMessage msgvolt(1,V_VOLTAGE);
-
MQTT and batterylevel
I can't get the ProMini to publish the batterylevel.
In the serial interface I can see that it is reporting the levels correct, but nothing reaches Mosquitto nor OpenHAB.My sketch looks likes this, what am I doing wrong?!
#include <MySensor.h>
#include <SPI.h>
#include <DallasTemperature.h>
#include <OneWire.h>#define ONE_WIRE_BUS 3 // Pin where dallase sensor is connected #define MAX_ATTACHED_DS18B20 16 unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds) OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); int BATTERY_SENSE_PIN = A0; // select the input pin for the battery sense point MySensor gw; int oldBatteryPcnt = 0; 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(); // use the 1.1 V internal reference analogReference(INTERNAL); // Startup and initialize MySensors library. Set callback for incoming messages. gw.begin(); // Send the sketch version information to the gateway and Controller //gw.sendSketchInfo("Temperature Sensor", "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, S_TEMP); } } 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 and no error if (lastTemperature[i] != temperature && temperature != -127.00) { // Send in the new temperature gw.send(msg.setSensor(i).set(temperature,1)); lastTemperature[i]=temperature; } } // get the battery Voltage int sensorValue = analogRead(BATTERY_SENSE_PIN); //Serial.println(sensorValue); // 1M, 470K divider across battery and using internal ADC ref of 1.1V // Sense point is bypassed with 0.1 uF cap to reduce noise at that point // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts // 3.44/1023 = Volts per bit = 0.003363075 float batteryV = sensorValue * 0.003363075; int batteryPcnt = sensorValue / 10; Serial.print("Battery Voltage: "); Serial.print(batteryV); Serial.println(" V"); Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %"); if (oldBatteryPcnt != batteryPcnt) { // Power up radio after sleep gw.sendBatteryLevel(batteryPcnt); oldBatteryPcnt = batteryPcnt; } gw.sleep(SLEEP_TIME); }
-
RE: Help needed - MQTT Ethernet gateway to Openhab
Don't want to lock myself into one solution (point-to-point, GW <-> OpenHAB) so I actually wanted a middleware between MySensors and OpenHAB just in case there's other devices (i.e non-arduino) that support MQTT.
If I in the future get tired of OpenHAB and want to go for another "frontend" just simply delete OpenHAB and connect something else that supports MQTT to the Mosquitto broker. -
RE: Help needed - MQTT Ethernet gateway to Openhab
@mbj Nice! I didn't get it work with OpenHAB directly to the MQTT GW, with a broker it worked like a charm.
@brad.s Perhaps a stupid question, but did you remove the comments "#" before the mqtt:mysensor.url=tcp://192.168.2.150:1883 ?
I would anyhow advise to install Mosquitto just for checking that the GW sends the correct things.
-
RE: sensor logging, and automation..
Well, I'm also moving bricks around in my head regarding the same matter.
My first test would be to use Mosquitto_sub in verbose mode with a Php script to load the db with raw data, in SQL you can later refine the data. That's how far my bricks have moved for now... -
RE: Help needed - MQTT Ethernet gateway to Openhab
On the RPi I used Mosquitto as a broker between the MQTTGateway and OpenHAB. Works perfectly.
-
RE: OpenHab, MQTT gateway and Battery level - how?
Hi @doctor64 ,
How did you solve the battery reporting?
Did you implement the changes in h and cpp file from the link and compiled/uploaded the gateway sketch again?