Digispark #2:
Interfacing Digispark With Temperature Sensor LM35
In our previous post, we look on how to interface the Digispark with LCD 16x2. Today we will look at how we can interface the temperature sensor LM35 with Digispark. For this, we will need to have the LM35 temperature sensor, Digispark and the LCD. Before going further let's look at LM35.
Basically, the LM35 looks similar to any other transistor. To differentiate either it is a transistor or temperature sensor one to check the value printed on the flat side of it. The pinout of the LM35 is as shown on the image above. By looking it from the flat side, the first pin on the left is the 1) VCC, 2) Analog Out and 3) Ground. The connection of the circuit diagram is as shown below
Once we have constructed the circuit as per the image above, now we can move on to the programming part.
This code can copy and paste directly into the Arduino IDE. Once verified, try to upload to the board. Below are the image and video of my testing.
And below is the demo video
Thank you
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <TinyWireM.h> // I2C Master lib for ATTinys which use USI - comment this out to use with standard arduinos #include <LiquidCrystal_I2C1.h> // for LCD w/ GPIO MODIFIED for the ATtiny85 #define GPIO_ADDR 0x27 // (PCA8574A A0-A2 @5V) typ. A0-A3 Gnd 0x20 / 0x38 for A - 0x27 is the address of the Digispark LCD modules. LiquidCrystal_I2C1 lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines float temp; int tempPin = A3; // analog input pin float tempc; //variable to store temperature in degree Celsius float vout; //temporary variable to hold sensor reading void setup(){ pinMode(tempPin,INPUT); // Configuring pin A1 as input TinyWireM.begin(); // initialize I2C lib - comment this out to use with standard arduinos lcd.init(); // initialize the lcd lcd.backlight(); // Print a message to the LCD. lcd.print("Electrosoft!"); delay(500); } void loop(){ vout=analogRead(tempPin); vout=(vout*500)/1023; tempc=vout; // Storing value in Degree Celsius lcd.setCursor(0,0); lcd.print("in DegreeC= "); lcd.setCursor(0,1); lcd.print(tempc); delay(1000); //Delay of 1 second for ease of viewing in serial monitor } |
This code can copy and paste directly into the Arduino IDE. Once verified, try to upload to the board. Below are the image and video of my testing.
And below is the demo video
Thank you
Well, This is really great you have tried something new with Digispark. IoT devices made home totally automated. The Wifi temperature. humidity, light and vibration sensors has changed the life completely. Thanks for sharing the coding part with us!
ReplyDeleteYou there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. temperature chamber,
ReplyDeleteHistory essay writing can be a tricky subject. Learn the way you possibly can write college essays for history classes with ease. belltestchamber.com
ReplyDeleteI have recently had an experience vindicating the use of weather strips. I now want to pass on this knowledge to other people. Barrackpore
ReplyDeleteWhat lines in the code must be changed if we replace the LCD for a TM1637?
ReplyDelete