Solving ethercard issues, plus daylight saving correction.

I've been fighting with the ethercard library on and off for a couple of months, trying to improve its reliability when being used as a client to post a json string to emoncms.  Although I made some improvements, it still was not good enough for me. Issues were mainly as a result of not being able to handle out of sequence packets.  (I appreciate that some people don't have an issue.  I think they are the lucky ones. The internet being what it is, there is no control over the devices that a packet will traverse.  Changing router and server both changed the problems I was having, but neither removed them.)
 
What I realised last week was that I could achieve my result in another way.  What I am doing now is serving a http page from the emonbase, which simply contains the json string. This is being read using a small linux system I have running my weather station (O2 Joggler), which immediately posts it to emoncms hosted remotely.  The result is near perfect operation so far, far exceeding my expectations and what I was getting by using the client on emonbase. I do have the watchdog enabled, and I also reset the emonbase if I don't see 10 http requests when I expect to.  So far, I'm not seeing any resets.
 
The only issue I then had was how to set the clock on the emonglcd.  This I solved by occasionally (once an hour or so) fetching the time from an ntp server.  This also works perfectly (except when my router throws the occasional wobbly!).  I have updated emonglcd so that it takes a lot longer before whinging about no rf being received from the emonbase.
 
A second flash of inspiration solved daylight saving for me, which had always been a bit of cludge. I now have one of the switches on the display which simply toggles between GMT and BST.

I want to make a couple more changes to my sketch so that an ntp failure is not catastrophic (at the moment it waits for the ntp response before proceeding, and this is not ideal), and then I'll post my code.

Lloyd

Lloyd's picture

Re: Solving ethercard issues, plus daylight saving correction.

I've now sorted things out so that ntp failure is ignore, and is retried after a short period of time.  I've also added dns lookup for a list of 5 different servers that it uses in a round robin fashion.  Finally happy with my solution , and will leave it alone to check its reliabilty.

Lloyd

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.