Project tutorial
WIZnet Interior Sensor Board

WIZnet Interior Sensor Board © CC BY-SA

Board for sensing voltage /current air temperature and motion via I2C and being sent to Librato for monitoring.

  • 568 views
  • 0 comments
  • 0 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Tarantula

Apps and online services

About this project

Here is a simple setup for monitoring inputs from an Arduino to the cloud using a WIZnet Serial to Ethernet adapter and Node-RED to split the messages up and sending it to ThingSpeak where it can be monitored and controlled from anywhere in the world.

By using this device, I discovered yet another way to send data without MQTT which is really interesting... You can use just about any Arduino/ESP device to send data to the cloud using the WIZnet as long as it has a TX/RX port. The WIZnet device can be used for setting up and Arduino based home automation system without the use of wireless devices and complicated code... If you have a serial.Write in the Code you can send it via Ethernet..

There are five components to this project:

  • Setting up the WIZnet device
  • Arduino voltage/current/temperature/accelerometer board design and soldering
  • Arduino hookups
  • Node-RED setup
  • 3D-printed box for the devices

1. Setting Up the WIZnet Device

First power up the WIZnet using 3.3V DC and Ground to the pins shown below. Plug in an Ethernet cable preferably Cat5e or Cat6. Look for lights then go to your computer and do the following:

I used the WIZnet SE2 configuration Program and set the Ip allocation to DHCP then pressed “Setting“ I did another search and it came up a the Following IP address 192.168.1.71

Next was the Serial setup. I used "TCP Mixed." Local port 5000 and the remote IP is The IP of the WIZnet device. I don't have a screen shot Program installed so I have to rely on Pictures for this Part from my PC.

ThingSpeak.com Output

2. Arduino Power Shield and Wiring Hookups

I soldered the female and male pins together and intend to tape the connections up to prevent short circuits. The Power Shield Board is my brainchild and am very proud of it..It is capable of providing power to the ARDUINO and the WIZnet all the while sending data ..There is an on board DS18B20 temperature sensor as well as an I2C Accelerometer. sending XYZ co-ordinates and 2 Controllable Relays ..

The images below are of the Arduino shield. The first image is of the original one that is shown in the photos. The second one is a revamped design. I've added a higher amperage and higher voltage regulator. The first voltage regulator is good for 300mA maximum 18 volts DC and the second is good for 1.5 Amps and 30VDC which is more in line with powering off of a larger 24 volt solar array.

I also moved the screw connectors forward and gave myself more space as it was tight fitting the relay screw connectors into their place. I also thickened up the relay PCB connections to take up to 5 amps comfortably.

Tip #1: When soldering the SMD parts... Solder your SMD parts first

* when using solder as opposed to solder paste solder 1 pad place your part heat the solder and let cool before moving your tweezers

* when cooled solder the other side optimum temp for this process is 300 degrees

Tip#2: Buy some low temp solder paste for the power chip and deposit 2 thin lines across the pads. *See pictures put the Board in a small oven at 350 degrees until you see the paste turn to solder... Remove and check board before it cools. Keep an eye on the process!

Simple Wiring

  • Red +3.3 VDC
  • Black GND
  • Yellow RX-TX
  • Orange TX-RX

3. Node-Red

4. 3D Printing Your Enclosure

I made the box fairly tall to accommodate more wiring and sensors in the future...

I am attaching a Slicer file opened with [UltiMaker Cura]

Code

