It is based on a JY-MCU basic AVR board with ENC28J60 Ethernet interface and a 1-wire bus to provide a local web server with real time temperature readings of any number of 1-Wire thermometers. In addition, it can be configured to post the readings to COSM data feed.
This is running at my house for quite some time and is posting indoors and outdoors readings every 10 min to the following COSM feed: https://cosm.com/feeds/100389
The hardware description can be found in my other post.
To compile the project download the JY-MCU hardware profile for Arduino and the following libraries:
The code can be download from here: TempServer V0.2.ino
The server use DHCP to configure the TCP/IP stack and then start (led 7 remains on while setting up, then led 8 start to blink for normal operation).
The configuration link on the main page will bring up the COSM configuration page where you can configure the posting interval, the feed id and the COSM API key (to reset this configuration, hold switch 1 when the program starts).
In the next versions I am planning to enhance the following (not in a particular order):
- Enable to name each sensor for display in the list and for posting the date to COSM.
- Log up to 96 past readings in the device EEPROM (every 15 min for 24 hours).
- Show the min/max of the logged values.
- Show graph of the logged values.
- Use network time to make sure date logging and posting is done properly even when the device restarts frequently (currently, the posting of data is done after the device is constantly on for the selected posting time, that is, if the post of data is every 10 min, and the device restart every 7 min for some reason, no data will ever be posted).
- Improve the posting code to retry on HTTP errors (currently the code ignore the returned HTTP code and does not check for time out).
Please let me know your thoughts (especially if you willing to give it go).
Thank you for sharing.
ReplyDeleteBut I could not find the library here https://github.com/jcw/ethercard (unable to connect)
Can you upload ethernet library to else where?
Thank you.
You can find a copy of the library in https://sites.google.com/site/hagaishatz/arduino
DeleteI will appreciate if you can share your thought on the solution.
Regards.
Great project! I am wondering if you can help me get this working on Arduino with ATmega 328p chip? I'm using a ENC28J60 shield (uses pins 10 - 13, and 2).
ReplyDeleteI refreshed the 4 libraries you use with the same version to be sure I am using the same code. I also update the line:
if (ether.begin(sizeof Ethernet::buffer, mymac, 12) == 0)
to:
if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
as the "arduino shield" version of the ENC28J60 uses pin 10 for CS.
Sketch compiles and uploads fine, I get a DHCP address, and display the web page. It shows the "is it hot?" header at the top of the page, but no other content. I used serial debugging in your sketch, adding Serial.print(tempC); so I could see if it is reading my oneWire bus, and it is, I see the output from my DS18S20's each time the webpage calls. I also see in my browser (ctrl+shift+i) the reload calls.
I cant seem to figure out why it is not rendering the temps in the browser page. I tried your older version of this project (The one without EEPROM) with the same results, so I thought I'd try your new version, and am seeing the same problem. Any troubleshooting you have would be greatly appreciated!!
-Joe
Thanks for trying this out.
DeleteIf the reload calls you inspect in the browser tools are with a proper response content then the problem is probably in the javascript code.
Are there any javascript errors in the browser console?
-Hagai
Thanks for getting back to me. I am very very new to JavaScript, so I suspect you are right that there are potentially errors in my code. I am working through that code over the next week or so, and I will post my findings.
Deletethanks!
Joe
I too have the same problem.
DeleteThe browser console says this:
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
No way to edit :-(
DeleteI cant seem to find the event.returnValue in the js code, or any where in the schetc. Hagai can you help with this?
Also I see that your temp server is down, or at least not posting to Xively. Cant seem to get that to work either, but I think the tow eerors hang together
This comment has been removed by the author.
DeleteKryten, Joe,
DeleteAs Kryten noticed, my device is not running since I moved to my new house. It looks like some compatibility problem with jQuery, my JavaScript and the browser that you are using. I will try to have a look on this over the weekend.
Cheers, Hagai.
Thanks for that Hagai.
DeleteHere is the StackOverflow link again since I deleted the last post I did.
http://stackoverflow.com/questions/20045162/event-returnvalue-is-deprecated-please-use-the-standard-event-preventdefault?answertab=active#tab-top
Im kinda stupid some times :-p
From what I can see, Not that Im any good with java scripting, I think it will be enought to change the jQuery versions.
DeleteHere:
http://blog.jquery.com/2013/04/18/jquery-2-0-released/
Althou It might throw off the nice GUI you made.
There are som enice tips on migrateing to newer versions here :
https://github.com/jquery/jquery-migrate/#readme
Looks (to me) like the trick is to change the lines:
278-281 in the .ino file
(had to cut all the HTML part of the code in order to post it)
href='//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css'/>
"'//code.jquery.com/jquery-1.8.2.min.js'>
'//code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js'>
I dont have the time to look into wich versions we should use in order to fix this as Im am @ work.
This comment has been removed by the author.
DeleteSo I got home started testing my theory but no luck.
DeleteAfter checking some more in the Developer tools (in Chrome).
It looks to me that the Temp is not beeing posted to the list view. The only child I see in the list view is the updatet time.
I now think that the error is some where in the second and third script line of mainJs function.
Hope this helps you a little Hagai and I have no clue into Java scripting so I cant help. Sorry about that.
Also Im not going to be able to check anything until monday as I will be away at a cabin ( where I hope to put this in the end)
Thanks for your efforts.
DeleteCan you post a sample of the readings response you get into the browser?
Have a nice weekend.
I tested the javascript using a simulation of the actual Arduino and it works as expected using the current jQuery 1.8.2 and jQueryMobile 1.2.0 versions.
DeleteI suspect that something is not right with the list.json responses returned from the device.
They should look something like this:
{"list":[{"id":"AABBCCDD11223344","name":"Sensor 1","val":2.411},{"id":"AABBCCDD11223355","name":"Sensor 2","val":2.866}],"uptime":76391299,"free":545,"feed":""}
But I don't have the device with me at the moment to test it myself. Will try to find some time over the weekend.
I did not see any thing looking like that. ( i might not have looked in all the right plases.)
DeleteSorry for late reply, have been occupied other ways. I will check as soon as i can, bit that means Monday
I have added serial output in order to see if the OW is read at all and it is. (first thing I did when there was no temp showing).
DeleteHere is teh output from dev console
Delete{"list":[{"id":"2882ABC50200002E","name":"Sensor 1","val":T},{"id":"2836C7BC020000FE","name":"Sensor 2","val":T}],"free":258,"intr":15,"feed":"163946092","cosm":"216.52.233.120"}
It looks to like the tempC float value is not being entered in to the string. I can read out the tempC using serial output.
Thanks, indeed the temperature float value is not written to the response ("val":T).
DeleteThe issue is in the EtherCard.cpp - uncomment the following line at the top of the file:
//#define FLOATEMIT // uncomment line to enable $T in emit_P for float emitting
The code use BufferFiller::emit_p to build the response and is unable to write float values unless this is enabled in the library.
Looking forward for positive news.
There you go all perfect!
DeleteThanks for helping Hagai. I really appreciate it.
It dos not seem to hang on to the API key for xively. The last 4 characters are being transformed into wild cards as a dimond shape with a question mark inside
It looks like it got fixed by itself
DeleteWhen I try to compile I get error: 'EEPROM' was not declared in this scope.
ReplyDeleteIm on a Arduino nano using mega328 chip.
Had an issue with the way I installed the EEPROMEx lib.
DeleteThis comment has been removed by the author.
ReplyDeleteHow are you getting on with adding names to the sensors?
ReplyDeleteOne Idea is to scan the OW bus during atrstup and storing the adresses in eeprom, setting the names like setting COSM /Xively API key.
I dont have the skills (yet) to fix the EEPROM stuff to do this but i can have a go to help you out a bit