AntiGuide: PoTrollDoucheV0



PagePrincipale :: DerniersChangements :: ParametresUtilisateur :: Vous êtes 216.73.216.212 :: Signaler un abus :: le: 20250716 13:27:40
Version obsolete, voir PoTrollDoucheV1
20160407

sans douite constrit sur un Modèle mini o pro
consigne fixe!
prise CH2 A
affichage 4digits si connecté
sonde Ds18B20 étanche sur câble
était branché par prolific noir intégré dans usb male! noir rouge vert jaune
mis usb pwr noir rouge

conso: moins de 1 mA en veille, donc si 400 mAh (baton 9900 mAh) on doit durer 400 heures, plus d'une semaine

chantier: C:\Users\adminpo\Desktop\ARDUINO\arduino-1.6.7\examples\po\PoTrollDouche2?

réflexion sur afficheur!
le Led4Digits5pins n'est pas convenable(nécessite raffaichissement permanent)
ressortir afficheurr Lcd 16x2 peu de fils ArduinoLcd16x2 (6 mA , mais 25 mA avec rétro-éclairage)

20160407-1145 mis en déchage sur PowerBankBlackLcd : échec se met en sécurité
20160407-1300 mis en déchage sur PowerBankGoldLed : semble tenir


#include "DS18B20.h"
#include "RCSwitch.h"
#include "Sleep_n0m1.h"

#include "DISPLAY4.h"
// display
#define SCK 7
#define RCK 5
#define DIO 6

Sleep sleep;
unsigned long sleepTime; //how long you want the arduino to sleep

RCSwitch mySwitch = RCSwitch();

// testé le 20120213 aveccapteur  reçu ce jour
// http://antiguide.free.fr/wiki/wakka.php?wiki=ArduinoDs18B20
/*ReadDS18B20
ver: 6 Jly 2010
THIS IS A FIRST DRAFT.... WORKS, but scheduled for overhaul.


Simple, simple test of reading DS18B20
connected to nuelectronics.com datalogging shield.

See...

http://sheepdogguides.com/arduino/ar3ne1tt.htm

... for explanation of this code.

Code lightly adapted from code from nuelectronics.com*/

#define PWR_PIN 13

#define TEMP_PIN  11 //See Note 1, sheepdogguides..ar3ne1tt.htm
#define TEMP_PWR_PIN  12 //See Note 1, sheepdogguides..ar3ne1tt.htm

#define RF433_PIN 10

#define Tcritique 2800 

#define  ON "00FF00FF000F"
#define OFF "00FF00FF0000"

DS18B20 ds;
DISPLAY4 display;
void setup() {
    Serial.begin(115200);
    delay(1000);
    sleepTime =10000;

    Serial.print("Douche... : ");
    Serial.println(Tcritique);

      mySwitch.enableTransmit(RF433_PIN);  // pin emetteur
      mySwitch.setRepeatTransmit(4);  // increase # of frames will slow process!

    plug(false);delay(4000);
    plug(true);delay(4000);
    
    digitalWrite(TEMP_PIN, LOW);
    pinMode(TEMP_PIN, INPUT_PULLUP);      // sets the digital pin as INPUT_PULLUP (logic 1)
    digitalWrite(TEMP_PWR_PIN,LOW);
    pinMode(TEMP_PWR_PIN, OUTPUT);      // sets the digital pin as INPUT_PULLUP (logic 1)
    digitalWrite(TEMP_PWR_PIN,HIGH);
    
    
    Serial.print(TEMP_PIN);
    Serial.print("\n");
    ds.begin(TEMP_PIN);

    sleep.idleMode();
    sleep_mode();
    wdt_disable();   
 
}

void plug(bool on){
  if (on) {
    mySwitch.sendTriState(ON);
    Serial.println(ON);
  }else{
    mySwitch.sendTriState(OFF);
 Serial.println(OFF);
  }
  
}
void loop(){

  int TReading=ds.read();
  Serial.print("raw: ");
  Serial.println(TReading);
 int SignBit, Whole, Fract, Tc_100;
 
  SignBit = TReading & 0x8000;  // test most sig bit
  if (SignBit) // negative
  {
    TReading = (TReading ^ 0xffff) + 1; // 2's comp
  }
  Tc_100 = (6 * TReading) + TReading / 4;    // multiply by (100 * 0.0625) or 6.25
  Serial.print("centieme de degre: ");Serial.println(Tc_100); 
  plug(Tc_100<Tcritique);
  display.setint(Tc_100);
  display.show(5);
  
  Whole = Tc_100 / 100;  // separate off the whole and fractional portions
  Fract = Tc_100 % 100;


  if (SignBit) // If its negative
  {
     Serial.print("-");
  }
  Serial.print(Whole);
  Serial.print(".");
  if (Fract < 10)
  {
     Serial.print("0");
  }

  Serial.print(Fract);

      Serial.print("\n");
 // delay(5000);      // 5 second delay.  Adjust as necessary


   Serial.print("sleeping for ");
  Serial.println(sleepTime); 
  delay(100); //delay to allow serial to fully print before sleep

  digitalWrite(PWR_PIN,LOW);
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepDelay(sleepTime); //sleep for: sleepTime
 
  delay(100); ////delays are just for serial print, without serial they can be removed
  Serial.println("Awaked... ");
 digitalWrite(PWR_PIN,HIGH);

}