Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / program won't run any more when adding #include <SD.h> on: December 09, 2012, 11:28:12 am
My program is 500 lines of code and runs stable for days days. I'm using these lib's;

Code:
#include <stdio.h>
#include <SPI.h>
#include <WiFi.h>
#include <Time.h>

I wanted to extend my code and start using data loggin on the SD card on my WiFi shield.

As soon as I add;

Code:
#include <SD.h>

Code won't run anymore... Nothing zero, nadah...

I'm not doing anything else, I don't initialize the SD card, I'm not adressing one function on the SD.h lib, only the one include line, and my program doesn't run any more...

Wierd buggy Arduino...
2  Using Arduino / Programming Questions / Re: How do I sync the internal clock with NTP over WiFi? on: December 08, 2012, 03:13:58 pm
I've found an example which needs EthernetUdp, can you also use this with WiFi?
3  Using Arduino / Programming Questions / How do I sync the internal clock with NTP over WiFi? on: December 08, 2012, 10:01:57 am
I've got a WiFi shield, and I connect to the internet succesfully, but I need to sync the internal clock with a NTP server.

I can find ton's of Ethernet Sheild examples. But Since I only have a Wifi sheild...

It kinda get stuck on the UDP thing, any help/example would be great!

Thanks!
4  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 06:03:29 pm
I get this error tho;

 error: cannot convert 'StringSumHelper' to 'char*' for argument '1' to 'void wltl(char*)'

Code:
void wltl(char *logmessage) { // write line to log
          if(DEBUG){
            Serial.print(hour());
            Serial.print(":");
            Serial.print(minute());
            Serial.print(":");
            Serial.print(second());
            Serial.print(":");
            Serial.println(logmessage);
          }
}

And I call it with this;

Code:
  wltl("IP Address: " + String(ip[0]) + "." + String(ip[1]) + "." + String(ip[2]) + "." + String(ip[3]));

The WLTL routine is suppose to make live easier, to centrally controll weather or not to write log items to disc, or add time stamps.

If I first have to construct a string, and then pass it, I might as well just plot it...

I'm a VB guy, I don't understand all this fuzz.
5  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 05:50:14 pm
Majenko, Drone, thanks a lot! smiley
6  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 04:31:57 pm
It this all because you are passing a pointer to the string, and not the actual string?
7  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 04:29:35 pm
Okey,

But what if I want to pass 5 arguments;

Code:
  wltl("IP Address: " + String(ip[0]) + "." + String(ip[1]) + "." + String(ip[2]) + "." + String(ip[3]));
  wltl("Signal strenght (RSSI): " + String(WiFi.RSSI()) + "dBm");

Do I have to write 5 overload routines?

8  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 04:04:18 pm
And why exactly are strings evil?
9  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 04:03:39 pm
But this forces me to allways pass 2 arguments to the function,

I sometimes just want to '

Code:
wltl("blaaat");

Without having to:
Code:
wltl("blaaat" ,"");

To make it all work.

Is there not a way to combine the string before passing it to the function?
10  Using Arduino / Programming Questions / Re: Passing a string to a function/sub on: December 04, 2012, 03:27:43 pm
Is that because they can't be of variable lenght?,

And with a char array, how exactly would you write the log routine?

Thanks!
11  Using Arduino / Programming Questions / Passing a string to a function/sub on: December 04, 2012, 03:18:21 pm
I've made a function to write a line to the log;

Code:
void wltl(String logmessage) { // write line to log
          if(DEBUG){
           Serial.println(String(hour()) + ":" + String(minute()) + ":" + String(second()) + " " + logmessage);
          }
}

But I get some strange results when I run this.

I call it like this;

Code:
  wltl("SSID: " + String(WiFi.SSID()));

Thanks for your help guys...!  smiley
12  Using Arduino / Networking, Protocols, and Devices / Re: Sending FS20 commands using a Arduino and a TX868-75 on: November 29, 2012, 05:06:11 am
1. I've got this from a german forum, apparently a 150 ohm resister should do the job.

2. Second question;

https://github.com/jcw/jeelib

Kudo's for Jean-Claude Wippler!

13  Using Arduino / Networking, Protocols, and Devices / Sending FS20 commands using a Arduino and a TX868-75 on: November 28, 2012, 12:15:13 pm
Hello fellow Arduino users, I have a Arduino Uno, and I want to send FS20 commands.

I've got a TX868-75 (http://www.elv.de/hf-sendemodul-tx868-75-868-mhz.html)

Two questions on this matter;
1-The TX868-75 has 3 connectors, plus, ground and signal, what is the best way to connect the signal pin to the Arduino? The TX868-75 expects 3volts on the singal pin, but the arduino sends 5 volts.
2-Does anyone have a software example on how to send commands to the TX868-75 module?

I found some german forum posts on question one, but I don't really understand that.

Thanks in advance!
14  Using Arduino / Project Guidance / Re: Wireless doorbell on: November 17, 2012, 02:47:04 pm
I've spend the last week figuring out what was wrong with my approch.

I've ruled out some other hardware aspects like voltage, batteries, reciever used. (I've tried several RX868 recievers).

I've also tested the wireless doorbell, the FS20 TK my a FS20 hardware power switch. And it works, even 3 floors away. So it's not the FS20 TK.

And I've started to study, and break down the code to the bare minimum that I need. (I'm only gonna use FS20) Also I've added some comments, I'm not a native 'C' speaker, I speak assembler and basic, so it took me some time to figure out some of the syntax.

