Hi all,
This is my first post but I've been following this interesting project since months. I have built an emonTx, an emonGLCD and an OKG W5200 base to monitor my PV system. I have an account on emoncms for the moment: my purpose is to move to a local server (maybe a RaspberryPi) as soon as possible. Now that everything is setup, I see that the clock of the GLCD is not updated. I've put some debug string in the code in order to understand what's going on and I see the following:
- The very first transmission returns an error:
Sent: &json={rf_fail:1}
>>line_buf (78) :
Notice: Undefined index: HTTP_HOST in /var/www/emoncms/core.php on line 31
okÀ¨²à
- The OKG disconnects from the server.
- After a couple of seconds, I see the data posted:
Sent: &node=10&csv=564,429,0,23551
>>line_buf (78) :
Notice: Undefined index: HTTP_HOST in /var/www/emoncms/core.php on line 31
okÀ¨²Âi
- It then disconnect again.
- Then I see the time request to the server:
Sent time request
>>line_buf (85) :
Notice: Undefined index: HTTP_HOST in /var/www/emoncms/core.php on line 31
t14,26,03
- Then I see another disconnect.
- After 8 seconds, the OKG restarts because the watchdog timer has never been reset. The loop then starts again with the rt_fail and the following exactly as reported.
I see all the posted data on the emoncms3.
It seems to me that the Notice messages I'm getting do not let the code to switch properly into the 'ok' cases and so neither the time nor the post return are managed properly. I was thinking to "ignore" those notices, but I would prefer to solve any issue instead of setup a workaround.
Is there anybody who can help me, please?
One last stupid question: is emoncms3 free for usage? I mean, I can post all my data without anything else than the registration I've done? Is there a limit in the posted data?
Thanks for your help and consideration.
Re: Problem with emoncms multinode
Hi,
I've found the reason of the resets: in the original sketch the buffer line_buf used to store line of http reply header has been declared as 50 bytes long. The Notice response I get from the server is 85 bytes long, so I believe that the program was crashing... I defined it as 256 bytes and I do not see any reset now.
Still unclear to me why I am gettin' the message "Notice: Undefined index: HTTP_HOST in /var/www/emoncms/core.php on line 31". Then I get either the "ok" or the time, but the sketch can't recognize them!
Thanks to anyone can help.
Regards,
Alberto
Re: Problem with emoncms multinode
HTTP_HOST is generally obtained from the HTTP request header i.e. what the client used as the "target host" for the request.
are you using the domain name or the IP Address?
Re: Problem with emoncms multinode
I'm using the emoncms_multinode sketch were I've just changed mac, local ip and I've put the api key. I'm using
char server[] = "emoncms.org";
so the domain name.
Re: Problem with emoncms multinode
is emoncms3 free for usage?
Yes. But I am sure your support by purchasing hardware from the shop, or by donations, would be appreciated.
Re: Problem with emoncms multinode
Of course. I already did it and for sure I'll go on doing it as this project and this community are very valuable.
Re: Problem with emoncms multinode
Hello Alpav, Welcome and good to hear you have built the kits up. The HTTP_HOST error was my mistake (although it is strange that it somehow did not show up for me), anyway I have now fixed it, so that should make everything else work. I put some details on using emoncms.org up here: http://emoncms.org/site/usage
Re: Problem with emoncms multinode
Hello Tristan, thanks for your reply. I have put the following workaround in my code:
//char line_buf[50]; // Used to store line of http reply header
char line_buf[512];
[...]
//if (strcmp(line_buf,"ok")==0)
if (strcmp(&line_buf[pos-2],"ok")==0)
{
Serial.println("OK received");
}
else if(line_buf[pos-9]=='t')
{
int p=pos-9;
Serial.print("Time: ");
Serial.println(line_buf+p);
char tmp[] = {line_buf[p+1],line_buf[p+2],0};
byte hour = atoi(tmp);
tmp[0] = line_buf[p+4]; tmp[1] = line_buf[p+5];
byte minute = atoi(tmp);
tmp[0] = line_buf[p+7]; tmp[1] = line_buf[p+8];
byte second = atoi(tmp);
if (hour>0 || minute>0 || second>0)
{
char data[] = {'t',hour,minute,second};
int i = 0; while (!rf12_canSend() && i<10) {rf12_recvDone(); i++;}
rf12_sendStart(0, data, sizeof data);
rf12_sendWait(0);
}
}
It's been working for the last two days and it seems to be still working after your fix.
So I'll keep it, just in case :) What do you think?
Thanks for everything.