Wiznet makers

mvpatel

Published October 30, 2022 © MIT license (MIT)

0 UCC

0 VAR

2 Contests

0 Followers

0 Following

Smart home IoT Hub using WizFi360-EVB-PICO

IoT based home automation system for future smart home using WIZnet WizFi360-EVB-PICO with Various energy harvesting sensors and actuators.

COMPONENTS Hardware components

WIZnet - WizFi360-EVB-Pico

x 1

Main Controller and Cloud connectivity for Smart home Hub


sparkfun - SparkFun Transceiver Breakout - nRF24L01+

x 1

Smarthome IoT hub to actuator wireless connection

Software Apps and online services

Arduino - Arduino IDE

x 1

arduino Ide with Raspberry pi pico add on package https://github.com/earlephilhower/arduino-pico


PROJECT DESCRIPTION

WizFi360-EVB-PICO based Smart home IoT Hub is energy efficient IoT based home automation system hub for future smart home using WIZnet WizFi360-EVB-PICO as heart of the project, it is connected to internet via WiFi connection using MQTT by onboard WIZnet WizFi360 module

Various wireless actuators and EnOcean Energy Harvesting wireless sensors are communicating to WIZnet WizFi360-EVB-PICO using NRF24L01 and EnOcean 868 Transceiver via SPI and UART protocol respectively. 

Received sensor data will be sent to client Android Application via our custom MQTT broker running on Amazon AWS EC2 instance over WiFi by WizFi360-EVB-PICO. Further Android App can trigger the actuators and all sensor data are displayed in mobile app in realtime. Further all sensor data and actuator status will be displayed on 0.96' OLED display interfaced with WizFi360-EVB-PICO over I2C .

before getting into the detailed build log, let's first have a look at video of entire system in action... 

Wizfi360 evb pico based Smart home IoT Hub in Action -

 

Application Overview-

Following components used in the project...

Wizfi360-evb-pico IoT hub

1. WizFi360-EVB-PICO - RP2040 as main processor for HUB and WizFi360 for WiFi connection
2. EnOcean 868 Transceiver - to communicate wireless with enocean energy harvesting sensors
3. nRF24L01 Transceiver - to communicate wireless with nrf24l01 based actuators
4. 0.96 inch OLED Display - to display various sensor reading and actuator status

WizFi360-evb-pico IoT Hub


 

Wireless Sensors - All Enocean Wireless Sensors used in project are battery less sensor modules powered by energy harvesting from either indoor ambient light or mechanical effort applied to press button. This sensor modules operates on 868MHz ISM Band.
1. Wireless Reed switch based magnetic door open/close sensor (EnOcean STM 320 with custom firmware - Ambient light energy harvesting) 
2.  Wireless Temperature and Soil Moisture sensor. (EnOcean STM330 – Ambient light energy harvesting) 
3. Wireless Room Temperature sensor. (EnOcean STM330 – Ambient light energy harvesting) 
4. Wireless Rocker Switch (EnOcean PTM120 - Mechanical energy harvesting) 

Enocean STM320 Reed Switch based Wireless door open/close sensor

Enocean STM330 Wireless Temperature Sensor

Enocean STM330 modified wireless temperature sensor as moisture cum temperature sensor for plant monitoring

 

Enocean PTM 120 wireless rocker switch

 

Wireless Actuators
1. RGB Mood Lighting Wireless Control module. (nRF24l01, neopixel LED strip and MSP430G2553 MCU) this operates on 2.4GHz ISM Band


2. Wireless Relay module to turn on/off 4 appliances. (nRF24L01, 4 relay module and MSP430G2553 MCU) this operates on 2.4GHz ISM Band
 

 

Wizfi360-Evb-Pico smarthome IoT Hub Build-

 

Wiring Diagram -

MQTT Implementation for RP2040 in arduino code is done using Wizfi360 AT commands, here is code snippet for the same,

// WiFi preffered AP Details
const char* ssid = "change_ssid"; // edit with preffered AP SSID
const char* psk  = "change_psk";  // edit with preffered AP PSK

