Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 30, 2014, 09:58:10 am
Sorry for the delay - very busy...


I have now the idea to be able to also set the brightness of my lamps via the Arduino.
If i use the neon lamps behind the dimmer and they also get dimmed it should be
possible with some logic in the code.
The question is what would work best: LDR, Photodiode or Phototransistor?

Then i have now another problem.
I need this self made optocoupler one time on some cable that is ~10 meter but just on and off (no dimmer) and it doesn't need
to be fast. It's J-Y(St)Y cable (~ AWG 23) and i think 5V over 10 meter and an LDR is not a good idea.
But i also have 24VDC there...
LDR + 24V + voltage divider possible or what can i do?
2  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 12, 2014, 10:22:39 am
As you can see in the datasheet from my dimmers they can do everything (leading phase angle / trailing phase angle).
I use electronic transformers for my LEDs.

The datasheet says:
Quote
Mixing of L loads (inductive loads, e.g. wound transformers) and C loads (capacitive loads,
e.g. electronic transformers) is not permitted. R loads (ohmic loads, e.g. 230V incandescent
lamps and halogen lamps) may be added anytime.
Hm, sounds save to put the neon lamp in parallel to the transformer.

Also from the datasheet:
Quote
Glow lamp current up to 5mA starting at 110V


I really don't want to kill such a expensive dimmer and need to be sure it will work.
3  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 11, 2014, 12:32:11 am
Ah ok, i looked and found some 230V 0.5 mA neons.
I was looking ad the ones we have here for the stwitches in our house.
But they are 20 years old and orange. I thought neons are always orange.
It looks like orange neons draw more power: http://www.conrad.de/ce/de/product/725013/Farbige-Glimmlampe-230-V-025-W-14-mA-Orange-Barthelme-Inhalt-1-St

But:
1. They lose brightness over years.
2. What happens with them behind a dimmer?
4  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 10, 2014, 03:38:27 pm
The neon lamps use ~0,35W.
From my point of view thats allot. In times where we change to LEDs in our house (incandescent light bulbs are already
banned here in Europe) and with the electricity price....
10 of this neon lamps running 24x365 is near $10 a year.
So if you look at all the stuff around the house, every watt counts.

Also the neon lamps will not work on the dimmers.
5  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 10, 2014, 01:10:32 pm
Ok, sorry if the german guy on the other end used the wrong word smiley
For me Power = On - like it is printed on all the on switches smiley-grin
If you look at it from the physics side then you are right.
6  Using Arduino / Project Guidance / Re: Zero Crossing Detector as high voltage power detector? on: September 10, 2014, 12:47:55 pm
I need voltage. I want to know if the relay, dimmer, switch, plug is on even if
the device behind it is off.
7  Using Arduino / Project Guidance / Zero Crossing Detector as high voltage power detector? on: September 10, 2014, 12:18:35 pm
Hi,

I'm looking for a way to check if some devices have power.
There are solutions like cheap 5V wall warts, relays, neon glow lamp...
But from my point of view the power waste is to big.
Also relays have the problem that most of them are not build for high and low voltage switching.
It would be easy to use a double switching relay if not both switches would be AgSnO2.

But there is another problem i have.
I use this dimmers in my house for LED lamps: http://www.eltako.com/fileadmin/downloads/en/datasheets/B_datasheet_EUD12NPN.pdf
And i want to check if they are on or off.

I found this circuit that wastes just 120mW: http://www.dextrel.net/diyzerocrosser.htm
Is this an option to detect power?
And will it work behind my dimmers?
8  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: May 02, 2014, 01:25:01 am
You don't know It?
http://deluxevideoonline.org/wp-content/uploads/2013/10/it-laugh.jpg
 smiley-grin

With it i meant the none compiling part.
And i was now looking for 10 minutes on the screen to find out what was wrong.
strncmp instead of strcmp

Ok the output is if i send my commands in that order:
Quote
1. "volume-ups"
Payload: volume-ups
Message:
Output: Run Code

2. "volume-ups"
Payload: volume-ups
Message: volume-ups
Output: Run Code

3. "volume-stop"
Payload: volume-stop
Message: volume-ups
Output: Stop Code

4. "volume-stop"
Payload: volume-stop
Message:
Output: Stop Code

5. "volume-ups"
Payload: volume-ups
Message:

6.
Payload: volume-ups
Message: volume-upsp
So after "volume-stop" the output (code that needs to be running) is empty on "volume-up".
By other words i can't turn the volume up after stopping it before.
Look at 6. after calling "volume-ups" a second time there is a "p" at the end of the message.
Where does that come from?

And before i forged: THANKS for helping.
9  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: April 30, 2014, 01:13:55 am
Yes,
Code:
void loop() {
  client.loop();
}
is lets the MQTT client run. If not you lose connection to the broker (HiveMQ on my Debian server)
http://knolleary.net/arduino-client-for-mqtt/api/#loop

Yes i need to subscript to the whole topic in the callback. I tested also "*/IR-SonyTV" and "#/IR-SonyTV" because i thought
it would work because i already subscribe in the setup.

