Gadget Renesas

Linking Ideas and Electronics

アイテム

GR-PEACH Special Page

Web server part 3

Let’s set up Web camera!

Overview

GR-PEACH can conduct the image processing of the camera. Let us introduce the case using GR-PEACH as a Web camera, with a security digital camera which is commercially available.

login

Preparations

Get ready GR-PEACH, a USB cable (microB type), a LAN cable, a microSD card, a digital camera
and a GR-PEACH AUDIO+CAMERA SHIELD released from CORE CORPORATION.

login
login login

 

How to connect with digital camera

login

 

Sample program for Web camera

First of all, save "index.htm" file in microSD for browser indication.

Click the following link with the right button; and execute “save the object in a file", for download.

index.htm

Next, insert microSD in an SD socket in the back side of GR-PEACH and copy to build the following sketch program in gr_sketch.cpp and write it down into GR-PEACH. 


#include 
#include "SD.h"
#include "HTTPServer.h"
#include "mbed_rpc.h"
#include "Camera.h"
#include "SdUsbConnect.h"

//#define USE_WIFI

#ifdef USE_WIFI
#include "ESP32Interface.h"
ESP32Interface network;
#define WLAN_SSID            ("xxxxxxxx")
#define WLAN_PSK             ("xxxxxxxx")
#define WLAN_SECURITY        NSAPI_SECURITY_WPA_WPA2
#else
#include "EthernetInterface.h"
EthernetInterface network;
#endif

/** Network setting **/
#define USE_DHCP               (1)
#if (USE_DHCP == 0)
#define IP_ADDRESS           ("192.168.11.2")     /* IP address      */
#define SUBNET_MASK          ("255.255.255.0")    /* Subnet mask     */
#define DEFAULT_GATEWAY      ("192.168.11.3")     /* Default gateway */
#endif

Camera camera(320, 240); // default CMOS CAMERA. In case of NTSC, create camera(0).
SdUsbConnect storage("storage");

static int snapshot_req(const char ** pp_data) {
  size_t size = camera.createJpeg();
  *pp_data = (const char*)camera.getJpegAdr();
  return size;
}

void setup(void) {

  Serial.begin(9600);
  Serial.println("********* PROGRAM START ***********");

  // SD & USB
  Serial.print("Finding strage..");
  storage.wait_connect();
  Serial.println("done");

  camera.begin();

  Serial.print("Network Setting up...\r\n");
#if (USE_DHCP == 0)
  network.set_dhcp(false);
  if (network.set_network(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
    Serial.println("Error");
  }
#endif
#ifdef USE_WIFI
  network.set_credentials(WLAN_SSID, WLAN_PSK, WLAN_SECURITY);
#endif
  if (network.connect() != 0) {
    return;
  }

  Serial.print("MAC Address is ");
  Serial.println(network.get_mac_address());
  Serial.print("IP Address is ");
  Serial.println(network.get_ip_address());
  Serial.print("NetMask is ");
  Serial.println(network.get_netmask());
  Serial.print("Gateway Address is ");
  Serial.println(network.get_gateway());
  Serial.println("Network Setup OK\r\n");

  SnapshotHandler::attach_req(&snapshot_req);
  HTTPServerAddHandler("/camera"); //Camera
  FSHandler::mount("/storage", "/");
  HTTPServerAddHandler("/");
  HTTPServerAddHandler("/rpc");
  HTTPServerStart(&network, 80);

}

void loop() {
}

                                
 


Operation check for the Web camera

Operation check for the Web camera After writing the program in GR-PEACH, start serial monitors such as Teraterm, then press a reset button on GR-PEACH.
The IP address acquired by DHCP will be shown up as follows.

login



Put the displayed IP address into the URL on the Web browser.
The camera image will be reflected on the display as following.

login

 


share