UNO + ENC28J60 + DS18B20 "Sketch too big"

Hi,

I would like to make sketch: room temperature(s) to Blynk with ENC28J60 and DS18B20. When i use temperature float values, the sketch is too big. INT temperature is okay, but i would like to use decimal values for temperture(s).

Please look the sketch:

define BLYNK_PRINT Serial // Comment this out to disable prints and save space
include UIPEthernet.h>
include BlynkSimpleUIPEthernet.h>
include OneWire.h>
include DallasTemperature.h>

char auth[] = “11da2c8d999448709fc49b42b47bec0e”;
int DS18S20_Pin = 2; //DS18B20 -> D2
OneWire ds(DS18S20_Pin);

float temperature;
//DallasTemperature sensors(&ds);
//DeviceAddress Probe01 = { 0x28, 0x72, 0xCF, 0x29, 0x05, 0x00, 0x00, 0x73 };

void setup()
{
//Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth);

// sensors.begin();
// sensors.setResolution(Probe01, 9);
// Setup function to be called each 5000 milliseconds
//timer.setInterval(5000, sendUptime);
}

// This function sends Arduino’s up time every second to 0rtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendUptime()
{
float temperature = getTemp();

// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(0, temperature); // Virtual 0
delay(5000);
}

void loop()
{
int temperature =getTemp(); //float is too big for sketch :frowning:

Blynk.run(); // Initiates Blynk
Blynk.virtualWrite(0, temperature); // Virtual 0
delay(1000);
// timer.run(); // Initiates SimpleTimer
}

float getTemp(){
//returns the temperature from one DS18B20 in DEG Celsius

byte data[12];
byte addr[8];

if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return 100; //+100C
}

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println(“CRC is not valid!”);
return 100; //+100C
}

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print(“Device is not recognized”);
return 100; //+100C
}

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;
}

Any advice how to make sketch smaller ? I would like to use up to 8 pcs DS18B20 senors with decimal values. IS it possible for arduino uno ?
Regards,
Jonkka

You possibly forgot to comment-out the first line: “#define BLYNK_PRINT Serial”. This helped me with your sketch :smile:
Furthermore, you can comment-out line “#define BLYNK_BUILTIN” in Blynk/BlynkConfig.h to remove built-in analog and digital operations (leaves you with virtual pins only).

Remember that ENC28J60 need software implementation of TCP stack on Arduino, this is quite big.
Same for OneWire, so you get a big binary.
I would recommend looking at ESP8266 as a standalone solution…

Hi,

Thanks a lot for help! :slight_smile: Now it works with one DS18B20 sensor and also decimals.

When i power boot my Arduino UNO, it will works about 1 minute. Then Blynk (android mobile app) tells than arduino uno not connected, and no temperature value anymore.

Router is working all time, maybe is it some blynk timeout ? Or router settings ?

Regards,
Jonkka

Can’t tell. You need to run Blynk with prints to understand what’s going on… (but it doesn’t fit)