Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Programming Questions / Re: how to snprintf to serial with String object type ? on: September 18, 2011, 01:42:41 pm
Thanks dannym.

I've replaced the snprintf line code with the following (as you suggested):
char sensor[5];
sensorTable.sensorName.toCharArray(sensor, 5);
snprintf(msgTmp,sizeof msgTmp, "  sensorname= %s",sensor);

And it worked like a charm.

And why I use the String class instead of char[]: for the easy use and standard includes functions.

Thanks a lot,
Jeroen
2  Using Arduino / Programming Questions / how to snprintf to serial with String object type ? on: September 18, 2011, 01:05:44 pm
Hello,

I would like to run the following simple code to simulate my problem:

typedef struct                 
  {
          String sensorName;         
          byte pin;
          byte state;
  }             
sensorData;

// sensors on this node  {sensorname,pinnr,begin_state}
sensorData sensorTable[6] =
{
     {"POG04",1,0},
     {"POG14",1,0},
     {"ROG04",1,0},
     {"ROG14",1,0},       
     {"LOG04",1,0},
     {"TOG04",1,0}
};
 
  void setup()
  {   Serial.begin(57600);};
int debug =1;
// function to write data to Log
void writeLog(char* msg)
{
    if (debug == 1) {Serial.println(msg);}  //else sometimes no nextline is given
}

void loop()
{
    char msgTmp(100);
        for (int i = 0; i < 6 ; i++)
        { 
               sensorTable.sensorName ;   
               Serial.println(sensorTable.sensorName) ;
               if (sensorTable.sensorName.charAt(0) == 'T')    // movement only for PIR sensors
               {
                     snprintf(msgTmp,sizeof msgTmp, "  sensorname= %s",sensorTable.sensorName);
                     writeLog(msgTmp);
               }
        }
        delay(1000);
}

When I comment  the snprintf, it works.
When I compile the code with the snprintf command not commented out,
I get the following error:
invalid conversion from 'char' to 'char*'
sketch_sep18b:38: error: initializing argument 1 of 'int snprintf(char*, size_t, const char*, ...)'

Does anyone know how to SNPRINTF a STRING object ?

Thanks a lot,
Jeroen.
3  Using Arduino / Programming Questions / help with TimeAlarm library on: September 16, 2011, 11:27:47 am
Hello,

I would like to set an output high and then, after 30 min set it low.

Therefore, I can simply use a timer (<TimeAlarms.h> lib):

set pix x high for sensor Y
AlarmOnce(900,timerswitch)

Now, when the function timerswitch is executed, I need the sensorname (via an array I get the pin) which must be set LOW

