jassak
Published © GPL3+

Sigfox kWh Meter

What if our old electric energy power meter with rotary disk could be connected to the Internet?

IntermediateFull instructions provided2 hours10,718
Sigfox kWh Meter

Things used in this project

Hardware components

Arduino MKR Fox 1200
Arduino MKR Fox 1200
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
CNY70
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
LED (generic)
LED (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Sigfox
Sigfox
ThingSpeak API
ThingSpeak API

Story

Read more

Schematics

Sigfox kWh electric energy power meter

Schematic for connection of MKRFOX1200 with CNY70 and other stuff.

Code

Sigfox kWh electric energy power meter

Arduino
This is .ino code for making your power meter intelligent.
#include <SigFox.h>

int DIODE = 13;
int BTN = 12;
int BTN_state = 0;
int BTN_prev = 0;
int BTN_NR_OF_PRESS = 0;
int CALC = 0;
unsigned long i = 0;
uint32_t CONSUMPTION = 0;
boolean SHINE = false;
boolean KARDAN = false;


void setup() {

  pinMode(DIODE, OUTPUT);
  pinMode(BTN, INPUT);
  Serial.begin(9600);
  if (!SigFox.begin()) {
    Serial.println("Sigfox module unavailable.");
  }

}

void loop() {


  int senzor = analogRead(A3);


  BTN_state = digitalRead(BTN);

  if (BTN_state != BTN_prev) {
    if (BTN_state == HIGH) {
      BTN_NR_OF_PRESS++;
    }
  }

  BTN_prev = BTN_state;

  if (BTN_NR_OF_PRESS % 3 == 0) {

    if (senzor > 300 && senzor < 950) {
      digitalWrite(DIODE, HIGH);
    }
    else {
      digitalWrite(DIODE, LOW);
    }
  }




  if (senzor < 1020 && SHINE == false)
  {
    SHINE = true;

  }
  if (senzor > 1020 && SHINE == true && BTN_NR_OF_PRESS == 4)
  {
    CALC++;
    SHINE = false;


  }
  if (CALC % 3 == 0 && CALC != 0 && KARDAN == false)
  {
    KARDAN = true;
    CONSUMPTION += 25;
  }
  if (CALC % 3 != 0) {
    KARDAN = false;
  }

  if (BTN_NR_OF_PRESS % 4 == 0) {
    digitalWrite(DIODE, LOW);


    if (SHINE == false)

    {



      for (millis(); (millis() - i) > 1800000;) {
        i = millis();
        SigFox.debug();
        SigFox.beginPacket();
        SigFox.write(CONSUMPTION);
        SigFox.endPacket();
      }

    }
  }


}

Credits

jassak

jassak

2 projects • 11 followers
UNi Student

Comments