Triac or ssr to control boiler resistance for photovoltaic self-consumption

I ask for help to build a unit that helps in the self-consumption of photovoltaics, I don’t know where to start …
on the net we talk about triac or ssr and let pass half-waves.
help me

@Massimotruglio83 you are looking for help in the wrong forum. if you need any help with cayenne, then you can ask here.

forgive me, I think a forum is for exchanging ideas, anyway dusting off my electrotechnics books I took a 40A SSR relay ( Brumfield / SSR-240D25 / PB545-ND / 678,179? utm_adgroup = & mkwid = s5qZaWcqt & pcrid = 315874699131 & pkw = & pmt = & pdv = c & productid = 678179 && gclid = Cj0KCQjwpsLkBRDpARIsAKoYI8zXJ4WPKopkW8jrYAnhjJIpyFunGYuNT3td_g-5DeeuDWIqgoo3ZPAaAhUwEALw_wcB), I just have to create the code, but on the net there a few things, I hope to do in weekend

yup, but there are many other forum that specialises in their respective field where you can find more help. anything related cayenne we are here to help.

how can I connect two devices with cayenne and exchange data in order to manage the automatisms?

are you familer with node-red?


anyways, based on @spacefolder code, i modified to subscribe to other device topic .

  MQTT Raw Data to Cayenne Dashboard,
  using the great Nick O'Leary's PubSubClient
  (Arduino Client for MQTT,
  What does it do?
  This sketch will attempt to connect to Cayenne MQTT server via Wifi,
  subscribe to a "dashboard button" topic, to turn on/off the esp8266 built in led.
  Also it will publish temperature readings from a Dallas DS18b20 digital temperature sensor.
  In a near future, the esp8266 (NodeMCU v2) should act as a smart thermostat, controlling my central heater/boiler.
  It should be possible to remotely check ambient temperature and boiler status using
  Cayenne Dashboard and turn the heater on/off (in case I left home in a hurry!, etc.)
  Inspired in several tutorials and sketches mashed up, mainly..
  Andreas Spiess
  Terry King
  Markus Ulsass
  Marc / spacefolder

// ---------- INLCUDE LIBRARIES ----------

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// ---------- DEFINE CONSTANT VALUES ----------

#define MQTT_SERVER     ""
#define MQTT_SERVERPORT 1883
#define MQTT_USERNAME   ""
#define MQTT_PASSWORD   ""
#define CLIENT_ID       ""

#define CLIENT_ID_SUB       ""

#define MQTT_TOPIC_BTN_ONOFF    "v1/" MQTT_USERNAME "/things/" CLIENT_ID_SUB "/data/2"

// ---------- INITIALIZE INSTANCES ----------

WiFiClient    espClient;              // Creates a client instance for the PubSubClient
PubSubClient  client(espClient);

// ---------- DEFINE VARIABLES ----------

const   char* ssid        = ""; // WLAN-SSID (WiFi router)
const   char* password    = ""; // WLAN Password

// Define a datatype to store the mqtt message, up to 50 bytes.
char    msg[50];                 // 50 BYTES QUIZAS SEA MUCHO AL GAS, pero bueh

// -------------------- SETUP -------------------

void setup() {

  // Initialize serial monitor for debugging purposes.
  Serial.println("DEBUG: Entering setup ");

  // Attempt to connect to WiFi.
  WiFi.begin(ssid, password);
  Serial.print("Connecting to ");

  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("");                       // Faltaria agregar que muestre el ip si no es estatico
  Serial.println("WiFi connected");

  // Initialize MQTT PubSub Library
  // Function called in case of an incomming mqtt message from Cayenne Dashboard
  // (In this case is the dashboard button to turn on/off the heater)

  Serial.println("DEBUG: Setup Done! ");


// -------------------- LOOOP -------------------

void loop() {
  // Check if the esp8266 is connected to the mqtt server.
  if (!client.connected()) {

  // If connected, perform PubSubClient housekeeping function.

// ------------------------------ OTHER FUNCTIONS

// Function that attempts to reconnect to the mqtt server.

void reconnect() {
  // If esp8266 is disconnected from the mqtt server, try to reconnect.
  // (*** I still need to think what wil happen to the boiler if connection is lost ***)
  while (!client.connected()) {
    Serial.print("DEBUG: Attempting MQTT connection...");

    // Attempt to connect
    if (client.connect(CLIENT_ID, MQTT_USERNAME, MQTT_PASSWORD)) {

      // Once connected, resubscribe to the Dashboard on/off button topic.

    } else {
      Serial.print("failed, rc=");
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
  Serial.println("DEBUG: Quiting reconnect loop ");

// Function to intercept MQTT messages

void mqttCallback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    // Show the received message "stream" in the serial monitor.
 //  Delay for debugging purposes. If a message arrives from Cayenne, the terminal feed pauses 5'.