Arduino

Easy-to-use Atmel Studio project for Arduino + programming the Arduino from Python

Posted on Sep 29, 2012 in Arduino, C++, Electronics, Programming | 3 comments

In this article you will find an example project for Atmel Studio that you can use with Arduino. I have also included two Python files to easily upload the code to your board. + Arduino, pro’s and con’s There are many reasons to like the Arduino, to name a few: Many libraries available and lots of example code on the web. Uploading code to your board with one click Portability of libraries Integrated serial monitor But there are also many things that drive seasoned programmers away from the Arduino environment: The IDE has about as many features as Windows Notepad. No...

Read More

UberFridge hardware and schematics

Posted on Jan 4, 2012 in Arduino, Beer, Electronics, UberFridge | 40 comments

I have grouped all the circuits used in my UberFridge project in this article. Schematics, a board layout and pictures. A top view of the electronics in UberFridge. My fridge has an on/off button on the top, which made it very easy to reroute it via a relay. The boards at the bottom were already in the fridge. I have encased most of the electronics for UberFridge in a small casing made from an Ikea box lid, see this article. The sensor wires go through the top of the fridge to the light bulb housing in the fridge. The relays are on a separate board. All other electronics are in a plywood...

Read More

Controlling fridge and beer temperature with a predictive on/off algorithm and PID

Posted on Jan 4, 2012 in Arduino, Beer, C++, Electronics, Programming, UberFridge | 5 comments

UberFridge is capable of controlling the temperature of a fermenting beer with 0.1° C accuracy. It can also be set to keep the fridge temperature within a -0.5 to +0.5 °C range. How this is done in an energy efficient manner is explained in this article. Controlling the fridge temperature To control the fridge temperature, I use a predictive on/off algorithm. Why do I need a predictive algorithm? Because waiting on measurements doesn’t work. On/Off actuators The temperature in the fridge cbe lowered by turning on the compressor. To increase the temperature, I just turn on the light in...

Read More

Programming my Arduino over WiFi

Posted on Jan 2, 2012 in Arduino, Electronics, PHP, Programming, UberFridge | 8 comments

My Arduino is embedded in my fridge, so having to take it out every time I want to change something in the software would be very annoying. But luckily the Arduino is plugged into a router, which is running Linux. I set out to get avrdude running on the router, so that I could upload new firmware to the router and have the router reprogram the Arduino. This article gives a step-by-step guide to set this up. Compiling avrdude for DD-WRT linux Edit: You can download the files I compiled on my router here. If you add those to the bin directory on your router, you can probably save yourself the...

Read More

Storing settings between restarts in EEPROM on Arduino

Posted on Jan 2, 2012 in Arduino, C++, Programming, UberFridge | 3 comments

In my UberFridge project I have a self learning algorithm to control the fridge temperature. Two parameters to estimate heating and cooling overshoot are adjusted continuously. I don’t want the Arduino to forget what it has learned every time it is reset, so I store these settings in EEPROM. The Atmega328 has 1K of EEPROM, which is plenty to store a few settings. The EEPROM is byte addressable, so I had to write a few functions to read and write integers and floats. Keep in mind that the EEPROM has only 100.000 write/erase cycles, so do not write to it too often. I write my settings to the...

Read More

Logging sensor data into Google annotated time line graphs with Python and Arduino

Posted on Dec 31, 2011 in Arduino, C++, JavaScript, PHP, Programming, Python | 1 comment

Annotated time line graphs from the Google Visualization API are a very nice way to display sensor data. With the gviz_api library for python the sensor data can be stored into JSON files that can be read by the Google Visualization API in JavaScript. Here I will explain the steps from Arduino to JavaScript. Arduino Code The first step is getting the sensor data from Arduino to Python. I have described setting up the serial communication between Arduino and Python here. The Arduino sends the sensor data as comma separated values, which can be read by a CSV reader in Python. As separator, I...

Read More

Communicating between Python and PHP/JavaScript with AF_UNIX sockets

Posted on Dec 31, 2011 in Arduino, Electronics, JavaScript, PHP, Programming, Python, UberFridge | 2 comments

I wanted a better and more direct way to communicate between PHP and Python than through files. Socket communication was the answer and this article explains how to set it up! My router runs a Python script that monitors my fermentation fridge. Only the python script communicates with the Arduino, so all commands and data requests to the Arduino go through this script. To keep loading times low for the web interface, I needed a fast and direct way to communicate between PHP and Python. Python and PHP run on the same router, so a straight forward way to communicate is through the file system....

Read More

Controlling an OLED character display with Arduino

Posted on Dec 29, 2011 in Arduino, C++, Electronics, Programming, UberFridge | 8 comments

For my UberFridge project I ordered a 4×20 OLED character display from Newhaven, the NHD-0420DZW-AY5-ND. It is a great display: it is much brighter and much better readable then a normal LCD. At only 25 dollars, it was an easy choice. The display was supposed to be HD44780 compatible, but it took me ages to get it to initialize properly. The folks at Newhaven couldn’t even figure out what the correct 4-bit initialization sequence had to be for Arduino. Finally I found a sequence that worked and modified the Arduino LiquidCrystal library to work with the OLED display. I also added...

Read More

Communicating between Python and Arduino with pyserial

Posted on Dec 28, 2011 in Arduino, C++, Electronics, Programming, Python, UberFridge | 4 comments

In my UberFridge project, my router runs a python script that periodically requests new sensor data from the Arduino. The script logs this data in files for the web server running on the router. All other communication with Arduino (getting the OLED’s content, reading/changing settings) also goes via the python script. The Arduino is programmed as a slave that responds to requests from python. With the pyserial library for python, setting this up is fairly easy. Python code My Arduino connects to the router via a USB hub. The router mounts the Arduino as /dev/usb/tts/0. See this article on...

Read More

Eleminating noise from sensor readings on Arduino with digital filtering

Posted on Dec 24, 2011 in Arduino, C++, Electronics, Programming, UberFridge | 8 comments

I use two LM35 temperature sensors to measure beer and fridge temperature in my UberFridge project. These sensors output 10 mV/°C, so for my fridge the output ranges between 40 and 300 mV. I wanted to be able to measure differences of 0.1 °C, so 1 mV. That is a very small voltage difference to measure in the presence of noise, so I implemented multiple filters to get rid of noise and increase accuracy. The sensor circuit I have connected the output of the sensors directly to the A/D converter of the Atmega328. The A/D converter is a capacitive load, which the sensors do not like, so I...

Read More