using old HM board for arduino projects?


 

Steve_M

TVWBB Guru
My v4.0 HM board got trashed a while back, but the connection to the atmega looks to be ok.

I've got a project where I want to explore using the all of the analog inputs on the atmega328 and log the data over the serial connection to a RasPi, which is already wired up with the HM board.

My assumption is that I need to compile my ino file into a hex file and upload it with avrdude?
 
Yeah you can compile anything in the Arduino IDE and flash the HEX file via the LinkMeter AVR Update page. I actually have a programmer defined that just calls this batch file to flash the file on the HeaterMeter. Requires curl on your system though and the password to be set below.
Code:
@ECHO OFF
SET HOST=192.168.2.21
SET PASS=xxx

C:\SysTools\curl\curl.exe -s -c %TEMP%\wwwavrdude.txt -H "Expect:" --form username=root --form password=%PASS% "http://%HOST%/luci/;stok=9d3845c5ed27aa9c81f4bc2b56b04329/admin/lm/fw" > NUL
C:\SysTools\curl\curl.exe -s -b %TEMP%\wwwavrdude.txt -H "Expect:" --form hexfile=@"%1" --form step=3 --form hex=/tmp/hm.hex "http://%HOST%/luci/;stok=9d3845c5ed27aa9c81f4bc2b56b04329/admin/lm/fw"
 
I should also point out that the linkmeterd might try to overwrite your code because it isn't getting heatermeter data any more. You should be able to avoid this by having your sketch put out a line with the microcontroller identifier line like this
Code:
$UCID,HeaterMeter,20160909
The 2 values don't matter, but the first is the sketch name, the second is the version number. They're strings and can be whatever you want but that will make linkmeterd think that data is coming. It will send a "/config" request but you can safely ignore it. Another useful sentence is the $HMLG,XXX which is a log message that is broadcast to all web clients and you'll see it in the javascript console log.
 
Good stuff, thanks!

I'll be using raspbian jessie as the distro on the pi, so no need to worry about linkmeter. I was more curious if I could treat the HM board as an arduino, which it looks like I can.

On a side note, I just discovered https://circuits.io/ which is super handy for testing out circuits and code.
 
I'll be using raspbian jessie as the distro on the pi, so no need to worry about linkmeter. I was more curious if I could treat the HM board as an arduino, which it looks like I can.
Oh yeah I've used avrdude on Raspbian as well to flash a HeaterMeter. It is connected via SPI and the reset pin is tied to GPIO25, which is the default linuxspi I think (although I did it way before they did!). Blank ATmegsa need to be programmed at -b128000, but once they are up to 16MHz you'll want to use -b2000000 instead of the default 400kHz because why not program at 5x speed? Also ffs skip verify because when EVER has programming not been successful?
Code:
modprobe spidev
modprobe spi-bcm2835

avrdude -P /dev/spidev0.0 -p m328p -c linuxspi -b2000000 -V -U flash:w:${FILE}:i

EDIT: The spi module is spi-bcm2835 on newer systems spi-bcm2807 on older systems.
 
Last edited:
Just a quick note to say how much I'm loving using the arduino simulator at https://circuits.io/

This is my prototype for creating a capacity tester for 4 batteries at a time and logging the results. I can adjust the voltage and current of each unit to simulate batteries at different voltages and mAh capacties as well as change the shunt and load resistor values to come up with the ideal load.

m4oc9LG.png
 
Any advice or guidance on running the atmega328p with 5v vcc rather than 3.3v?

My reason for running at 5v is to be able to measure voltages on the analog pins that are around 4v without having to use a voltage divider on each pin. I'll just need to use a voltage divider for the atmega TX to raspi RX signal.
 
According to the spec sheet the 328p requires a voltage between 1.8 and 5.5V. 5V Should work just fine.
 
Any advice or guidance on running the atmega328p with 5v vcc rather than 3.3v?
If you're asking about HeaterMeter, you should be fine unless you're using thermocouple inputs. The thermistor code is all proportional so it doesn't matter what the voltage is, just the ratio of voltage missing vs voltage remaining. Thermocouples are "5mV/C" which means we need to know what the voltage is so it is hard coded to an input voltage of 3.300V. If you need thermocouple support you can just scale the mV/C value so instead it would be... what, 7.58mV/C? The constant can be used to adjust the calculation so that the ADC value is scaled back to 3.3V. If you're hooking to a Raspberry Pi however, we are the SPI bus master so the SCK and MOSI lines will get 5V from the atmega to the Pi which will ruin its day.

If you're talking about atmegas in general, then of course! Most atmegas in use are 5V VCC at 16MHz. Actually, us running 16MHz at 3.3V is out of spec because they are supposed to only do 16MHz down to around 3.9V. I think the reason we went down to 3.3V in the HeaterMeter v3 days was because we were interfacing to 3.3V parts and having level shifters all over was a mess.
 
It was for atmegas in general. Rather than trying to use the semi-dead HM 4.0 board, I gutted it for the parts needed (DIP28 socket, caps and 16mhz oscillator, etc). I think I might use the Murata 5v regulator as well.

Here's the little board I made. I'm able to read and write to the chip using avrdude. Still need to hookup the serial connection.

0t0gyS4l.jpg
 

 

Back
Top