This part does not compile:
Code:
  if (strncmp(message,"volume-stop")==0) {
    // do whatever you need to stop the volume-up
    Serial.println("stop volume-up");
    message[0] = '\0';
  }
Quote
c:/programme (zip)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h: In function 'void callback(char*, byte*, unsigned int)':
c:/programme (zip)/arduino/hardware/tools/avr/lib/gcc/../../avr/include/string.h:135: error: too few arguments to function 'int strncmp(const char*, const char*, size_t)'
sketch_apr30a:58: error: at this point in file
If i take it out the "volume-ups" part works. "Up" is printed one time.
10  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: April 29, 2014, 05:50:05 pm
Ok first full code:
Code:
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <IRremote.h>

/**************************************************************
*                                               Ethernet Settings                                         *
**************************************************************/

// Ethernet Card Mac Address
byte mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
// IPv4 address
byte ip[] = {192, 168, 0, 99};
// Subnet mask
byte subnet[] = {255, 255, 255, 0};
// Default gateway
byte gateway[] = {192, 168, 0, 1};
// MQTT Broker
byte MqttBroker[] = { 192, 168, 0, 12 };
// Preferred DNS sever
// byte dns[] = {192, 168, 0, 1};

/**************************************************************
*                                                       Declare                                                    *
**************************************************************/

IRsend irsend;
int test = 0;

/**************************************************************
*                                                          MQTT                                                    *
**************************************************************/

// MQTT Callback
void callback(char* topic, byte* payload, unsigned int length) {
 
  Serial.print("New message from broker on topic: ");
  Serial.println(topic);

  Serial.print("Payload: ");
  Serial.write(payload, length);
  Serial.println();
  Serial.print("Test: ");
  Serial.println(test);

  // IR Remote Sony TV
  if (strcmp(topic,"skulltronics.net/hive/floor/optimus-prime/IR-SonyTV")==0) {
   
    // Volume Up Nonstop
    if (length == 10 && strncmp((char*)payload,"volume-ups",10)==0) {
      for (int i = 0; i < 250; i++) {
        Serial.println("running");
        delay(50);
        if (test == 1) {
          break;
        }
      }
    }// End Volume Up Nonstop

    // Stop Volume Up Nonstop
    if (length == 11 && strncmp((char*)payload,"volume-stop",11)==0) {
      test = 1;
    } // End Stop Volume Up Nonstop

  } // End IR Remote Sony TV

} // End MQTT Callback

// Fire up PubSub client
EthernetClient ethClient;
PubSubClient client(MqttBroker, 1883, callback, ethClient);

/**************************************************************
*                                                       Setup                                                       *
**************************************************************/

void setup() {

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Ethernet.begin(mac, ip, subnet, gateway);
  Serial.print(" IPv4 address: ");
  Serial.println(Ethernet.localIP());
   
  // Connect to Broker, give it Optimus Prime as the name
  if (client.connect("Optimus Prime")) {
    // Publish a message to the status topic
    client.publish("status","Optimus Prime is now online");
    // Listen for messages on the control topic
    client.subscribe("skulltronics.net/hive/floor/optimus-prime/#");
  }

}

void loop() {
  client.loop();
}
If i don't do the "strncmp length test" then my "for loop" is not running.
There is another way with a running for loop:
Code:
// MQTT Callback
void callback(char* topic, byte* payload, unsigned int length) {
 
  // ********** IR Remote Sony TV ********** //
  // Volume Up Nonstop
  if (strcmp(topic,"skulltronics.net/hive/floor/optimus-prime/IR-SonyTV/volume-ups")==0) {
    if (payload[0] == '1') {
      for (int i = 0; i < 250; i++) {
        Serial.println("running");
        irsend.sendSony(0x490, 12);
        delay(50);
        if (test == 1) {
          break;
        }
      }
    }
  } // End Volume Up Nonstop

  // Stop Volume Up Nonstop
  if (strcmp(topic,"skulltronics.net/hive/floor/optimus-prime/IR-SonyTV/volume-stop")==0) {
    if (payload[0] == '1') {
      test = 1;
    }
  } // End Stop Volume Up Nonstop
  // ********** End IR Remote Sony TV ********** //

} // End MQTT Callback
The second example means i have to call every command with his own topic and send "1" as message.
From my point of view it makes more sense to call the remote (IR-SonyTV) and send as message
what to do (volume-up) instead of calling the remote, then the button and tell the button what to do.
It has to do with null- termination and there is more about it here (comment 50 to 60): http://knolleary.net/arduino-client-for-mqtt/
Also i have to do it like in the first example if i want to send the IR-Remote hex code over MQTT.

Ok, what this code now does is printing "running" if i send "volume-ups".
I the send "volume-stop" and "running" is still printed.
After the 250 "running" prints i get my:
Quote
New message from broker on topic: skulltronics.net/hive/floor/optimus-prime/IR-SonyTV
Payload: volume-stop
Test: 0
print.

If i send then "volume-ups" as expected "running" is only printed once and Test: 1
So setting "test" works.

