WiFridge : the software

Arduino’s code

It can be found here on github. I won’t post it here. I hope comment in the code are sufficient to understand what I did. I will just describe main principles here.

Reading sensors

I used those libraries :

  • For 1-Wire, PJRC library which can be found here.
  • For DHT temp & humidity sensor, Adafruit library which can be found here.

WiFly

The goal is to send sensors data to an emoncms web site so that it can be historized and graphed. For that matter I built 2 web emoncms websites :

  • one on the internet on a shared hosting
  • one on a small and cheap Raspberry Pi

I know of 2 libraries for this WiFly module :

  • the one based on sparkun Sparkfun WiFly shield which can be found here
  • another one called WiflyHQ which can be found here

I first tried Sparkun lib but I could not get a stable web connection. It would eventually failed to connect to the destination web server after a random period of time. So I had a try for WiflyHQ. In the end, I still have stability problems but I find it easier to use as it kind of replicates all RN-XV functions whereas Sparkfun one tends to “hide” the bits and bytes but making it a bit more cryptic to me.

Also, samples in WiflyHQ makes use of a software serial port by default  whereas Wireless shield is using the hardware serial from the Arduino which is getting complex as you can’t really use the serial port for debugging without a risk of disturbing the Wifly module (see Hardware post here.)

Because of WiFly connection instability (it may be my code though wich is not… optimal…), I tried to use watchdog library to reboot both wifly and arduino in case something went wrong by entering an infinite loop which will eventually restart the arduino.. Not that efficient though… I still have some case where everything is stuck, not sending any data, but not rebooting… Or the wifly wont just properly reboot.

So I used the leds the try to grab some diagnostics information… but it does not really helped. It seems that the wifly will not get out of command mode from time to time. No idea why…

What’s next

Because of this instability, I want to try the quite new CC3000 wifi shield from Adafruit ! Just received it. I will migrate my code to work with that promising shield 🙂

 

 

7 thoughts on “WiFridge : the software

  1. I’m having trouble with the wifly module logging “Wifly has crashed and will reboot” but it never does. Can it be rebooted in code?

      • Yes I added that line into the WiflyHQ.cpp right after the log for wifly module crashed and must be rebooted. I still get crashes every now and then from which the module doesnt recover. I added a debug line in the wifly::reboot() function and it does get called but does not reboot the module. Is there another method I could call to force the reboot? BTW, what does for(;;); do?

        • Hello again,

          Unfortunately, I don’t know any other way.

          I finally stopped using the Wifly because of its unstability. I tried the CC3000 shield from Adafruit and found it much more stable (see http://interactingobjects.com/new-wifridge-based-on-adafruit-cc3000-wifi-shield/) Or at least, rebooting the Arduino when it get stuck somewhere works with the cc3000. Not the Wifly 🙁

          The for(;;) statement is creating an infinite loop which eventually reboot the arduino. You’ll see here that I am using the watchdog library. In setup(), I enable the watchdog timer setting the watchdog timeout to 8 secs, and then, at each loop resetting the watchog timer. If the watchdog does not get reset within 8 secs, the chip reboots. That’s the goal of the for(;;). I was hoping rebooting the Wifly + rebooting the Arduino would work… but it did not.

          The only way of getting out of a crashed Wifly was power cycle 🙁

          Sorry I can’t help more.
          JS

          • Ok thanks, I guess Ill have to migrate the project to cc3000. Just out of curiosity, did you try upgrading firmware? How do I determine what firmware my module is on?

            What about a different library? Im using WiflyHQ, but Ive seen WiflySerial and Wifly.

            BTW, I dont seem to get email alerts to these replies.

          • Hello Mars,

            I think I did an upgrade. It was a bit tricky though. You need to connect to the WiFly thru serial port. You can do this using console emulator like TeraTerm or PuTTY. You’ll find all information here.

            To see the firmware version, connect to the wifly using serial port also, enter command mode using $$$ and then type ver+enter. That should give you the version. If you’re using it with an arduino, you may get it thru a sketch.

            About libraries, I used Sparkfun’s one at first. But I found WiflyHQ easier and a bit more stable at the time. Also, I like the idea of not using the hardware serial port of the Arduino but rather 2 other pins with softSerial library. It makes life easier !

            Anyway, I tend to think it’s really the WiFly which is causing problems, not the libs. So I just gave up.

            But, I must say that there is hardware now that may (or may not…) be better :

            • cc3000 (you can find some shield or breakout at sparkfun or adafruit)
            • DFRobot WiDo : is is a nice low cost arduino leonardo fitted with a Wifi chip which is working with Adafruit’s CC3000 library. The drawback is that leonardo boot loader is bigger than arduino uno’s one leaving not that much space for your program. I wrote a little article about it here
            • ESP8266 chip which is very low cost. Never tried it but seems promising
            • WeIO which I am currently working on. It a young platform but very promising. More like a Beaglebone or a Raspberry Pi than an arduino though

            So, I don’t know what your project is, but you may want to have a look at those.

            Hope this helps.
            JS

            PS : I did add a new plugin to my blog so that you should be able to subscribe to replies now !

  2. Ok, well Im trying some things out because what happens in my case is that the fast blinking red led indicates it is not associated after a while. So Im trying to see if I can code my way into re-associating when that happens and if not, Ill go for some sort of reset either with wdt or asm.

    Thanks.

Leave a Reply to Mars Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.