How to change temperature upload period and put the ENC28J60 ethernet to sleep?


#1

I use DS18B20 sensor, ENC28J60 ethernet module and Arduino MEGA. I want this system to last many years. Ethernet is operating on 40-70C so I don’t think it will last many years (my opinion). So I want to upload temperatures and put the module to sleep for 1 hour.

  1. How to upload only one temperature value once and not periodically?

  2. How to send ENC28J60 module (not shield) to deep sleep?

    /**************************************************************
    For this example you need UIPEthernet library:
    https://github.com/ntruchsess/arduino_uip

    Wire it up:
    

    VCC - 3.3V
    GND - GND
    SCK - Pin 52
    SO - Pin 50
    SI - Pin 51
    CS - Pin 53

    **************************************************************/
    #define CAYENNE_DEBUG // Uncomment to show debug messages
    #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space

    #include <CayenneDefines.h>
    #include <UIPEthernet.h>
    #include <BlynkSimpleUIPEthernet.h>
    #include <CayenneEthernetClient.h>
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #define VIRTUAL_PIN V1
    boolean temp_uploaded=0;
    const int tmpPin = 3;
    OneWire oneWire(tmpPin);
    DallasTemperature sensors(&oneWire);

    char token[] = “”; //NOT MY TOKEN

    void setup()
    {
    Serial.begin(9600);
    Cayenne.begin(token);
    sensors.begin();

    }

    void loop()
    {
    Cayenne.run();

    }

    // This function is called when the Cayenne widget requests data for the Virtual Pin.
    CAYENNE_OUT(VIRTUAL_PIN)
    {
    // Send the command to get temperatures.
    sensors.requestTemperatures();
    // This command writes the temperature in Celsius to the Virtual Pin.
    Cayenne.celsiusWrite(VIRTUAL_PIN, (random() % 100));
    Serial.println(“Temp updated”);
    temp_uploaded=1;
    // To send the temperature in Fahrenheit use the corresponding code below.
    //Cayenne.fahrenheitWrite(VIRTUAL_PIN, sensors.getTempFByIndex(0));
    }


#2

Hello Sir,

you can use:

static void 	powerDown ()
 	Put ENC28J60 in sleep mode.
 
static void 	powerUp ()
 	Wake ENC28J60 from sleep mode. 

I recommend to read this article: http://blog.derouineau.fr/2011/07/putting-enc28j60-ethernet-controler-in-sleep-mode/