11°- ¡HERE WE GO AGAIN!


Output devices

Inicio

Wednesday ,April 21

Hello everyone, welcome back to this your favorite profile of "improvising with electronics", just kidding, well this week was a little more interesting than the previous ones and by interesting I mean that it was very challenging, starting with the move From the FabLab to a new place and with the challenge of fulfilling the assigment with the materials that I had at home, join me to see this medley of trial, error and much more.

Components/Functioning/Bootloader Attiny85/Group assignment

The challenge

For this week's mission, it was asked to connect our board to an output device or also known as actuators, following the line of the previous mission in which I made the breathalyzer (see it here) and taking into account that I have fewer and fewer weeks left. (I swear to you how time flies, sometimes it scares), it is time to connect an OLED screen to my motherboard, however on the way I resolved that I do not need a super microcontroller to do that activity, that is why I used our dear Attiny85 (I swear to you, I love this microcontroller) so that it can connect with a 128x64 dimension Oled screen, so that it is something similar to this:

Do you want to know how I did it? Join me to see it.

The components & Group assignment

Only a couple of components will be needed for this mission For this mission the components are almost the same from the previous mission or from week 4 in electronic production, however I will mention them right now:
-Attiny85:
-MQ3 sensor :
-OLED SSD1306:
Initially these are the most important components, however if you want to do some programming tests you will need some additional components in case you do not have a board for the attiny85, these are the following:

-Mini Breadboard
-Usb male A
-Res 220 ohms x2
-Res 1k ohms x1
-Jumpers

For this mission we will use an electronic board that was already manufactured in previous missions, which in this case we named fabtiny because it is built around the attiny85 microcontroller, which is one of the most versatile microcontrollers of all, it is also compatible with arduino as well. that allows us easy programming with our electronic components.

These will be for the assembly of the attiny programmer (it is only necessary if you do not have an attiny programmer), there are other ways to program the attiny85 such as connecting it with another arduino through ISP or through the ICSP pins, which you can review here.

This microcontroller is very particular due to its low current consumption and also because it can be used with different actuators and sensors, as if that were not too much, it also has the possibility that it can be articulated with the Arduino bootloader and be able to program it directly. with arduino, besides that it can also be used for other projects and due to its size it lends itself a lot to other designs.

If we want to explore a little more about this microcontroller and its benefits, we can easily visit its datasheet in which all its functions appear or we can also appreciate it in the following image in which it certifies that this microcontroller by itself can consume about 300 ua which is surprising for a microcontroller and which would give way to only the use of current through the sensors and actuators.

Hello World - Individual assignment

To start we must remember that in this mission we will work with our beloved atinny 85 programmable board, which we had previously used for other missions as we can see in the following video, here we can also see how the board works with output leds and an entry button.

*The fabtiny electronic card controlling output and input devices at the same time.

One of the most satisfactory things in the world of electronics and programming is to achieve this first circuit and programming for the popular "Hello world", this time we will do it on our OLED screen. First we must have the circuit ready and in our case the following circuit will be the one that we will use for this mission:

It is time to program, for this it is necessary to add some libraries to our Arduino Ide because the programming for the OLED in an attiny85 is different than in a different Arduino Uno, for this we will have to download the following libraries:

SSD1306

Tinywire

Then we have to copy the folders in the libraries folder inside the arduino folder and now it's time to program:

To carry out the "Hello World" programming it is necessary that we use this programming in our arduino IDE sketch:

	void setup() {
		 TinyWireM.begin(); // iniciar I2C en attiny85
		 oled.init(0x3c);   // Init Oled display
		 oled.clear();
	   }
	   void loop() {
		 //analogRead en A2
		 oled.cursorTo(25, 0);
		 oled.printString( "Hola Mundo ");
	   
	   }
	   
	   
	

Sounds cool to you? Now is the time to raise the level a bit, to do so we have to place the following programming in a new arduino sketch:


		#include "SSD1306_minimal.h"
		SSD1306_Mini oled;   // oled 
		char palabra[5];    // Para ingresar letras
		
		void setup() {
		  TinyWireM.begin(); // iniciar I2C en attiny85
		  oled.init(0x3c);   // Init Oled display
		  oled.clear();
		}
		void loop() {
		  //analogRead en A2
		  oled.cursorTo(0, 0);
		  oled.printString( "Medicion:");
		  oled.cursorTo(65, 0);
		  printAnalog(2);
		  oled.printString("mg/l");
		  delay(50);  // actualiza el display
		}
		
		//crear una nueva función de lectura
		void printAnalog(byte i) { 
		  dtostrf((((analogRead(i) / 1024.0) * 10.0)-1.10), 4, 2, palabra); //calibrando el sensor
		  oled.printString(palabra);
		}
		
		

Chef's Notes:
- When loading the program, remember not to have anything connected to pins 2 or 3 (D +, D-), because these pins on the Attiny85 are used for the serial communication of the attiny85 and your computer, on the other hand, remember that in This configuration requires powering the electronic board through the USB port.

Once finished we will have the following result:

Next-Week 11 Previous-Week 9