레이블이 UDP인 게시물을 표시합니다. 모든 게시물 표시
레이블이 UDP인 게시물을 표시합니다. 모든 게시물 표시

2015년 7월 6일 월요일

UdpNtpClient

UDP NTP Client

NTP

*Network Time Protocol - wikipedia
NTP

*참조:https://blog.cloudflare.com/understanding-and-mitigating-ntp-based-ddos-attacks/

Do UdpNtpClient

  1. Import Program NTPClinet_HelloWorld: “http://developer.mbed.org/users/embeddist/code/UdpNtpClient/
    2015-07-06_15-22-24

  2. if same program is existed, Import Name of NTPClinet_HelloWorld will be changed(2).
    2015-07-06_15-23-39

  3. Remove mbed-rtos and EthernetInterface

    • Remove mbe-rtos
      2015-07-06_15-25-15
    • Remove EethernetInterface
      2015-07-06_15-25-25
    • Directory after removing mbed-rtos & EthernetInterface
      2015-07-06_15-26-46
  4. Import WIZnetInterface”https://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/"(1)
    2015-07-06_15-28-12

  5. Dirctory for UdpNtpClient
    2015-07-06_15-29-11

  6. Make Codes: porting to WIZnetInterface from EthernetInterface

    • Add arrange for MAC address, call init(mac_addr) for initialing ethernet class.
      2015-07-06_15-47-20
  7. UDP APIs in WIZnetInterface

    • NTPClient.cpp\Bind() in UDP
      2015-07-06_15-55-19

    • NTPClient.cpp\sendTo(): send in UDP
      2015-07-06_15-52-14

    • NTPClient.cpp\receiveFrom(): recv in UDP
      2015-07-06_15-52-41

    • NTPClient.cpp\Close() in UDP
      2015-07-06_15-54-43

  8. Confirm packets by WireShark

    • NTP version 4, clinet
      2015-07-06_17-15-36
    • NTP version 4, server
      2015-07-06_17-15-50

Code Repository

I will update…

Ref. Code

#include "mbed.h"
#include "EthernetInterface.h"
#include "NTPClient.h"

EthernetInterface eth;
NTPClient ntp;

int main() 
{
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x01, 0x02, 0x03};

    //eth.init(); //Use DHCP
    eth.init(mac_addr); //Use DHCP

    eth.connect();

    printf("Trying to update time...\r\n");
    //if (ntp.setTime("0.pool.ntp.org") == 0)
    if (ntp.setTime("jp.pool.ntp.org") == 0)
    {
      printf("Set time successfully\r\n");
      time_t ctTime;
      ctTime = time(NULL);
      printf("Time is set to (UTC): %s\r\n", ctime(&ctTime));
    }
    else
    {
      printf("Error\r\n");
    } 

    eth.disconnect();  

    while(1) {
    }
}

2014년 12월 22일 월요일

An Simple IoT example - connected CO2 Sensor with WIZ550S2E

WIZ5500S2E and S-300

This IoT example shows how to connect CO2 sensor to your ethernet network, and how to send sensing data by using Serial-to-Ethernet gateway module as UDP client. Using S-to-E gatewat module, your device does not need any additional codes and hardware requried.

In this example, WIZ550S2E-232 as a S-to-E module and S-300 as a CO2 sonsor module are used.


  • WIZ550S2E-232: This module is a gateway module that converts RS-232 protocol into TCP/IP protocol and enables remote gauging, remote management of the device through the network based on the Ethernet and the TCP/IP by connecting to existing equipment with RS-232 serial interface.


  • S-300: This SO2 (Carbon Dioxide) sensor module designed by ELT (http://eltsensor.co.kr/) and has available output with TTL-UART for sampling interval of about 3 seconds .




Block Diagram and Network Configurations




  • This figure is shown the block diagram and network configurations for this project.


    • IoT Sensor Node is made up as follows


      • S-to-E : WIZ550S2E-232

      • CO2 Sonsor : S-300

      • UDP Client embedded on S-to-E


    • Monitoring Server is composed as follows


      • UDP server : Hercules (TCP/IP utils) on PC




    Diagram


  • Serial-to-Ethernet Module : WIZ550S2E-232

    WIZ550S2E-232


    • Gateway module that converts RS-232 protocol into TCP/IP protocol

    • Serial to Ethernet Module based on W5500 & Cortex-M0

    • RJ-45 mounted, Pin-header type module

    • Serial signals : TXD, RXD, RTS, CTS, GND

    • Support the configuration method of AT command & Configuration tool program

    • Configuration tool program operates on Windows, Linux & MAC OS

    • Support the interface board for RS-232 and RS422/485

    • 10/100Mbps Ethernet & Max.230kbps serial speed

    • Support WIZ VSP (Virtual Serial Port) program

    • Dimension (mm) : 55(L) x 30 (W) x 23.49 (H)


  • Co2 Sensor: ELT Sensor : S-300

    S-300


    • Non-Dispersive Infrared (NDIR) technology used to measure CO₂levels.

    • Pre-calibrated

    • Available outputs : TTL-UART, I2C, ALARM, PWM/Analog Voltage.

    • Gold-plated sensor provides long-term calibration stability.

    • Installed re-calibration function

    • Operate as ACDL mode (Automatic Calibration in Dimming Light mode).

    • Manual Re-Calibration function is executable.

    • ROHS Directive- 2011/65/EU,[EN50581 : 2012,IEC 62321-3-1 : 2013]

    • Size : 33mmx33mmx13.1mm

    • Weight : 10 grams




Hardware connections



Three lines as below the may be connected for Sensor node.
The TXD in S-300 and RXD in WIZ550S2E should be connected together.


























WIZ550S2E Direction S-300 JIG
RXD <--- TXD
VCC(baseboard) <--- VCC (5V)
GND GND



  • WIZ550S2E

    WIZ550S2E Pin Maps


  • S-300 JIG

    JIG S-300 Pin Maps




Software




  • WIZ550S2E Side: Sensor Node



    WIZ550S2E Configuration


  • PC tools: Monitoring Server


    • Herdules


      > Hercules SETUP utility is useful serial port terminal (RS-485 or RS-232 terminal) , UDP/IP terminal and TCP/IP Client Server terminal. It was created for HW group internal use only, but today it's includes many functions in one utility and it's Freeware! With our original devices (Serial/Ethernet Converter, RS-232/Ethernet Buffer or I/O Controller) it can be used for the UDP Config.

    • Hercules download : version3.2.8


    • Hercules user guide : User Guide



    Hercules




Setting





Excuting




  • UART frame of S-300

    S-300 output frame in UART


  • CO2 Data received from the Sensor node

    C02 Data received form Sensor node


  • CO2 Data shown in text format

    text type


  • CO2 Data shown in Hex format

    Hex type