And this is the resulting code;

Code:
// The basic idea is to measure pulse widths between 0/1 and 1/0 transitions,
// and to keep track of pulse width sequences in a state machine.
// can't just change these pin definitions, PIN_868 uses interrupts
#define PIN_868 14  // the 868 MHz receiver is connected to AIO1

enum { UNKNOWN, T0, T1, T2, T3, OK, DONE };

// track bit-by-bit reception using multiple independent state machines
struct { char bits; byte state; uint32_t prev; uint64_t data; } FS20;

static byte FS20_bit (char value) {
    FS20.data = (FS20.data << 1) | value;  // shift left one, and AND with value
    if (FS20.bits < 0 && (byte) FS20.data != 0x01)
        return OK;
    if (++FS20.bits == 45 && ((FS20.data >> 15) & 1) == 0 ||
          FS20.bits == 54 && ((FS20.data >> 24) & 1))
        return DONE;
    return OK;
}

    byte zerosfound;
    
static void ook868interrupt () {
  // the ook interrupt occours on a FS20 protocol split, so on 300usec for a 0, and on 500ms for a 1
    // count is the pulse length in units of 4 usecs
    byte count = TCNT2;
    TCNT2 = 0; // reset the timer to 0
    // FS20 pulse widths are 400 and 600 usec (split on 300, 500, and 700)
    // see http://fhz4linux.info/tiki-index.php?page=FS20%20Protocol
    if (FS20.state != DONE) {
        switch ((count - 25) / 50) {  
          // count values from 75 to 124 are considered a '0'
          // count values 125 to 174 are considered a '1'
            case 1:  FS20.state = FS20.state == T0 ? FS20_bit(0) : T0; break;
            case 2:  FS20.state = FS20.state == T1 ? FS20_bit(1) : T1; break;
            default: FS20.state = UNKNOWN;
      
          }
    }
}

static void reset_FS20 () {
    FS20.bits = -1;
    FS20.data = 0xFF;
    FS20.state = UNKNOWN;
}

static void ook868timeout () {
    if (FS20.state != DONE) {
        reset_FS20();
        //Serial.print(TCNT1);
        //Serial.println();
    }
}

static void ook868setup () {
    pinMode(PIN_868, INPUT);
    digitalWrite(PIN_868, 1); // pull-up
    
  
    // enable pin change interrupts on PC0
    PCMSK1 = bit(0);
    PCICR |= bit(PCIE1);

    /* prescaler 64 -> 250 KHz = 4 usec/count, max 1.024 msec (16 MHz clock) */
    // prescaler 32 -> 500 KHz = 2 usec/count
    TCNT2 = 0;
    TCCR2A = 0;
    TCCR2B = _BV(CS22);
    //TCCR2B = _BV(CS21) | _BV(CS20);
    TIMSK2 = _BV(TOIE2);  // set the 6th bit to true, enabling overflow interrupt
    
    reset_FS20();
}

// Poll and return a count > 0 when a valid packet has been received:
//  4 = S300
//  5 = FS20
//  6 = FS20 extended
//  7 = KS300
//  9 = EM10*

static byte ook868poll (byte* buf) {
    if (FS20.state == DONE) {  
        uint32_t since = millis() - FS20.prev;
      if (since > 150) {
        byte len = FS20.bits / 9;
        byte sum = 6;
        for (byte i = 0; i < len; ++i) {
            byte b = FS20.data >> (1 + 9 * i);
            buf[len-i-1] = b;
            if (i > 0)
                sum += b;
        }
        if (sum == buf[len-1]) {

            FS20.prev = millis();
            reset_FS20();
            return len;
        }
      }
      reset_FS20();
    }
      
    return 0;
}

ISR(TIMER2_OVF_vect)    { ook868timeout(); }
ISR(PCINT1_vect)        { ook868interrupt(); }

void setup () {
    Serial.begin(115200);
    Serial.println("FS20 Test\n");
    ook868setup();
}

void loop () {
    byte buf[10];
    byte len = ook868poll(buf);
    if (len != 0) {

        Serial.print("Time: ");
        Serial.println(millis() / 1000);
        
        Serial.print("FS20:");
        for (byte i = 0; i < len; ++i) {
            Serial.print(' ');
            Serial.print(buf[i], DEC);
        }
        Serial.println();

    }

}

Using this code the symtons are still what they where in the beginning; only when I hold the FS20 TK in less than 20 centimeter of the reciever, I get valid FS20 packages. Which really amazes me, because the type of FS20 reciever I use should be an extra sensitive one (RX868-SH-C3, chip; http://www.alldatasheet.com/view.jsp?Searchword=TH71111.2)

I've also expiremented with removing the check sum from the code, and I then do recieve packages over longer distance, but they are all crippled. Wrong house code, wrong checksum, wrong command.

So at this point I'm really amazed about this code ever working for anyone. Because to me it looks to fuzzy and to incedental, counting the time to determine the code...
15  Using Arduino / Project Guidance / Re: Wireless doorbell on: November 13, 2012, 05:29:35 pm
Could it be that the two radio devices aren't on quite the right frequency/channel or using different encoding? It's pure speculation, but perhaps the radio link would be able to work despite the mismatch if the signal was extremely strong, but not when it is at normal levels.

Okey, and where/what would you modify to get it straight?
Pages: [1] 2