Simple TX RX Code with DS181 TEmperature SensorClojure
/*
  Software serial multple serial test

 Receives from the hardware serial, sends to software serial.
 Receives from software serial, sends to hardware serial.

 The circuit:
 * RX is digital pin 10 (connect to TX of other device)
 * TX is digital pin 11 (connect to RX of other device)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo and Micro support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created back in the mists of time
 modified 25 May 2012
 by Tom Igoe
 based on Mikal Hart's example

 This example code is in the public domain.

 */
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DS18B20.h>
SoftwareSerial mySerial(10, 11); // RX, TX
// 1-Wire devices connected to digital pin 2 on the Arduino.
DS18B20 ds(2);
int temp;
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // Print number of devices on the bus.
  Serial.print("Devices: ");
  Serial.println(ds.getNumberOfDevices());
  Serial.println();
  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
 // mySerial.println("Hello, world?");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
     // Iterate through all devices.
  while(ds.selectNext())
  {
    // Print family name.
    switch(ds.getFamilyCode())
    {
      case MODEL_DS18S20:
        Serial.println("Model: DS18S20");
        break;
      case MODEL_DS1820:
        Serial.println("Model: DS1820");
        break;
      case MODEL_DS18B20:
        Serial.println("Model: DS18B20");
        break;
      default:
        Serial.println("Unrecognized Device");
        break;
    }
    
    // Print address.
    uint8_t address[8];
    
    ds.getAddress(address);
    
    Serial.print("Address:");
    
    for(uint8_t i = 0; i < 8; i++)
    {
      Serial.print(" ");
      Serial.print(address[i]);
      
    }
    
    Serial.println();
    
    // Print resolution.
    Serial.print("Resolution: ");
    Serial.println(ds.getResolution());
    
    // Print power mode.
    Serial.print("Power Mode: ");
    
    if(ds.getPowerMode())
    {
      Serial.println("External");
    }
    else
    {
      Serial.println("Parasite");
    }
    
    // Print temperature in degrees Celcius and degrees Fahrenheit.
    Serial.print("Temperature: ");
    Serial.print(ds.getTempC());
    Serial.print(" C / ");
    Serial.print(ds.getTempF());
    Serial.println(" F");
    mySerial.print(":");
    mySerial.print(ds.getTempC());
    
    // Print an empty line.
    Serial.println();
  }
  
  // Wait 10 seconds.
  delay(1000);
}
Complicated Arduino Code with I2CC/C++
/*
   LTC2945 Test Code // Part of this code is from
  http://www.kevindarrah.com/wiki/index.php?title=Power_Monitor [[Please give Kevin Darrah a big thumbs up]]

   Copyright 2017, Helium Systems, Inc.
   All Rights Reserved. See LICENCE.txt for license information
   Install the following libraries through Sketch->Manage Libraries:
       - ArduinoJson
       - Helium
*/
#include <OneWire.h>
#include "I2Cdev.h"//(MPU6050)
#include "MPU6050_6Axis_MotionApps20.h"
#include <DS18B20.h>//(Temperature Sensor)
#include<stdio.h>
#define BUFSIZE 9
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
//=================POWER SENSOR================================
#define LTCADDR B1101111//Table 1 both LOW (7bit address)
byte ADCvinMSB, ADCvinLSB, curSenseMSB, curSenseLSB, AinVMSB, AinVLSB;
unsigned int ADCvin, ADCcur, AinV;
float inputVoltage, ADCvoltage, current10, current1, current0p1, current0p01;
//=============//Declare the relay Pins and Values//=============
const int Relay1 = 5;
const int Relay2 = 6;
int sensorValue = 0;
int sensorValue2 = 0;
int sensorValue3 = 0;
//===========Temperature Sensor======================
DS18B20 ds(7);
uint8_t address[] = {40, 250, 31, 218, 4, 0, 0, 52};
uint8_t selected;
//================//Gyroscope
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
#define OUTPUT_READABLE_ACCELGYRO
#define LED_PIN 13
bool blinkState = false;

//====================
int32_t send_interval;
#define LED_PIN 13

void setup() {
  Serial.begin(9600);
  //=======================
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  mySerial.begin(4800);
  mySerial.println("Hello, world?");
  Serial.println("Starting");
  Wire.begin();
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  Wire.begin();
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
  Serial.println("Initializing I2C devices...");
  accelgyro.initialize();
  // verify connection
  Serial.println("Testing device connections...");
  Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
  //==================
  Serial.print("Devices: ");
  Serial.println(ds.getNumberOfDevices());
  Serial.println();
  //=================
  // configure Arduino LED pin for output
  pinMode(LED_PIN, OUTPUT);
  pinMode (Relay1, OUTPUT);
  pinMode (Relay2, OUTPUT);
  digitalWrite(LED_PIN, HIGH);
  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  //==========================


}

