C++

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

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

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

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