Learning/Studying Heatermeter Code


 
I find the only way I learn things is to have a practical learning opportunity.

Thanks Steve_M, a "practical learning opportunity" is the very reason I began studying the Heatermeter code. I thought it would be an opportunity to learn a project top to bottom: from software, to electron flow, to tasty dinner. I thought it was an opportunity to see some C/C++ code work it's way through a circuit board.

It still might be that opportunity, but I can't seem to pull out the Linkmeter code. It's on my computer somewhere. I can compile it: cd ~/openwrt and "make package/linkmeter/compile" works without error. So the code is there somewhere...

I'm hoping that ~/heatermeter/openwrt/packages/linkmeter/src will be the pay dirt. But at first glance the files there seem to be little more than avrdude and bcm2835 rpi GPIO library.
 
The majority of the system that runs on the Pi is written in LUA scripting so it will run on "any" platform without modification. That is any platform that the LuCI host code runs on. The hmdude source doesn't need to be compiled unless you need to flash a blank ATmega chip.

You could spend a dozen hours trying to compile and debug and make things work on x86 and still not be sure if they are working the same as they are on a Pi. Or you could buy a Raspberry Pi and an SD card for *at most* $45 and use that. I know the latter involves shelling out cash, but what is your time worth and what advantage does running on x86 give you at the end?
 
You could spend a dozen hours trying to compile and debug and make things work on x86 and still not be sure if they are working the same as they are on a Pi. Or you could buy a Raspberry Pi and an SD card for *at most* $45 and use that. I know the latter involves shelling out cash, but what is your time worth and what advantage does running on x86 give you at the end?

That's why I was asking if someone knew of a "headache free" way of virtualizing! For this reason I've already given up and just took my rpi from another project. (I virtualized a brewpi to replace the pi there ;))

I can think of a few advantages but they certainly don't apply to many users.
For instance, if your running multiple cookers for some event each cooker might get its own atmega but they could all be controlled from just a single machine virtualizing (if necessary) a UI for each cooker.

Do you foresee any long term issues of making the project dependant on specific platforms?

[Edit] Thought about it for or a minute and took a gander at the serial protocol you implemented... If someone really wanted to they could write a UI for whatever platform they wanted pretty easily. I suppose that's what DavidNP has already figured out.
 
Last edited:
The majority of the system that runs on the Pi is written in LUA scripting so it will run on "any" platform without modification. That is any platform that the LuCI host code runs on. The hmdude source doesn't need to be compiled unless you need to flash a blank ATmega chip.

You could spend a dozen hours trying to compile and debug and make things work on x86 and still not be sure if they are working the same as they are on a Pi. Or you could buy a Raspberry Pi and an SD card for *at most* $45 and use that. I know the latter involves shelling out cash, but what is your time worth and what advantage does running on x86 give you at the end?

Thanks CapnBry! Ah... the dangers of mixing thread topics. We have two issues floating through this thread: studying/learning the project's code; and also, replacing the rpi. I'm afraid that I indulged the 86ing of the rpi conversation and should have politely asked folks to begin another thread.

I'm most interested in the code that runs the PID, (reads and writes to the probes/fan/servo). I'm guessing from your comment above that this code is largely LUA scripts -- perhaps found in the heatermeter/openwrt/package/linkmeter/* directories? I picture hmdude as a conduit taking code stored on the rpi and loading it into the ATmega chip -- similar to the way avrdude loads sketches in the Arduino world. Am I on the right track?

Thanks for all your great work. Love my Heatermeter! I measure the temperature of practically everything I cook now. Morning coffee included.
 
Thanks CapnBry! Ah... the dangers of mixing thread topics. We have two issues floating through this thread: studying/learning the project's code; and also, replacing the rpi. I'm afraid that I indulged the 86ing of the rpi conversation and should have politely asked folks to begin another thread.
Sorry

I'm most interested in the code that runs the PID, (reads and writes to the probes/fan/servo). I'm guessing from your comment above that this code is largely LUA scripts -- perhaps found in the heatermeter/openwrt/package/linkmeter/* directories?

You'll find all that magic in the arduino code, more specifically grillpid.cpp here: https://github.com/CapnBry/HeaterMeter/blob/master/arduino/heatermeter/grillpid.cpp

The arduino, or rather the avr powered heatermeter board, is "self contained" (someone correct me if that's the wrong terminology). All of the logic used to operate your cooker is within the avr code or the HeaterMeter/arduino/ directory. It calcs it's own fan outputs, translates analog thermistor readings to temperatures, etc.

The LUA scripts that Bryan was referring to earlier is all the code for the user interface, or how the user interacts with the controller. It is simply the middle man to send data (configuration changes) from the user to the avr and display data (pretty graph) to the user in a meaningful way.

From the readme:
Code:
+-----+ +-----+ +------+
|Probe| |Probe| |Blower|
+-----+ +-----+ +------+
     |       |        |    2.5mm jacks
A +-------------+     |
V | HeaterMeter |-----/    (arduino/heatermeter)
R +-------------+
========|===============   Serial UART
  +-----------------+
O |   +-----------+ |
p | L | linkmeter | |      (openwrt/package/linkmeter)
e | u +-----------+ |
n | C      |        |      /var/run/linkmeter.sock
W | I  +-------+    |
r | d  | httpd |    |
t |    +-------+    |
  +-----------------+

The top AVR (heatermeter board) half doesn't need the bottom openwrt (raspberry pi) half to run your cooker, but the bottom openwrt half is very nice to have.
 
Last edited:
Thank you! Funny thing... I started my search at HeaterMeater/HeaterMeter-master/arduino/heatermeter/* and got hung up on the first files I opened: heatermeter.ino, heatermeter.sln, heatermeter.vcxproj, and heatermeter.vcxproj.filters. These didn't look like anything that could run on a AVR!

The *.ino file is the main file for the Arduino IDE, the other 3 I believe are for opening the code in MS Visual Studio instead. If you open the heatermeter.ino file with an Arduino IDE you'll find it will load all the c++ source files for the HeaterMeter AVR. Then you can just click through the tabs and browse the code. You can make tweaks and compile/upload from their too. But to compile you'll need copy the folders inside HeaterMeter/arduino/libraries/ into your Arduino IDE's libraries folder.
 

 

Back
Top