void loop() {
  const char data;
  size_t data_used;
  char message[56];
  char msg[56];
  int sensorValue;
  int message1;
  int    status;
  int8_t result;
  int v = (inputVoltage);
  int c = (current0p01);
  int t = (ds.getTempC());
  int m1 = (ax);
  int m2 = (ay);
  int m3 = (az);
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
  //============================================================
  //*************POWER SENSOR***********************
  //===========================================================
  Wire.beginTransmission(LTCADDR);//first get Input Voltage - 30V max
  Wire.write(0x1E);
  Wire.endTransmission(false);
  Wire.requestFrom(LTCADDR, 2, true);
  delay(1);
  ADCvinMSB = Wire.read();
  ADCvinLSB = Wire.read();
  ADCvin = ((unsigned int)(ADCvinMSB) << 4) + ((ADCvinLSB >> 4) & 0x0F);//formats into 12bit integer
  inputVoltage = ADCvin * 0.025; //25mV resolution
  Wire.beginTransmission(LTCADDR);//get ADC Input 2V max
  Wire.write(0x28);
  Wire.endTransmission(false);
  Wire.requestFrom(LTCADDR, 2, true);
  delay(1);
  AinVMSB = Wire.read();
  AinVLSB = Wire.read();
  AinV = ((unsigned int)(AinVMSB) << 4) + ((AinVLSB >> 4) & 0x0F);//12 bit format
  ADCvoltage = AinV * 0.5E-3; //500uV resolution
  Wire.beginTransmission(LTCADDR);//get sense current
  Wire.write(0x14);
  Wire.endTransmission(false);
  Wire.requestFrom(LTCADDR, 2, true);
  delay(1);
  curSenseMSB = Wire.read();
  curSenseLSB = Wire.read();
  ADCcur = ((unsigned int)(curSenseMSB) << 4) + ((curSenseLSB >> 4) & 0x0F);//12 bit format
  current0p1 = ADCcur * (25E-3) / 0.1; //1A max, unit is mA
  Serial.print("Volts_");
  Serial.println(inputVoltage);
  mySerial.write("V %2f",inputVoltage);
  Serial.print("Amps_");
  Serial.println(current0p01, 2);
  mySerial.write("A %2f",current0p01);
  delay(1000);
  //======================================
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
    // display tab-separated accel/gyro x/y/z values
#ifdef OUTPUT_READABLE_ACCELGYRO
  Serial.print("a/g:\t");
  Serial.print(ax); Serial.print("\t");
  mySerial.write("X %2f",(ax));
  Serial.print(ay); Serial.print("\t");
  Serial.println(az); Serial.print("\t");

#endif
  delay(5000);
  //==========================================
  while (ds.selectNext())
  {
    switch (ds.getFamilyCode())
      // Print address.
      uint8_t address[8];
    ds.getAddress(address);
    for (uint8_t i = 0; i < 8; i++)
      (ds.getResolution());
    Serial.print(ds.getTempC());
    mySerial.write("T %2f",ds.getTempC());
    Serial.print(" C / ");
    Serial.print(ds.getTempF()); 
    Serial.println(" F");
    sensorValue = ds.getTempC();
    //==================
    sprintf(data, 75, "V %d:A %d:T %d:X %d:Y %d:Z %d", v, c, t, m1, m2, m3); //NOTE: The values V,A,T,X,Y,Z are needed for the next step
    Serial.println(data);
    mySerial.write(data);
    delay(5000);

  }
  //==================================
  //*************RELAY CONTROL******************
  //=================================
int reading1; 
  reading1 = (ds.getTempC());

  if ( reading1 <= "25") {
    digitalWrite(Relay1, LOW);
    Serial.println("FAN_ON");
  }
  else {
    digitalWrite(Relay1, HIGH);
    Serial.println("FAN_Off");
    delay(1);// delay in between reads for stability
  }

}

Custom parts and enclosures

Ultimaker Cura
Download and install Cura
Ultimaker Cura
Download and Install Cura Save to SD Card and Print

Schematics

Arduino Hookup For Serial
Arduino wiznet twj9qv14jb

Comments

Similar projects you might like

Helium Solar Monitoring Board with Relays

Project tutorial by Jade Perreault

  • 3,706 views
  • 2 comments
  • 18 respects

WIZnet S2E Light Control

Project tutorial by Team S2ELighting

  • 1,449 views
  • 0 comments
  • 7 respects

Ultrasonic Sensor with Alarm, LCD and Temperature

Project tutorial by MichDragstar

  • 4,658 views
  • 7 comments
  • 19 respects

Touch Sensor and Sound Sensor Controlling AC/DC Lights

Project showcase by Anbumachi

  • 1,161 views
  • 2 comments
  • 5 respects

Soil Moisture Sensor With LCD Display

Project tutorial by Patel Darshil

  • 19,368 views
  • 4 comments
  • 37 respects

WIZnet S2E Deadbolts

Project tutorial by S2E Lock

  • 3,210 views
  • 0 comments
  • 9 respects
Add projectSign up / Login