Dear Reader:

This is currently a WIP, and I've yet to finilize a lot, which is why some information is omitted, such as my hardware setup and github links. As such what is currently here may not make complete sense when you are reading this, however I intend to update this section as I go

Software:

Currently to make this project work I am using Mosquitto broker on the same device as the Qt chart, which can then just listen on localhost. If I do decide to make a dedicated server, I think it would be best to just make it another project and keep this micro controller project small in scope

Programming the controller is done with PlatformIO instead of the arduino IDE, no good reason for that, I just like VS Code UI so much more that Arduino IDE. 

Hardware:

Two MAX6675 digital converters which handle reading the k-type thermocouples such that the difference of temperature between the hot measuring junction, and the reference junctions are accounted for as well.

To work with those converters I also have 2 K-type thermocouples, one with a stub nose, which is to read ambient temperature when smoking meat, as its such a fundamental part of smoking. The other sensor is of the long pointy form so that I may stab the meat I'm cooking, and measure internal temperature. 

Finally the controller is the Arduino MKR1010, and it was chosen because I wanted a small form factor, with low power demands to support sitting outside next to a hot smoker for hours at a time. The MKR1010 provided an out of the box solution to networking needs as well

Current Task
The two converters communicate over SPI, and I am currently working out a way to have the two sensor share a common bus (I think I am using that term correctly). A colleague from work with more experience in hardware suggested I use a tri-state buffer to isolate the signals from each sensor when their corresponding CS pin is pulled low (or "selected"). 

Arduino Code 

I'm not yet ready to share my code publicly as my WiFi credentials are still hard coded, but the overall loop works as below

void loop() 
{
  bool somethingToSend = false;

  // if(temperatureSensors.readAmbientTemperature()) TODO: Figure out how to make sensors share same buffer
  // {
  //   somethingToSend = true;
  //   double ambientTemperature = temperatureSensors.getAmbientTemperature();
  //   networkInterface.SendMessageTemperature(ambientTemperature);
  // }

  if(temperatureSensors.readInternalTemperature())
  {
    somethingToSend = true;
    double internalTemperature = temperatureSensors.getInternalTemperature();
    networkInterface.SendMessageTemperature(internalTemperature);
  }
  
  if(!somethingToSend)
  {
    networkInterface.Poll();
  }
  
  LowPower.sleep(250);
}

 The loop depends on 2 main parts, with an additional LED control which is not super useful to overall project.

  1. MQTT client class which (as you likely have guessed) sends the temperature data over my home WiFi via MQTT. The broker runs locally on my personal laptop. 
  2. MAX6675 handler, and by extension what actually measures the temperatures. handles the chip selection of SPI and gathers the data.
  3. the onboard LED just changes color based on the Arduino's connection to the MQTT broker and WiFi - as the device is to run without a computer I figured it would help in making sure all is good. Its omitted from the loop as it doesn't need to change per step. Its only used in the Setup().

Both converters are managed by the one class. This object (I mean the class that manages the sensors) takes a periodic reading, which is organised in two circular buffers type logic - one for ambient, another for internal. Once the buffers are full the main loop receives that there is data to send to the broker, that data is the temperature readings from the buffers. Rather than spam the broker with several "noisy" temperature readings, both sensors buffers are averaged out to reduce "noise", and those value is determined to be the current temperatures. Data is sent every...

Read more »