Project #6: MicroView – Mk03
MicroView
Project #6 – Mk03
1 x MicroView
1 x DS18S20
1 x Resistor 1.65k Ohm
3 x Jumper Wires 3″ M/M
08 pin – GND
11 pim – 2
15 pin – +5V
DonLuc1804Mk05b.ino
// ***** Don Luc ***** // Software Version Information // 3.01 // DonLuc1804Mk05 3.01 // MicroView // OneWire // DS18S20 #include <MicroView.h> #include <OneWire.h> // Temperature chip i/o int DS18S20_Pin = 2; //DS18S20 Signal pin on digital 2 OneWire ds(DS18S20_Pin); // on digital pin 2 float temperature = 0; String tempZ = ""; void loop() { // Temperature chip i/o temperatu(); isTe(); uView.setFontType(1); uView.setCursor(0,20); uView.print("Don Luc"); uView.display(); delay(1000); uView.clear(PAGE); }
getTemperature.ino
float getTemp() { //returns the temperature from one DS18S20 in DEG Celsius byte data[12]; byte addr[8]; if ( !ds.search(addr)) { //no more sensors on chain, reset search ds.reset_search(); return -1001; } if ( OneWire::crc8( addr, 7) != addr[7]) { return -1002; } if ( addr[0] != 0x10 && addr[0] != 0x28) { return -1003; } ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end byte present = ds.reset(); ds.select(addr); ds.write(0xBE); // Read Scratchpad for (int i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); } ds.reset_search(); byte MSB = data[1]; byte LSB = data[0]; float tempRead = ((MSB << 8) | LSB); //using two's compliment float TemperatureSum = tempRead / 16; return TemperatureSum; } void temperatu(){ temperature = getTemp(); } void isTe() { tempZ = ""; uView.setFontType(1); uView.setCursor(0,10); uView.print("Celsius"); uView.setCursor(0,30); tempZ.concat(temperature); tempZ.concat("C"); uView.print( tempZ ); uView.display(); delay(5000); uView.clear(PAGE); }
setup.ino
void setup() { uView.begin(); // begin of MicroView uView.clear(ALL); // erase hardware memory inside the OLED controller uView.display(); // display the content in the buffer memory, by default it is the MicroView logo delay(1000); uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared. uView.setFontType(1); uView.setCursor(0,20); uView.print("Don Luc"); uView.display(); delay(5000); uView.clear(PAGE); // erase the memory buffer, when next uView.display() is called, the OLED will be cleared. uView.setFontType(1); uView.setCursor(0,20); uView.print("OneWire"); uView.display(); delay(5000); uView.clear(PAGE); uView.setFontType(1); uView.setCursor(0,20); uView.print("DS18S20"); uView.display(); delay(5000); uView.clear(PAGE); }
Don Luc
Leave a Reply