when i use the tft display the ds18b20
if i comment out the begin for the display the ds18b20 works but i dont know how to remove that conflict ive tried 2 diffrent libs for the temp sensor
#include "painlessMesh.h"
#include <Arduino.h>
#define MESH_PREFIX "whateverYouLike"
#define MESH_PASSWORD "somethingSneaky"
#define MESH_PORT 5555
#include "DS18B20_INT.h"
#define ONE_WIRE_BUS 12
OneWire oneWire(ONE_WIRE_BUS);
DS18B20_INT sensor(&oneWire);
Scheduler userScheduler;
painlessMesh mesh;
#include "Ucglib.h" // Include Ucglib library to drive the display
// Create display and define the pins:
Ucglib_ST7735_18x128x160_HWSPI ucg(2, 15, 0); // (A0=2, CS=10, RESET=9)
// The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK=13 and SDA=11)
int Variable1; // Create a variable to have something dynamic to show on the display
int temp1=0,temperature1=20;//hemma
int temp2=0,temperature2=5;//borta
String tempstring;
int anval;
float current=0;
void sendMessage() ; // Prototype so PlatformIO doesn't complain
Task taskSendMessage( TASK_SECOND * 1 , TASK_FOREVER, &sendMessage );
void sendMessage() {
ucg.setPrintPos(60, 120); // Set position (x,y)
ucg.print(current);
Serial.println(current);
taskSendMessage.setInterval(10000);
}
void setup(void) // Start of setup
{
// start serial port
Serial.begin(115200);
// Start up the library
sensor.begin();
// request to all devices on the bus
delay(100);
// Display setup:
pinMode(4, OUTPUT);
pinMode(5, INPUT_PULLUP);
pinMode(16, INPUT);
digitalWrite(4, HIGH);
// Select a type of text background:
//ucg.begin(UCG_FONT_MODE_TRANSPARENT); // It doesn't overwrite background, so it's a mess for text that changes
// ucg.begin(UCG_FONT_MODE_SOLID); // It writes a background for the text. This is the recommended option
ucg.clearScreen(); // Clear the screen
// Set display orientation:
ucg.setRotate270(); // Put 90, 180 or 270, or comment to leave default
ucg.setFont(ucg_font_7x14B_mr);
ucg.setColor(0, 255, 255, 255); // Set color (0,R,G,B)
ucg.setColor(1, 0, 0, 0); // Set color of text background (1,R,G,B)
ucg.setPrintPos(0,11); // Set position (x,y)
ucg.print("HEMMA BORTA");
delay(1000);
ucg.setFont(ucg_font_inb46_mr);
mesh.setDebugMsgTypes( ERROR | STARTUP ); // set before init() so that you can see startup messages
mesh.init( MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT );
Serial.println("itwork");
userScheduler.addTask( taskSendMessage );
Serial.println("itwork");
taskSendMessage.enable();
ucg.print("test");
} // End of setup
void loop(void){
mesh.update();
// Read analog value
anval = analogRead(0);
// Adjust temperature1 based on analog value
if (anval < 100) {
temperature1--;
delay(200);
} else if (anval < 750 && anval > 100) {
temperature1++;
delay(200);
}
// Increment temperature2 if button on pin 5 is pressed
if (digitalRead(5) == LOW) {
temperature2--;
delay(200);
}
// Decrement temperature2 if button on pin 16 is pressed
if (digitalRead(16) == LOW) {
temperature2++;
delay(200);
}
// Update display if temperature1 changes
if (temperature1 != temp1) {
tempstring = String(temperature1);
temp1 = temperature1;
if (temperature1 < 10)
tempstring += " ";
ucg.setColor(0, 255, 0, 0); // Set color (0,R,G,B)
ucg.setColor(1, 0, 0, 0); // Set color of text background (1,R,G,B)
ucg.setPrintPos(-3, 60); // Set position (x,y)
ucg.print(tempstring);
}
// Update display if temperature2 changes
if (temperature2 != temp2) {
tempstring = String(temperature2);
temp2 = temperature2;
if (temperature2 < 10)
tempstring += " ";
ucg.setColor(0, 0, 0, 255); // Set color (0,R,G,B)
ucg.setColor(1, 0, 0, 0); // Set color of text background (1,R,G,B)
ucg.setPrintPos(80, 60); // Set position (x,y)
ucg.print(tempstring);
}
sensor.requestTemperatures();
// BLOCKING!! blocks until sensor is ready
Serial.print("Temp: ");
Serial.println(sensor.getTempC());
// current = temporary;
delay(10);
}
// End of loop