Embedded programming

Week 8 - 16 March

In order to better understand what is programable by a microcontroller, Victor drove us through the basics of computer programming and the difference between Analog and Digital. Analog has a continuous value that humans have to set, while digital draws a flow average curved line along those values to create a smoother and more accurate path. 

We use a transistor to control the flow of electrons electrically. Thanks to the transistor we can program different tasks based on the voltage that the microcontroller receives, and convert it to a value.

A memory or chip is an amount of a lot of transistors that store information. Architecture on a microchip: is a set of instructions and a combination of circuits that does small specific tasks. 

Microcontrollers can do only one thing at a time while microprocessors can do multiple tasks at the same time. Thanks to the internal clock of the microprocessor we can program a task based on the time that has passed between the conditions. 

Weekly task

Use your programmer (HUZZAH32, ESP32 Feather) to program a circuit with a “led and a bottom” to do something

The circuit board, could be done as a shield, breadboard or vinyl cutter

How to program the temperature sensor? 

I decided to continue programming the thermistor sensor that I used for my circuit in the electronics design task. Depending on the microcontroller the voltage reference will change. In this case, I’m using an ESP32 with an output voltage of 3v3. 
Analogue to digital ADC 10 Bits.
A voltage divider, Higher to lower using a combination of resistors. 
Ohms Laws:
V in = I (current) * (R1 +R2)
V out = I * R2

Values of a sensor are basically the modifications to the current received by the microcontroller.I used this tutorial to understand the theory behind it.

   
void setup() {
  // put your setup code here, to run once:
  pinMode(A7, INPUT);
  Serial.begin(9600);
}
void loop() {
  // put your main code here, to run repeatedly:
  int tempReading = analogRead(A7);
  // This is OK
  double tempK = log(10000.0 * ((4095.0 / tempReading - 1)));
  tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK )) * tempK );       //  Temp Kelvin
  float tempC = tempK - 273.15;            // Convert Kelvin to Celcius
  Serial.print( "T = " );
  Serial.print( tempC, 1 );
  Serial.print( "     " );
  Serial.println( tempReading );
  delay(500);
}

Link to class documentation

Link to Files