SO :
- it is not possible to give a parameter through a function in an alarm mode (fe AlarmOnce(900,timerswitch(sensorY))

The other option is to save the alarmID and sensorname in an array
This way I always now which alarm is active for which sensor.

But when the function timerswitch() is executed after 30 minutes by the alarm, I need to know the alarmID to know the sensorname to put this pin LOW.

Any idea how to get the alarmID in the function executed by the alarm (and yes, I will have many alarms and sensors)

Thanks in advance,
Jeroen
4  Using Arduino / Programming Questions / Re: how to declare an array of structures ? on: September 14, 2011, 03:22:35 pm
Hello johnwasser,

indeed, your code works,

Thanks
5  Using Arduino / Programming Questions / how to declare an array of structures ? on: September 14, 2011, 02:54:34 pm
Hello, I would like to declare an array of structure data:
code:

#define pir0Sensor     0
#define pir1Sensor     1
#define relais0Sensor  2
#define relais1Sensor  3
#define LDR0Sensor     4
#define temperature0Sensor 5
#define amountSensorsInSensorTable 6

typedef struct                 
{
        String sensorName;         
        byte pin;
        byte state;
}             
sensorData;   

// sensors on this node
sensorData sensorTable[amountSensorsInSensorTable];
sensorTable[pir0Sensor] =(sensorData){"POG04",pir0Pin,0};
sensorTable[pir1Sensor] =(sensorData) {"POG14",pir1Pin,0};
sensorTable[relais0Sensor]= (sensorData) {"ROG04",relais0Pin,0};
sensorTable[relais1Sensor]  = (sensorData) {"ROG14",relais1Pin,0};
sensorTable[LDR0Sensor] = (sensorData) {"DOG04",LDR0Pin,0};
sensorTable[temperature0Sensor] = (sensorData) {"TOG04",temperature0Pin,0};And I'm getting the error:
sketch_sep14b:18: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep14b:19: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep14b:20: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep14b:21: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep14b:22: error: expected constructor, destructor, or type conversion before '=' token
sketch_sep14b:23: error: expected constructor, destructor, or type conversion before '=' token

I don't see what I'm doing wrong.
Anyone an idea ?

Thanks,
Jeroen.
6  Using Arduino / Programming Questions / Re: send string via RF on: September 08, 2011, 03:18:14 am
Sorry for the mistake, I can't copy my real code at this moment.
Indeed, the declarations should be 'String' with a capital.
So I use the String constructor (not called a string datatype):

datatype struct       
{
   String sensor;         
             int value1;
              int value2;
          long value3;
}        Payload;       
Payload payload;

String sensorTMP1="TOG04";



The send command = rf12_sendStart(0,&payload,sizeof payload,2);

Thanks,
Jeroen.
7  Using Arduino / Programming Questions / send string via RF on: September 08, 2011, 02:49:00 am
Hello,

As from Arduino IDE 0022, we can use standard strings.

For sending via RFM12, I've defined the following 'payload structure':
datatype struct       
{
   string sensor;          
             int value1;
   int value2;
   long value3;
}        Payload;      
Payload payload;

string sensorTMP1={"TOG04"};

I set the payload.sensor=sensorTMP1

When I want to send the payload, the send command hangs on the rf12_sendStart(0,&payload,sizeof payload,2); (using the jeenode RFM12 library).
I assume it has something to do with the string datatype in the payload structure, because when I send only int, float or chars it works.

Is there a simple way to solve this and still has the advantage using a string datatype ?

Thanks in advance,
Jeroen.
8  Using Arduino / Networking, Protocols, and Devices / Re: heat-power consumption ethernet shield wiznet 5100 chip on: August 10, 2011, 04:51:15 am
Hello,

It's definitaly the W5100 chip that becomes extremely hot and uses a lot of power (I will try to measure this tonight, but I think around 4 W)
The regulator has no problem. (it is a 5 V) and does not become extremely hot.

Is it realy necessary to stop the power to this chip, can't I just disable the chip via CS/SS pin (bring pin 10 HIGH) ?

Thanks,
Jeroen
9  Using Arduino / Networking, Protocols, and Devices / heat-power consumption ethernet shield wiznet 5100 chip on: August 09, 2011, 12:33:08 pm
Hello,

I've a 24*24 7*7 power monitorring / PID thermostat based on arduino mega 2560 with an ethernet sield v2.
The ethernet connection is used for system status page and to transfert once a day all the logged data from SD to PC.

 As you can read in a lot of topics, this chip becomes hot, and the side-effect: consumes also a lot of power.

Has anyone a trick to let this chip consumes less power ?

The only thing I can think of is to 'suspend' the ethernet during night.

Any advice is handy,
thanks,
Jeroen.
10  Using Arduino / General Electronics / correct way to send signal to an external watchdogtimer IC on: July 29, 2011, 07:35:10 am
Hello,


As I can't get my internal WDT timer to work (on a Mega 2560, tried it the last year :-(
, I've connected a external WDT (tps3823).

So, what i like to know is how to forsee from an arduino a signal (0 to 1 or 1 to 0) every 100 msec to this WDT.
I've tried an alarm already (to pit a digital output L and H every x time), but this is not fast enought in my havy (as you can read in the explantation at the end of this topic) main program.

So can anyone share with me how he would connect the arduino to the wdt (so the arduino will forsee a continous signal when its working) and stops this continue signal when he crashes ?

For your information, this is my hardware implementatie:

I've run the last half year the following configuration:

Base station:
- Arduino mega2560 official arduino shield
- official SD card and ethernet shield
- LCD monitor (2x16 chars)
- RFM12 tranceiver
- DS1820 temperature sensor
--> master that logs the power / temperature from the slave(s) and also acts as a PID temperature regulator (for controlling the heaters). It acts also as a webserver:
- when request on client windows, it can send over the .csv logged file to the pc or delete it on the SD
- when rquest , it can send to the client pc a status page of the base station
- sets the time (via ntp)

Slave: jeenode with CT sensor (for power), based on openenergy 3.0 software + DSB1820 temperature sensor

On my pc, I use the emoncms database. Every day a task gets the csv file (from base station over ethernet), convert it to emoncms rows and insert the new entries in emoncms. I also have written some graphs in JPgraph to follow my energy use.

My experience with several devices on the same SPI bus:
when accessing the ethernet device (fe. send over a 30 MB csv file to the client pc), the mega hangs when receiving on the same time a RF pakkage. (it rarely happen, once a month), but is annoying. As it is a Mega2560, the internal WDT won't work and there are no alternative bootloaders yet available.

Best regards,
Jeroen.

11  Using Arduino / Microcontrollers / Re: exteral watchdog timer ic for mega2560 on: April 13, 2011, 12:05:37 pm
Westfw,

I only want to use the WDT and my sketch is around 205 kbyte (larger than the 128kb)

Whats now the conclusion ?

Please advice,
Jeroen
12  Using Arduino / Microcontrollers / Re: exteral watchdog timer ic for mega2560 on: April 12, 2011, 05:07:46 pm
Thanks all for the response.

I will give the reflash bootloader another try as Coding Badly suggested.

Does anyone know where to find a good bootloader for the mega2560 (fe from adafruit) ?
But I need the full hardware memory capacity (as it is a large sketch with a lot of variables)

Thanks in advance,
Jeroen
13  Using Arduino / Microcontrollers / Re: exteral watchdog timer ic for mega2560 on: April 11, 2011, 01:46:58 pm
Yes, I have another one, but just for the power consumption and the space, I would like to use a small chip.
But this could be also an option.

Jeroen
14  Using Arduino / Microcontrollers / exteral watchdog timer ic for mega2560 on: April 11, 2011, 12:37:17 pm
Hello,

I have build a home automation arduino circuit with ethernet, SD logger, whireless RF12 transmissions over nodes, LCD display. So my master arduino is mission critical and crashes ones in a month. (always when requesting tcpip packages)

as I can't get the internal wdt for atmega2560 (on standard mega board) to work (due to restrictions of the bootloader)
and I cant flash the bootloader (I did not find a very good explanation).

So my only option is to use an external watchdog timer ic.
Has anyone got experience with it ?

Thanks in advance,
Jeroen.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: mega2560 and rf12.h on: October 15, 2010, 07:46:40 am
sorry for the lack of information

OS: windows 7
arduino-0021 libs.
RF12.h comes from http://code.jeelabs.org/libraries/RF12/

and fe. the example program pingPong. (but it is the same with all programs)

It compiles if you select as board the duemi.. with 328 chip, but it gives  errors when you select mega2560 board.


Thanks,
Jeroen
Pages: [1] 2 3 ... 5