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.
-
How to upload only one temperature value once and not periodically?
-
How to send ENC28J60 module (not shield) to deep sleep?
/**************************************************************
For this example you need UIPEthernet library:
GitHub - ntruchsess/arduino_uip: UIPEthernet: A plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Build around Adam Dunkels uIP Stack. Further developed version can be found on https://github.com/UIPEthernet/UIPEthernetWire 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));
}