I need to send every command minimum 3 times to the IR-LED. That is how Sony remotes work.
You press a button and the IR-LED blinks 3 times.
So for my non-stop volume up i normally need:
3 blinks 50ms pause 3 blinks 50ms pause...
until i say "volume-stop"
11  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: April 27, 2014, 12:06:19 am
Ok, another 4 hours. I don't get it.
I also tested it with
Code:
while(test == 1) {
    Serial.println("up");
    if (test == 0) {
      goto outer;
    }
 }
outer:;
in the void loop.
What i'm missing or doing not how all the other examples i see are done:
http://forum.arduino.cc/index.php?topic=41706.msg302984#msg302984
First answer: http://stackoverflow.com/questions/863172/how-can-i-break-out-of-two-nested-for-loops-in-objective-c
http://letsmakerobots.com/node/37905




12  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: April 21, 2014, 10:34:54 am
Quote
Well, that's perfectly obvious. To you.
It is cause its the payload.
The topic says MQTT so this is about the Arduino pubsubclient.
Quote
But it sure doesn't have to have the meaningless name "callback".
It is not meaningless if you know MQTT in conjunction with Arduino cause it's part of
the pubsubclient (Arduino client for MQTT).

And everything is working great. Switching house lights, TV  programs, Doorbell ring through Asterisk over VoIP
to Softphones, 1-Wire sensor logging to MariaDB....
I only can't get this stupid loop stop to work.

I do it with voice commands.
The idea was if i say "TV volume up" that the Arduino sends the IR signal until i say "volume stop".
Volume up works but i can't stop it.

The server sends payload "volume-up" to the Arduino and runs it and it's working.
But if i send then the payload "volume-stop" it does not stop running "volume-up".
If i check my "int test" after sending "volume-stop" it's set to "1" but does not effect the running  "volume-up" loop.
13  Using Arduino / Programming Questions / Re: Break/Stop loop with MQTT payload/message on: April 21, 2014, 05:40:24 am
@lar3ry, you don't know MQTT? Then for sure my code makes no sense to you.
MQTT = Message Queue Telemetry Transport: http://en.wikipedia.org/wiki/MQ_Telemetry_Transport

Callback is part of http://knolleary.net/arduino-client-for-mqtt/

So "volume-up" runs if my MQTT broker on my server sends: "/mytopic/mytopic/IR-SonyTV/volume-up"
And "test" gets changed if i call/send: "/mytopic/mytopic/IR-SonyTV/volume-stop"
14  Using Arduino / Programming Questions / Break/Stop loop with MQTT payload/message on: April 20, 2014, 07:39:59 pm
Hi,

after almost two days i give up.
I want to stop a loop with MQTT but can't get it to work.
I tried endless possibilities. Here is one:
Code:
int test = 0;
void callback(char* topic, byte* payload, unsigned int length) {

  if (length == 9 && strncmp((char*)payload,"volume-up",9)==0) {
    for (int i = 0; i < 1000; i++) {
      Serial.println("up");
      Serial.println(test);
      delay(50);
      if (test == 1) {
        break;
      }
    }
  }


  if (length == 11 && strncmp((char*)payload,"volume-stop",11)==0) {
    Serial.println("stop");
    Serial.println(test);
    test = 1;
  }

}
If i call "volume-up" and get my test prints and then call "volume-stop" nothing happens.
If i call "volume-stop" first and then again i see that "test" has a value of "1".
Also "volume-up" is then printed just once.

I also tried it in "void loop()" with:
Code:
while (test == 0) {
  Serial.println("its running");
  Serial.println(test);
  // delay(20);
  if (test == 1){
    break;
  }
}
But that also doesn't stop if i call "volume-stop".

I'm out off ideas smiley-sad
15  Using Arduino / Networking, Protocols, and Devices / Re: 1-Wire Vcc GND - connect to Data GND on sensors? on: April 02, 2014, 02:33:47 pm
beside the sensor
Then 1-Wire would not make sense smiley

I don't sum it up yet. But 15, 20,  30 meters is nothing in a house.
From living room to bed room 8m...
From bed room to bath room 8m...
To the sensor and back in the cement flooring is 4+4=8m
That alone makes 16 meters!
Then i go to the windows (each 2 reed switches and a glass breakage detector)...

I found one guy who uses the Loxone Smart Home Automation and has 1 ring
for each floor of his house. Every window, door, temp in every room and so on...
And Maxim writes about 100, 200, 500 meters - so it should not be a problem if you do it right.
But now i have S/FTP PiMF everywhere and its to late cause i thought its the best.
I use CAT6 for one wire and my light switches and CAT7 for Ethernet.

Quote
Try it in an environment as identical as possible to the final installation
How can somebody to that? How to replicate all the wires/electric in your house (walls, ceiling)?
Especially if you just start to build your house...

No Apple stuff in da house smiley-evil

I extra bought two books about EMC/EMI from VDE (http://en.wikipedia.org/wiki/Verband_der_Elektrotechnik,_Elektronik_und_Informationstechnik)
Pages: [1] 2 3 ... 8