Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Renan_ghtNicolas DAILLYSamuel LONCLEfcaronAdrien BRACQ
Created May 26, 2023

Smart House

Imagine a future where your house is not just a place to live, but a smart, intuitive and efficient living space.

60
Smart House

Things used in this project

Hardware components

DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×2
Pressure/Altitude/Temperature Sensor
Adafruit Pressure/Altitude/Temperature Sensor
×3
Cytron Technologies maker nano
×2
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
Central Module Bluetooth 4.0 intégré
×1
DSD TECH HM-10
Module Bluetooth 4.0 Arduino Compatible
×1
DSD TECH HM-18
Module Bluetooth 5.0 Arduino Compatible
×2
SH-BT02A
Bluetooth 4.0 2 Relay
×1
SX1262
Module LoRa pour RaspberryPi
×1
Ks0018
Buzzer Arduino
×1
HC-SR501
Capteur de mouvement Arduino
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
OS of the RaspberryPi 3
ubuntu server
os of the server
Smart House
Experimental Website
API Smarthouse
API Meteo France
Ionic

Story

Read more

Schematics

Schematic of Linky Communication

Kikad project for Linky Communication and Alimentation from Linky

Laser Cutting - Wooden House

file for Laser Cutting

Code Arduino

Only one code for all module depend from config

Mobile App code

Framework Ionic using Vue.JS

Code

Arduino code

C/C++
Only one code for all modules depend from setup, all zip below
#include "Include.h"

// Init sensors define in globals
#ifdef SENSOR_BMP
Sodaq_BMP085 bmp;
#endif

#ifdef SENSOR_DS18B20
OneWire ds18b20Wire(DS18B20_PIN);
DallasTemperature ds18b20(&ds18b20Wire);
#endif

#ifdef SENSOR_LINKY
LinkyHistTIC Linky(10, 11);
uint8_t i;
#endif

// Init communication modules define in globals
#ifdef BLE_HM1X
HM1X_BT hm1x = HM1X_BT();

#ifdef __AVR_ATmega328P__ // Nano
SoftwareSerial hm1xSerial(TX_PIN, RX_PIN);
#endif
#endif

#ifdef BLE_SHIELD
const char* serviceUuid = "19b10000-e8f2-537e-4f6c-d104768a1214";
const char* characteristicUid = "2A19";

BLEService bleService(serviceUuid);
BLEStringCharacteristic bleCharacteristic(characteristicUid, BLEWrite | BLENotify, 100);
#endif

void executeCommand(String data) {
#ifdef DEBUG
  Serial.print("Receive: ");
  Serial.println(data);
#endif

  String command = getCommand(data);

#ifdef HUMIDITY_AVAILABLE
  if (command == "HUMIDITY") {
    commandHumidity();
  }
#endif

#ifdef PRESSURE_AVAILABLE
  if (command == "PRESSURE") {
    commandPressure();
  }
#endif

  if (command == "PING") {
    commandPing();
  }

  if (command == "RELAY") {
    String args = getArgs(data);

    commandRelay(getArgValue(args, 0).toInt(), getArgValue(args, 1));
  }

#ifdef TEMP_AVAILABLE
  if (command == "TEMP") {
    commandTemp();
  }
#endif
}