// MQTT Broker and topic details
const char* broker = "your broker"; // edit with preffered MQTT Broker
const int   port = 1883; // edit with preffered MQTT Broker port
const char* pub_topic = "your_publish_topic";   // edit with preffered MQTT Publish topic
const char* sub_topic = "your_subscribe_topic"; // edit with preffered MQTT Subcribe topic

// Setup wifi connection and MQTT broker using WizFi360 AT Commands
void setup_wifi_mqtt_at_wizfi360(void)
{
  Serial2.setTX(4);
  Serial2.setRX(5);
  Serial2.begin(115200);
  delay(2000);
  Serial2.println("AT+RST");
  delay(2000);
  Serial2.println("AT+CWQAP");
  delay(2000);
  serial2_Flush();
  Serial2.println("ATE0");
  delay(1000);
  serial2_Flush();
  Serial2.println("AT+CWMODE=1");
  delay(1000);
  serial2_Flush();
  Serial2.print("AT+CWJAP_CUR=\"");
  Serial2.print(ssid);
  Serial2.print("\",\"");
  Serial2.print(psk);
  Serial2.println("\"");
  delay(5000);
  serial2_Flush();
  Serial2.println("AT+CIFSR");
  delay(500);
  serial2_Flush();
  Serial2.print("AT+MQTTSET=\"");
  Serial2.print(broker);
  Serial2.println("\",\"\",\"wiznet_tewr3\",60");
  delay(3000);
  serial2_Flush();
  Serial2.print("AT+MQTTTOPIC=\"");
  Serial2.print(pub_topic);
  Serial2.print("\",\"");
  Serial2.print(sub_topic);
  Serial2.println("\"");
  delay(3000);
  serial2_Flush();
  Serial2.print("AT+MQTTCON=0,\"");
  Serial2.print(broker);
  Serial2.print("\",");
  Serial2.println(port);
  delay(3000);
  serial2_Flush();
  Serial2.println("AT+MQTTPUB=\"hello mvv\"");
  delay(3000);
  serial2_Flush();
}

on successful Wifi connection and broker connection, message received on subscribed topic is retrieved using custom call back function that need to execute in loop frequently to check for incoming messages,

// MQTT Callback function
void mqtt_at_chk_sub_msg(void) {
  char payload[100];
  uint8_t len = 0;
  uint8_t i = 0;
  while(Serial2.available()>0)
  {
    char xx = Serial2.read(); // if first char is > means its message from sub topic
    if(xx == '>')
    {
      delay(10);
      xx = Serial2.read(); // avoid space after > 
      while(Serial2.available()>0)
      {
      	payload[i] = Serial2.read();
      	i++;
      }
      len = i;

      Serial.print("Received msg from topic - ");
      Serial.print(sub_topic);
      Serial.print(" : ");
      for (int i=0;i<len;i++) {
        Serial.print((char)payload[i]);
      }
      Serial.println();
    }
  }

Publishing message to already configured topic before connecting to broker using AT+MQTTTOPIC command is straight forward and only one command AT+MQTTPUB is required,

Serial2.println("AT+MQTTPUB=\"temperature is 30 C\"");  // for constant string message

char msg_buf[] = "temperature is 30 C";  // For variable message stored in char buf
Serial2.print("AT+MQTTPUB=\"");
Serial2.print(msg_buf);
Serial2.println("\""); 

Complete arduino sketch for WizFi360-evb-pico smart home iot hub with all required header files is attached in this document for reference.

Android MQTT Dashboard -    MQTT Dashboard android App is configured with our Amazon AWS EC2 instance and preferred topics. Widgets for sensor reading display and actuator control is added as shown in following screen shot.

Play store link - https://play.google.com/store/apps/details?id=com.lapetov.mqtt&hl=en_IN&gl=US

 

Documents
  • WizFi360-evb-pico smarthome iot hub arduino sketch

    WizFi360-evb-pico smarthome iot hub arduino sketch with custom header files used for OLED, nrf24l01 tx-rx, enocean receiver

  • Application Overview

    Block diagram showing how Wizfi360-evb-pico smart home iot hub connected to various wireless low power energy harvesting sensors/actuators and to cloud

  • Connection Diagram

    Wiring Diagram of Wizfi360-evb-pico with enocean 868 transceiver , nrf24l01 and 0.96 inch I2C Oled display

Comments Write