Friday, July 13, 2012

Tips for using NeoCat's Arduino Twitter library

This may be obvious to people who are better at programming than me, but I struggled to figure it out for a while. NeoCat's library can only post chars and char arrays to twitter, but readings are not in char format. To get around this I had to do some fiddly type conversions, which I lay out below.



itoa(var, varChar, 10);                               //converts 'var', which is an int, to 'varChar', which is a char
                                                                //If anyone can tell me what the '10' is for, please do


stringone = String(stringone + varChar  );    //make a string called stringone. Append the newly formed  
                                                                  //char 'varChar', which was the int 'var'.
                                                                   

   stringone.toCharArray(msg, 100);             //convert 'stringone' to char array (reads "value of the in
                                                                  //'var'")
                                                                  //save the char array as 'msg'. 100 is the number of
                                                                  //characters in the char array.
twitter.post(msg);                                       //posts data to twitter


'msg' must be declared as a char at the beginning of the sketch.

Notes: 
var was declared as an int, it could be, for instance, an analog reading.
varChar was declared as a char[].
stringone does not need to be declared until it is made.
More chars and char arrays can be added to stringone by using the + symbol and the char name.

Brewduino

I put down my first all-grain batch of beer the other day, and discovered that the arduino-based thermostat I had made for it had stopped working. I put the beer inside to keep warm, and it seems to be ok, but it prompted me to continue work on my brewing computer.

I now have a functioning network, so I've decided to add a reporting feature to my device. I've written the first revision of the code, but haven't yet got all the hardware going.

Here are the functions planned:

Internet enabled
Temperature sensing
Thermostatic control (hopefully with PID/PD)
Specific gravity sensor
Temperature calibration for gravity readings (reads gravity and spits out what the value would be if the liquid were at a set temperature)
Alcohol content calculation
Daily report of gravity, alc% and temperature via Twitter and email
Thermostatic control failure alert via Twitter and email
'Time to bottle' alert via Twitter and email
Datalogging

I'm yet to get the gravity sensor working, but that shouldn't be too much of an issue. I also haven't trialled the datalogging to SD card or PID yet. So far I know I can get it to send me an email with the readings, and I know it can control the temperature. More to come when I'm closer to completion.

Furnacey fun

I made the rest of my casting patterns the other day, and after painting them with glossy paint, set to finishing the furnace.

I lined it with the clay mix from before after grinding it down to a very fine powder. Because I knew I was short on volume I added all the sawdust I could find, most of a bag of perlite, some more sand, and the last of my bag of bentonite. I also filled the bottom of the body with dirt to fill up some of the extra space.

When lining furnaces it's important that your clay not be too wet. That was my problem the first time, and the loss of moisture caused a lot of shrinkage, and thus, cracks. This time I made the clay much drier. I spread the dry clay out as thinly as I could on a plastic ground sheet and sprayed a very fine mist of water over it, then mixed thoroughly with a rake. I repeated this until the clay was uniformly damp. It looked a bit like breadcrumbs and clumped together when squeezed, but did not feel wet. After that, I covered it for a while so it could percolate a bit, and to give me time to get the body ready to be lined.

The inner form was made by wrapping the metal from an old canola oil tin around a pair of wooden discs. Before doing this I rolled it up as tightly as possible and tied it like that for a few days. This meant that the metal was springy and would hold the discs, but also that it would pop in on itself when the discs were removed. I packed about an inch of clay down straight on top of the dirt, making sure there was a former for a drain hole. That done, I set the inner form on the clay bottom and began to ram clay in around it. When I got to the level of the burner I put the pipe in and continued to ram. You should build the lining up in very small layers, working around the furnace as you go.

To line the lid I just placed it on a piece of plastic sheet on the ground, inserted a piece of PVC in the middle as a former, and packed the clay in. I rand wires all through the lid to add stability. After using the concrete here it occurred to me that I should have used concrete in the bottom instead of dirt too...

Unfortunately, I was STILL short of clay, so the lid was only 2 thirds full, and the body lining stopped short about an inch from the top of the steel wall. To compensate for this I ground the steel on the body back to the level of the clay, I also filled the top of the lid in with quick set concrete. This is not a hotface, so concrete was fine. It was just to add stability.

I also began work on a lifting mechanism for the lid, but haven't finished it yet.

I cast my first four lathe parts the other day, and they came out reasonably well. Some had little pockets caused by loose sand, but the pockets are in non-critical places. It took all day, but I got the carriage, cross slide, compound base and compound slide castings done, and turned all my scrap into ingots. I'll upload some photos soon, but at the moment I'm busy machining the castings on a friend's milling machine.