void loop() {
  String command = "";

#ifdef MODULE_BLE
#ifdef BLE_HM1X
#ifndef SENSOR_LINKY
  command = getBleCommand();

  if (command != "") {
    executeCommand(command);
    clearBleCommand();
  }
#endif /* SENSOR_LINKY */

#ifdef SENSOR_LINKY
  Linky.Update();

  if (Linky.pappIsNew())
  {
#ifdef DEBUG
    Serial << F("Puis. app. = ") << Linky.papp() << F(" VA") << endl;
#endif
    sendData("APP+" + String(Linky.papp()));
  }

#ifdef LKY_Base
  if (Linky.baseIsNew())
  {
#ifdef DEBUG
    Serial << F("Index base = ") << Linky.base() << F(" Wh") << endl;
#endif
    sendData("INDEX+" + String(Linky.base()));
  }
#endif /* LKY_Base */

#ifdef LKY_HPHC
  if (Linky.hchpIsNew())
  {
#ifdef DEBUG
    Serial << F("Index HP = ") << Linky.hchp() << F(" Wh") << endl;
#endif
    sendData("HP+" + String(Linky.hchp()));
  }
  if (Linky.hchcIsNew())
  {
#ifdef DEBUG
    Serial << F("Index HC = ") << Linky.hchc() << F(" Wh") << endl;
#endif
    sendData("HC+" + String(Linky.hchc()));
  }
  if (Linky.ptecIsNew())
  {
#ifdef DEBUG
    Serial << F("Tarif en cours : ");
#endif
    if (Linky.ptec() == Linky.C_HPleines)
    {
#ifdef DEBUG
      Serial << F("heures pleines") << endl;
#endif
      sendData("MODE+HP");
    }
    else
    {
#ifdef DEBUG
      Serial << F("heures creuses") << endl;
#endif
      sendData("MODE+HC");
    }
  }
#endif /* LKY_HPHC */

#ifdef LKY_IMono
  if (Linky.iinstIsNew())
  {
#ifdef DEBUG
    Serial << F("I instant. = ") << Linky.iinst() << F(" A") << endl;
#endif
    sendData("I+" + String(Linky.iinst()));
  }
#endif /* LKY_IMono */

#ifdef LKY_ITri
  for (i = Linky.C_Phase_1; i <= Linky.C_Phase_3; i++)
  {
    if (Linky.iinstIsNew(i))
    {
#ifdef DEBUG
      Serial << F("I Phase ") << i + 1 << F(" = ") << Linky.iinst(i) << F(" A") << endl;
#endif
      sendData("I" + i + "+" + String(Linky.iinst(i)));
    }
  }
#endif /* LKY_ITri */
#endif /* SENSOR_LINKY */
#endif /* BLE_HM1X */

#ifdef BLE_SHIELD
  BLEDevice central = BLE.central();

  delay(500);

  if (central) {
#ifdef DEBUG
    Serial.println("* Connected to central device!");
    Serial.print("* Device MAC address: ");
    Serial.println(central.address());
#endif /* DEBUG */

    while (central.connected()) {
      command = getBleCommand();
      if (command != "") {
        executeCommand(command);
        clearBleCommand();
      }
    }

#ifdef DEBUG
    Serial.println("* Disconnected!");
#endif /* DEBUG */
  }
#endif /* BLE_SHIELD */
#endif /* MODULE_BLE */
} /* loop */

void setup() {
#ifdef DEBUG
  Serial.begin(9600);
  while (!Serial);

  delay(1000);

  Serial.println("Starting..");
#endif

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

#ifdef MODULE_BLE
  setupBle();
#endif

  setupSensors();
  setupSlots();

  digitalWrite(LED_BUILTIN, HIGH);

#ifdef DEBUG
  Serial.println("Started!");
#endif
}

void setupSensors() {
  // BMP
#ifdef SENSOR_BMP
  bmp.begin();
#endif

  // DHT
#ifdef SENSOR_DHT
  pinMode(DHT_PIN, INPUT_PULLUP);
#endif

  // DS18B20
#ifdef SENSOR_DS18B20
  ds18b20.begin();
#endif

  // Linky
#ifdef SENSOR_LINKY
  Serial.println("Init");
  Linky.Init();
#endif
}

void setupSlots() {
  pinMode(SLOT_1, OUTPUT);
  pinMode(SLOT_2, OUTPUT);
  pinMode(SLOT_3, OUTPUT);

  digitalWrite(SLOT_1, LOW);
  digitalWrite(SLOT_2, LOW);
  digitalWrite(SLOT_3, LOW);
}

Credits

Renan_ght
1 project • 0 followers
Contact
Nicolas DAILLY
33 projects • 21 followers
Associated Professor at UniLaSalle - Amiens / Head of the Computer Network Department / Teach Computer and Telecommunication Networks
Contact
Samuel LONCLE
1 project • 0 followers
Contact
fcaron
15 projects • 3 followers
Contact
Adrien BRACQ
0 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.