Espruino Garduino v2

Posted on
  • Garduino is originally an Arduino beginner's project where you use a simple soil sensor to turn on a water pump to water your plants. It sounds trivial, but I had all kind of strange issues last year with this - and playing with water in your living rooms is also something I'd not recommend.

    This year I decided to focus on sensor data - right now I transmit air temperature, air humidity (DHT11), soil humidity and a light reading to Xively, where everything gets added to nice charts.

    The feeds are online here - if CC3000 has not crashed it should show some data, too :-)

    https://xively.com/feeds/1848857974

  • I agree it's not trivial project. I used to try many solutions based on water sensors, pumps, etc. It is difficult for many reasons: quality sensors, water distribution systems (especially challanging when you have 30+ plants scattered all over the house), individual requiremets for water of each plants.

    Finally I gave up and bought electronic-less solution:
    http://www.blumat.at/en/watering-system-­for-house-plants.html

    It has been working for over 5 years supplying water for over 30 plants.

  • Thx for the link. If it was not about having fun with electronics, I'd do the same. And still might once the vacation time comes closer and I need a really reliable solution.

  • Yes, I had the same dilema: have a fun with electronics OR have really reliable solution for plants. My wife made me choose the 2nd option just before vacation time:)
    Plants are really chalanging;)

  • Great! Well, it still seems to be working at the moment! Although it looks like you may have had to restart it? :)

    I did some more work on CC3000, so you might find that the latest version is a bit more reliable as well. It'll only remove the single interval when there is an error - so if you do the following then it should always keep working:

    setInterval( function() {
      setTimeout(function() {
       // set up WiFi and send reading here
      }, 10);
    }, 60000);
    
  • trying this out as I write pretty much. One maybe silly question: I added vref to the data as I thought it might show me the battery level. nonsense, right? but what is the correct way to figure out the charge level of a battery - and kick of a trigger once the level is too low?

  • Ups, trying this on my mac - it does not upload correctly:
    This is what I see:

    Connected
    yyyyyyyyyyyyyyyyyyyyConnected
    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

  • See the other post you made about the problem - it'll be fixed now, you just have to update the firmware again.

    Reading vref works fine if you've removed the voltage regulator, but normally it'll just return 3.3v (ish) unless your battery gets really low.

    Best idea is to take 2x 1M Ohm resistors and connect them in series across the battery to create a potential divider. Then, just connect the middle to one of the analog inputs and the value you get will be 1/2 the battery voltage. If your battery is >6.6v you'll need to change the resistor values accordingly though :)

  • ok, thx. was able to flash the firmware, connected now on my Pixel. Mac strangely does not want to connect.

    I've update the code, but now I get this:

    Running onInit()...
    Connected.
    {"temperature":24,"air_humidity":34,"soi­l_humidity":44,"light":70,"vref":3.29211­3194909577877922}
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":47,"light":70,"vref":3.29211­3194909577877922}
    INTERNAL ERROR: Timeout on SPI RX
    Looks like CC3000 has died again. Power cycling...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":48,"light":70,"vref":3.29211­3194909577877922}
    INTERNAL ERROR: Timeout on SPI RX
    Looks like CC3000 has died again. Power cycling...
    Timed out, disconnecting...
    Timed out, disconnecting...
    Timed out, disconnecting...

    Does that help?

  • Just for reference, here is the full code. I wrapped the connect in a setTimeout.
    https://gist.github.com/hansamann/949082­5

  • ok, have to correct myself. for above code snipped I set the interval to 20 sec, but the fail timeout was still at 30 seconds. I changed that to a put reqwuest every 30 secs and fail timeout to 20 secs.

    It makes sense I guess and works nicely now:

    save()
    =undefined
    Erasing Flash.....................
    Programming 36000 Bytes...................................­....
    Checking...
    Done!
    Running onInit()...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":45,"light":64,"vref":3.28990­9638554216808614}
    -->
    INTERNAL ERROR: Timeout on SPI RX
    Looks like CC3000 has died again. Power cycling...
    ==> Closed.
    Timed out, disconnecting...
    ERROR: Unknown Timeout
    Complete, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":25,"light":64,"vref":3.28990­9638554216808614}
    soil_humidity value set to average, was: 25
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":25,"light":64,"vref":3.29211­3194909577877922}
    soil_humidity value set to average, was: 25
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":48,"light":63,"vref":3.29211­3194909577877922}
    INTERNAL ERROR: Timeout on SPI RX
    Looks like CC3000 has died again. Power cycling...
    Timed out, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":53,"light":63,"vref":3.29211­3194909577877922}
    INTERNAL ERROR: Timeout on SPI RX
    Looks like CC3000 has died again. Power cycling...
    Timed out, disconnecting...
    Connected.
    {"temperature":21,"air_humidity":34,"soi­l_humidity":67,"light":64,"vref":3.29211­3194909577877922}
    soil_humidity value set to average, was: 67
    -->
    ==> Closed.
    Complete, disconnecting...

    It still runs into a cc3000 issue quite often, but it keeps running :-) Will put the sensors back and will let it run over night.

  • I'll look into it. I've just tried it here and it does seem to come up with SPI RX timeouts much more often now.

    My guess is that the recent changes to the SysTick IRQ handler just pushed it over the edge, and now SPI is more likely to lose characters.

  • Copy this into the Web IDE flasher's URL box and give it a try: http://www.espruino.com/binaries/git/com­mits/cb1101a1855f3b37bdeb2b7a91af12d4aa4­5dc99/espruino_1v57_espruino_1r3.bin

    I tweaked the IRQ priorities and at least for me, it's a mile better now.

  • First thought it is way, better, and I think it is, but after waiting after the 4/5th request, I got this:

    Running onInit()...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":99,"light":2,"vref":3.292113­194909577877922}
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":100,"light":2,"vref":3.28990­9638554216808614}
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":100,"light":3,"vref":3.28990­9638554216808614}
    light value set to average, was: 3
    -->
    ==> Closed.
    Complete, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":100,"light":3,"vref":3.28770­9030100334661739}
    light value set to average, was: 3
    Timed out, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":100,"light":3,"vref":3.28990­9638554216808614}
    light value set to average, was: 3
    Timed out, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":99,"light":2,"vref":3.289909­638554216808614}
    Timed out, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":100,"light":2,"vref":3.29211­3194909577877922}
    ERROR: Unable to locate host
    Timed out, disconnecting...
    Connected.
    {"temperature":22,"air_humidity":35,"soi­l_humidity":99,"light":2,"vref":3.289909­638554216808614}
    -->
    ==> Closed.
    Complete, disconnecting...

    I am leaving this up for the night, conecting it to a power supply and will monitor it.

    Thx!

  • You probably have quite a bad WiFi signal strength? Mine is very temperamental when that happens.

    At the end of the day, I can't stop the CC3000 from crashing. That's TI's problem.

    All I can do is try and make Espruino detect the crash, deal with it and restart it - which hopefully it'll be better at now. It still might not be perfect but hopefully it's getting nearer now.

    I wonder if someone might be able to add a firmware updater to Espruino. At least then it might be possible to update the CC3000 itself with slightly less broken software.

  • Hi Gordon, thx a lot. I had it running with a 30sec/20sec timout over night, which was not running through - but I'll experiment with the durations a bit.

    the signal strength shoudl be very good - it's not next to the wifi router directly, but 5 meters from it. At least my laptopn or mobile devices show full strength.

    The cc3000 seems to have a lot of issues. I am active in the Spark Core forums, too, and they were lucky to have TI work on a better CC3000 firmware. According to them, some improvments were made and more are to come. They have the possibility to flash that as part of a normal update process.

    That idea with a complete reset if nothign happened a few seconds - is that realistic?

  • I don't see there's any way around doing a reset. I've had zero response from TI about the issues, even on their own forums. I was talking to the guy who designed the CC3000 shield from Adafruit, and he's had similar problems. It's a disgrace really - I'll be avoiding TI's stuff like the plague in the future.

    I left the WiFi humidity sensor (http://www.espruino.com/wifi_humidity) running overnight and it is still going and reporting back data, and has been for 14 hours straight (although it looks like there's something iffy with the DHT11 module now!).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Espruino Garduino v2

Posted by Avatar for hansamann @hansamann

Actions