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 🙂

 

 

WiFridge : hardware details

In this post, I will give the details of the WiFridge hardware : how to connect the probes to the Arduino. It follows the post here.

The hardware

Here is the bill of material :

  • 1 AM2302 Humidity & temperature sensor
  • 2 DS12B20 1-wire waterproof temperature sensor
  • 3 3mm LEDs (green, yellow, red)
  • 3 1kΩ resistor
  • 1 10kΩ resistor
  • 1 4.7Ω resistor
  • 1 Arduino Wireless shield
  • 1 RN-XV Wifly module
  • some solderless breadboard
  • a bunch of wires

Fritzing Wifridge

It is connected as describe on the previous figure (created mostly with Fritzing.)

  • AM2302 : data connected on digital input 3 for kitchen temperature and humidity connected to a 10kΩ pull-up resistor
  • both DS18B20 : data on digital input 2 for fridge and freezer temperature, connected to a 4.7Ω pull-up resistor
  • status leds on digital inputs 6, 9 and 10 (optionnal though, just here for displaying status when operating) through 1kΩ resistors.

The 3 sensors are also connected to ground and +5V through their corresponding wire.

WiFridge Front Final with notes

Also, to simplify debugging, I decided to connect WiFly UART to a software serial port on the Arduino so that the hardware serial is free for programming and debugging. I simply cut off the Rx and Tx legs on the shield and reconnected them to digital pin 7 & 8. But it is possible to only bend the legs so you can revert the process.

Wifridge Rx Tx cutoff 640x487

 That’s it for the hardware. In a coming post, I will describe the software part.