Soil Humidity - any ideas how to fix the values? #1156
Replies: 17 comments
-
Posted at 2014-03-08 by ChrisZ hansamann, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-09 by hansamann Hi Chris, many thx for your comments. Meanwhile, I added a LDR for sensing the light intesity and I worked a bit on the WiFi stability - e.g. I disconnect from CC3000 and reconnect every 60 sec. It is not perfect, but runs a few hours at some point. I uploaded my code here for everybody to see: The readSoilSync() function is doing this:
Changing the direction of in/out is mainly due to my last years experiences. I also sent a constant current through the soil last year, which I fixed in this project. Now, is your idea with resistors and capacitor still valid with this setup? I admit I've not tried it out yet, as I first would like to understand why it makes a differnce if I power it via the power supply compared to the battery. I am planning to do this tonight and before I'll try a few other 5V power supplies (from different phones). Thx! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-09 by hansamann I have a few pics online, in case this helps to figure out the project: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-09 by hansamann OK, I'm a bit lost here. It does work constantly with similar results as via the battery with a different power supply. I used a supply from a samsung phone now, connected via micro USB. So... that's good. There must be something with the other charger. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-09 by ChrisZ Sven; |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-10 by @gfwilliams It could be that the USB wall adaptor was particularly 'noisy'... I guess cheap ones are probably designed to output a lot of power (1-2A) at 5v, and when Espruino a plugged in and draws 10mA, the signal is probably pretty noisy. The other thing you could do is to call |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-10 by hansamann The power supply used was for an Asus Nexus 7 - a USB charger. I think it's supposed to supply 1A at 5V - but the power saving mode you mentioned sounds like a interesting reason for the issue. It's gone now with a Samsung charger :-) But just for fun I am also reporting the getAnalogVRef to Xively, so when I swap the charger again I would see it in the logs. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-15 by hansamann HI @gordon, might have found the issue. I was just refactoring the code a but, throwing out the useless vref value, etc. and then noticed that it was running really nicely when connected to my mac, debugging to the web ide. When I prepared the espruino for running off the usb power supply, I would typically do Now, I cannot understand why, but when I keep the debug statements (console.log) turned on, it works. It not running for hours how, but it seems to fix something. I've uploaded the latest code - I have only a few console.log in there. Could it be that one has to "consume" or touch the data variables, e.g. response data at least once so it is freeing memory or not blocking? That's happening when debugging in my code is on for example. https://gist.github.com/anonymous/9572141 If you have time, please take another look - I am now trying to understand why it works if console.log turned on :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-16 by ChrisZ Hi; |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-16 by hansamann Thx for the great comments. Especially for the tipps on how to read the soil values. Will change my code soon - right now I randomly choose a directly for each reading session and then stick with it. My main problem though is still the connectivity. Today I was lucky to reset in the morning and according to xively it was running till 14:00 - but that was real luck. It still seems to hang at some point and then I need to manually reset. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-17 by @gfwilliams Thanks - I'll try and look into the CC3000 again. Keeping the WiFi connection open actually seems to be relatively reliable now but I'll see if I can figure out why it's crashing. A quick fix might just be to enable the watchdog timer that now exists? http://www.espruino.com/Reference#l_E_enableWatchdog If you set it for something like 20 seconds it'll probably be enough to handle most cases... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-21 by hansamann Hi Gordon - I have tried the enableWatchdog method out - but it does not quite work. I also don't quite understand: a reset does not load the saved program, right?
Right now I am calling the watchdog timer in onInit with 10 seconds. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-21 by @gfwilliams The watchdog hard resets (much like hitting the RST button), which will load data from flash - I think you're looking at the docs for the What doesn't work? it should reset the device if any command takes longer than 10 secs to complete (which some of the CC3000 commands do unfortunately :( ) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-21 by hansamann Ah, ok - I guess I was confused as from the watchdog function the reset function is referenced... but nothing states it is a hard reset. Might be obvious for people used to microconrtoller watchdog functions (not me :-) I'll give it another try tomorrow. Last time it stopped after a few hours... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-22 by hansamann All right, it seems the watchdog does not really work for me. I've got the final code up here: https://gist.github.com/anonymous/9706137 I had to reset the device manually twice this morning and it just stopped again. Here is the procedure so we can rule out all other issues:
How could I get more info and data if it's connected to a power source? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-24 by @gfwilliams Hmm... Thanks - mind if I give your code a try? My guess is that somehow the intervals get removed - so Espruino is still working and responsive, but is just not doing anything. Does it not crash if it is left connected to the Mac? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-24 by hansamann Hi Gordon, feel free to take the code and massage it in any way you feel it makes sense. I can also send you the xively api key if that helps .All I connected is DHT11, LDR and the soil sensor- I think you could just mock LDR and soil sensor, simple analog reading, but the DHT11 might be interesting to really connect as it might be the reason for the issue. (e.g. it also uses a callback etc and it's a sensor that's a bit more complicated compared to the analog reading). Thx |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-03-08 by hansamann
I've done a garduino project last year, not connected to the internet, and @gordon posted in one of the forums that he created a Xively DHT11 (temp/air humidity) tutorial.
So I extended that idea with another sensor, a soil humidity sensor. It is just two pins connected to teh soil - one is put HIGH to send 5V and the other reads the analog value - between 0,1 on the espruino.
It works pretty well - unless I connect it to a 5V/1A power supply via the socket. That really means: if the espruino is connected to my battery-powered Google Pixel, or powered via a USB battery, it works very well - I read always around the same value (which is already averaged over 20 samples).
But once I connect it to the power supply - a phone charger / USB, connected to teh wall socket, it gives me crazy values - each measurement differs wildly from the last one.
I am really scratching my head what causes that? Any ideas are welcome :-)
Beta Was this translation helpful? Give feedback.
All reactions