M5NanoC6、無線シリアルで送られた文字列をSSD1306に表示する。ESP_NOW_Serial_Class




x 過去ログを見よ!!
x インサーネットフレームの意味が分かる人
x mac addの意味がわかる人
x mac addの宛先と自分がわかる人
x mac addの宛先を書き換えられる人
x インターネット老人会の人
x なぜかUSBシリアルの起動が失敗するので起動画面が出るまでターミナルをオンオフする
x 3.0.7

ここを都合よく書き換える


```c++

//ここは、相手先のMACアドレスを記述する。
// Set the MAC address of the device that will receive the data
// For example: XX:XX:XX:XX:XX:XX
const MacAddress peer_mac({0x48, 0x27, 0xE2, 0xE3, 0xBD, 0x50});
//const MacAddress peer_mac({0x40, 0x4C, 0xCA, 0x5A, 0xE3, 0x1C});


```

結果

![o_coq593.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/4dd272c8-94a1-c37b-3e7a-b17898460ecf.jpeg)

![o_coq594.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/bddcfaca-e484-8894-b3de-35e538c50876.jpeg)

![o_coq595.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/2d90e05b-0e53-bd70-56c0-9e5e1f84a6e5.jpeg)

![o_coq596.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/f2cf5c9e-c300-f32c-0f94-04edaaabb61f.jpeg)


プログラム


NanoC6(SSD1306 OLED)


```c++


//秋月のOLEDとアイテンドウのOLEDのアドレスは3C
//ESP_NOW_Serial_SSD1306_M5NanoC6_2


//インクルド
#include <Arduino.h>
#include <Wire.h>
#include "kanji1.h"

//rrrrrrrrrrrrrrrrrrrrrrrrrrrrr

#include "ESP32_NOW_Serial.h"
#include "MacAddress.h"
#include "WiFi.h"
#include "esp_wifi.h"


//rrrrrrrrrrrrrrrrrrrrrrrrrrrrr

//定義
#define MAX_PAGE                   (7)
#define MAX_COL                    (127)

#define COMMAND_MODE               0x80 // continuation bit is set!
#define DATA_MODE                  0x40

#define SET_COLUMN_ADDRESS         0x21 // takes two bytes, start address and end address of display data RAM
#define SET_PAGE_ADDRESS           0x22 // takes two bytes, start address and end address of display data RAM

#define SET_MEMORY_ADDRESSING_MODE 0x20 // takes one byte as given above
#define HORIZONTAL_ADDRESSING_MODE 0x00

//rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr


// Channel to be used by the ESP-NOW protocol
#define ESPNOW_WIFI_CHANNEL 1
#define ESPNOW_WIFI_MODE WIFI_STA     // WiFi Mode
#define ESPNOW_WIFI_IF   WIFI_IF_STA  // WiFi Interface

//ここは、相手先のMACアドレスを記述する。
// Set the MAC address of the device that will receive the data
// For example: XX:XX:XX:XX:XX:XX
const MacAddress peer_mac({0x48, 0x27, 0xE2, 0xE3, 0xBD, 0x50});
//const MacAddress peer_mac({0x40, 0x4C, 0xCA, 0x5A, 0xE3, 0x1C});

//無線のシリアル
ESP_NOW_Serial_Class NowSerial(peer_mac, ESPNOW_WIFI_CHANNEL, ESPNOW_WIFI_IF);



//rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr



//I2Cに配列を転送する
void write_s(uint8_t *str1, uint8_t len1) {

  Wire.beginTransmission(  0x3c  );

  for (int ii = 0; ii < len1; ii++) {

    //一文字出力
    Wire.write(*str1 ++);

  }//for

  Wire.endTransmission();

}//write_s


//セットページアドレス
void setPageAddress(uint8_t start, uint8_t end)
{
  uint8_t databytes[6] = {COMMAND_MODE, SET_PAGE_ADDRESS, COMMAND_MODE, start, COMMAND_MODE, end};
  write_s(databytes, 6);
}//setPageAddress


//セットカラムアクセス
void setColumnAddress(uint8_t start, uint8_t end)
{
  uint8_t databytes[6] = {COMMAND_MODE, SET_COLUMN_ADDRESS, COMMAND_MODE, start, COMMAND_MODE, end};
  write_s(databytes, 6);
}//setColumnAddress


//セットメモリーアドレシングモード
void setMemoryAddressingMode()
{
  uint8_t databytes[4] = {COMMAND_MODE, SET_MEMORY_ADDRESSING_MODE, COMMAND_MODE, HORIZONTAL_ADDRESSING_MODE};
  write_s(databytes, 4);
}//setMemoryAddressingMode

//8バイト分まとめて出力
void put8byte(int qq) {

  //データの配列の定義
  static uint8_t databytes[9] = {DATA_MODE, 0, 0, 0, 0, 0, 0, 0, 0};

  static int byte_count = 1;

  databytes[byte_count] = qq;
  byte_count++;

  if ( byte_count > 8 ) { //8バイト分、貯まったら
    write_s(databytes, 9);
    byte_count = 1;
  } // endif

} //put8byte


//ドットを打つ
void Dot(int x, int y, int c) {

  static int b_count = 0; //ビットカウント
  static int qq = 0;      //一時

  qq = qq | ( c << b_count);

  b_count++;

  if ( b_count > 7 ) { //1バイト分、貯まったら

    put8byte(qq); //SSD1306に出力

    qq = 0;
    b_count = 0;

  }//end if

}//DOt


//キャラクターRAMの内容
unsigned char st_p[4][8] = {
  //1    2    3    4    5    6    7    8
  {'N', 'o', '_', 'V', 'R', 'A', 'M', '.'  }, //1
  {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'  }, //2
  {'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R'  }, //3
  {'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b'  }  //4
};

//再表示
void display(void) {

  int y; int x;
  int a; int ch;

  //範囲の設定 (OLED内部のx,yカウンターを初期化してホームポジション0,0に)
  setPageAddress(0, MAX_PAGE);  // all pages
  setColumnAddress(0, MAX_COL); // all columns

  for (int ii = 0; ii < 8192; ii++) {

    //SSD1306のバッファーの配置順のxとyを求める
    y = ((ii & 0b0001110000000000 ) >> 7) + ( ii & 0b0111);
    x =  (ii & 0b0000001111111000) >> 3;

    //↓開始　16ビット漢字のメイン処理
    ch = st_p[y >> 4][x >> 4] - ' ';     //キャラクターRAMから漢字を求める
    //座標と漢字からキャラクターパターンを求める
    a = pgm_read_word_near( ch_data7 + (y & 0x0f ) + ( ch << 4 ) ) << ( x & 0x0f);
    a = a & 0x8000;
    //↑終了

    if (a != 0) {
      Dot(x, y, 1); //白のドットを打つ
    } else {
      Dot(x, y, 0); //黒のドットを打つ
    }//end if

  }//for ii

}//display


//SSD1306の初期化
void display_begin(void) {

  //I2Cの初期化
  Wire.begin(); //M5Stamp S3
  delay(200);
  Wire.setClock(2000000); //速度の変更 (I2C高速化 2Mhz)
  delay(200);

  //SSD1306の初期化スペル(魔法)
  //0x80,0x8D,0x80,0x14,0x80,0xAF
  write_s( (uint8_t*) "\200\215\200\024\200\257", 6);
  delay(100);

  //セットメモリーアドレシングモード (画面の終端に来たら画面の先頭に)
  setMemoryAddressingMode();

}//display_begin


unsigned char *lop = st_p[0];

int kanji16_printf(char* fmt, ...) {
  char buff[256];
  va_list args;
  va_start(args, fmt);
  int return_status = vsnprintf(buff, sizeof(buff), fmt, args);
  va_end(args);
  char *s = buff;

  while ( (*s) != 0 ) {
    (*lop++) = (*s++);
  }//while

  return return_status;
}//ns_printf


void kanji16_locate(int x, int y) {

  lop = &(st_p[y][x]);

}//kanji16_locate


void kinji16_cls(void) {
  //0
  st_p[0][0] = ' '; st_p[0][1] = ' '; st_p[0][2] = ' '; st_p[0][3] = ' ';
  st_p[0][4] = ' '; st_p[0][5] = ' '; st_p[0][6] = ' '; st_p[0][7] = ' ';
  //1
  st_p[1][0] = ' '; st_p[1][1] = ' '; st_p[1][2] = ' '; st_p[1][3] = ' ';
  st_p[1][4] = ' '; st_p[1][5] = ' '; st_p[1][6] = ' '; st_p[1][7] = ' ';
  //2
  st_p[2][0] = ' '; st_p[2][1] = ' '; st_p[2][2] = ' '; st_p[2][3] = ' ';
  st_p[2][4] = ' '; st_p[2][5] = ' '; st_p[2][6] = ' '; st_p[2][7] = ' ';
  //3
  st_p[3][0] = ' '; st_p[3][1] = ' '; st_p[3][2] = ' '; st_p[3][3] = ' ';
  st_p[3][4] = ' '; st_p[3][5] = ' '; st_p[3][6] = ' '; st_p[3][7] = ' ';
}//kinji16_cls


void kinji16_cls_y(int y) {

  st_p[y][0] = ' '; st_p[y][1] = ' '; st_p[y][2] = ' '; st_p[y][3] = ' ';
  st_p[y][4] = ' '; st_p[y][5] = ' '; st_p[y][6] = ' '; st_p[y][7] = ' ';

}//kinji16_cls_y

//SSD1306に一文字を書き込む
void kinji16_ch(char ch) {

  //Serial.print(ch);
  
  static int BY = 0;
  
  if( ch == 11 ){ //ホームポジション
    lop = st_p[0];
    BY=0;
  } else if(ch == 12 ) { //クリア
    lop = st_p[0];
    kinji16_cls();
    BY=0;
  } else if(ch == 10 ) { //リターン
    BY++;
    if(BY > 3){BY = 0;}
    lop = st_p[BY];
    kinji16_cls_y(BY);
   } else {
     (*lop++) = ch;
   }//endif
}


//SSD1306に文字列を書き込む
void kinji16_print(char *str1)
{
  //文字の中身がゼロか
  while (*str1) {kinji16_ch(*str1 ++); /*一文字出力*/}
}//now_print



//oooooooooooooooooooooooooooooooooooooooo


//MACを16進に変換
char *mac_add_conv(const uint8_t *a) {

  char h[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  static char b[16 + 1];

  for(int i=0;i<6;i++){
    b[i*2+0] = h[a[i] >> 4];
    b[i*2+1] = h[a[i] & 0x0f];
  }
  b[12] = 0;

  return ( b );
  
}//mac_add_conv


//1文字の送信
void now_ch(char ch) {

  while ( !(NowSerial.availableForWrite()) ) {
    delay(5);//連続送信防止
    Serial.println(".");
  }

  if (NowSerial.write(ch) <= 0) {
    Serial.println("Failed to send data");
  }

}//now_ch


//文字列の送信
void now_print(char *str1)
{
  //文字の中身がゼロか
  while (*str1) {now_ch(*str1 ++); /*一文字出力*/}
}//now_print



//ooooooooooooooooooooooooooooooooooooooooo

//初期化
void setup() {

  //SSD1306の初期化
  display_begin();

  //再表示
  display();delay(1000);

  kinji16_cls();
  kinji16_print("OLED");
  kinji16_ch('\n');//行(10)
  kinji16_ch('\n');//行(10)

  //再表示
  display();

//yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy


  //WiFiモードとWifiチャンネルの設定
  WiFi.mode(ESPNOW_WIFI_MODE);
  WiFi.setChannel(ESPNOW_WIFI_CHANNEL, WIFI_SECOND_CHAN_NONE);

  //シリアルポートの初期化
  Serial.begin(115200);

  //WiFiの起動待ち
  for (int i = 0; i < (6+3); i++) {
    Serial.print(".");
    delay(500); //接続待ち
  }
  while (!(WiFi.STA.started())) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  //WiFiメッセージの表示
  Serial.print("to  MAC Address: " );
  Serial.println( mac_add_conv( peer_mac  ) );
  Serial.print("WiFi Mode: ");
  Serial.println("Station");
  Serial.print("Channel: ");
  Serial.println(ESPNOW_WIFI_CHANNEL);
  Serial.print("MAC Address: ");
  Serial.println(WiFi.macAddress());

  //ESP_NOW_Serialの起動
  // Start the ESP-NOW communication
  Serial.println("ESP-NOW communication starting...");
  NowSerial.begin(115200); //無線シリアル
  Serial.println("You can now send data to the peer device using the Serial Monitor.\n");



//yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

}//setup


//メインループ
void loop() {
  
  static char data[4096+1];
  int str_num = 0;

  str_num = 0;data[0]=0;
  while (NowSerial.available()) {
    //Serial.print("[");
    data[str_num] = NowSerial.read();
    str_num++;
    if( str_num > 4095 ){str_num = 4095;}
    data[str_num] = 0;
    //Serial.print("]");
  }
  //Serial.print("(");
  //Serial.print("(");
  //Serial.print(str_num);
  //Serial.print(")");

  if( str_num != 0 ){
    //Serial.print("-");
    Serial.print(data);
    kinji16_print(data);
    display();//再表示
  }
  
  //Serial.print(")");

  delay(300);
  
  
}//loop


```



kanji1.h




```




//漢字ROM
const int ch_data7[] PROGMEM = {

0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, //' '
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, //!
0x0100, 0x0100, 0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0000, 

0x0000, 0x0120, 0x0240, 0x0480, 0x0900, 0x0000, 0x0000, 0x0000, // "
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0000, 0x0440, 0x0440, 0x0440, 0x1ff0, 0x0440, 0x0440, // #
0x0440, 0x0440, 0x1ff0, 0x0440, 0x0440, 0x0440, 0x0440, 0x0000, 
0x0000, 0x0100, 0x0380, 0x0540, 0x0920, 0x0900, 0x0500, 0x0380, // $
0x0140, 0x0120, 0x0120, 0x0920, 0x0540, 0x0380, 0x0100, 0x0000, 

0x0000, 0x0000, 0x0000, 0x1810, 0x1820, 0x0040, 0x0080, 0x0100, // %
0x0200, 0x0400, 0x0830, 0x1030, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0700, 0x0880, 0x0840, 0x0840, 0x0880, 0x0500, 0x0600, // &
0x0a00, 0x1108, 0x1090, 0x10a0, 0x1040, 0x08a0, 0x0710, 0x0000, 
0x0000, 0x0300, 0x0300, 0x0100, 0x0200, 0x0000, 0x0000, 0x0000, // '
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0080, 0x0100, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, //(
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0100, 0x0080, 0x0000, 
0x0000, 0x0200, 0x0100, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, //)
0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0100, 0x0200, 0x0000, 
0x0000, 0x0000, 0x0000, 0x1010, 0x0820, 0x0440, 0x0280, 0x0100, //*
0x0280, 0x0440, 0x0820, 0x1010, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x1ff0, //+
0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, //,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0180, 0x0180, 0x0200, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1ff0, //-
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, //.
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0x0300, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, // /
0x0200, 0x0400, 0x0800, 0x1000, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x3008, 0x2808, 0x2608, //0
0x2108, 0x20c8, 0x2028, 0x2018, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x0100, 0x0300, 0x0500, 0x0900, 0x0100, 0x0100, 0x0100, //1
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x0fe0, 0x1010, 0x2010, 0x2008, 0x0008, 0x0010, 0x0010, //2
0x00e0, 0x0300, 0x0400, 0x0800, 0x1000, 0x2000, 0x3ff8, 0x0000, 
0x0000, 0x0fe0, 0x1010, 0x2010, 0x2008, 0x0008, 0x0010, 0x03e0, //3
0x0010, 0x0008, 0x0008, 0x2008, 0x2010, 0x1010, 0x0fe0, 0x0000, 
0x0000, 0x0030, 0x0050, 0x0090, 0x0110, 0x0210, 0x0410, 0x0810, //4
0x1010, 0x2010, 0x3ffc, 0x0010, 0x0010, 0x0010, 0x0010, 0x0000, 
0x0000, 0x3ff8, 0x2000, 0x2000, 0x2000, 0x2000, 0x3fc0, 0x0020, //5
0x0010, 0x0008, 0x0008, 0x0008, 0x2010, 0x1020, 0x0fc0, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2000, 0x2000, 0x27c0, 0x2820, //6
0x3010, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x1ff8, 0x0008, 0x0008, 0x0010, 0x0010, 0x0020, 0x0020, //7
0x0040, 0x0040, 0x0040, 0x0080, 0x0080, 0x0100, 0x0100, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x1010, 0x0fe0, //8
0x1010, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2008, 0x1018, //9
0x0828, 0x07c8, 0x0008, 0x0008, 0x1010, 0x0820, 0x07c0, 0x0000,
0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, //:
0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, // ;
0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0200, 0x0400, 0x0000, 

0x0000, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, //<
0x0400, 0x0200, 0x0100, 0x0080, 0x0040, 0x0020, 0x0000, 0x0000, 

0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1ff0, 0x0000, // =
0x0000, 0x1ff0, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0800, 0x0400, 0x0200, 0x0100, 0x0080, 0x0040, 0x0020, //>
0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x0000, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x1010, 0x1010, 0x0010, 0x0020, //?
0x01c0, 0x0100, 0x0100, 0x0100, 0x0000, 0x0100, 0x0100, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2788, 0x2448, 0x2428, 0x2428, //@
0x2428, 0x2428, 0x2428, 0x2428, 0x13f8, 0x0800, 0x07e0, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2008, 0x2008, //A
0x3ff8, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x0000, 
0x0000, 0x3fc0, 0x2020, 0x2010, 0x2008, 0x2010, 0x2020, 0x3fc0, //B
0x2020, 0x2010, 0x2008, 0x2008, 0x2010, 0x2020, 0x3fc0, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2000, 0x2000, //C
0x2000, 0x2000, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x3fc0, 0x2020, 0x2010, 0x2008, 0x2008, 0x2008, 0x2008, //D
0x2008, 0x2008, 0x2008, 0x2008, 0x2010, 0x2020, 0x3fc0, 0x0000, 
0x0000, 0x3ff8, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x3fe0, //E
0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x3ff8, 0x0000, 
0x0000, 0x3ff8, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x3fe0, //F
0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2000, 0x2000, //G
0x20f8, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x3ff8, //H
0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x0000, 
0x0000, 0x1ff0, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, //I
0x0100, 0x0100, 0x0100, 0x0100, 0x1ff0, 0x0000, 0x0000, 0x0000, 
0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, //J
0x0008, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x2008, 0x2030, 0x2040, 0x2180, 0x2200, 0x2c00, 0x3000, //K
0x2800, 0x2600, 0x2100, 0x2080, 0x2060, 0x2010, 0x2008, 0x0000, 
0x0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, //L
0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x3ff8, 0x0000, 
0x0000, 0x2008, 0x3018, 0x2828, 0x2448, 0x2288, 0x2108, 0x2008, //M
0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x0000, 
0x0000, 0x2008, 0x3008, 0x2808, 0x2808, 0x2408, 0x2208, 0x2108, //N
0x2108, 0x2088, 0x2048, 0x2028, 0x2028, 0x2018, 0x2008, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2008, 0x2008, //O
0x2008, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x3fc0, 0x2020, 0x2010, 0x2008, 0x2008, 0x2010, 0x2020, //P
0x3fc0, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0000, 
0x0000, 0x07c0, 0x0820, 0x1010, 0x2008, 0x2008, 0x2008, 0x2008, //Q
0x2008, 0x2008, 0x2088, 0x2048, 0x1028, 0x0810, 0x07e8, 0x0000, 
0x0000, 0x3fc0, 0x2020, 0x2010, 0x2008, 0x2008, 0x2010, 0x2020, //R
0x3fc0, 0x2080, 0x2040, 0x2040, 0x2020, 0x2020, 0x2010, 0x0000, 
0x0000, 0x0fe0, 0x1010, 0x2000, 0x2000, 0x2000, 0x1000, 0x0fe0, //S
0x0010, 0x0008, 0x0008, 0x0008, 0x1008, 0x0810, 0x07e0, 0x0000, 
0x0000, 0x3ff8, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, //T
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, //U
0x2008, 0x2008, 0x2008, 0x2008, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, //V
0x2008, 0x2008, 0x1010, 0x0820, 0x0440, 0x0280, 0x0100, 0x0000, 
0x0000, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, //W
0x2008, 0x2108, 0x2288, 0x2448, 0x2828, 0x3018, 0x2008, 0x0000, 
0x0000, 0x0000, 0x2008, 0x2008, 0x1010, 0x0820, 0x0440, 0x0280, //X
0x0100, 0x0280, 0x0440, 0x0820, 0x1010, 0x2008, 0x2008, 0x0000, 
0x0000, 0x2008, 0x1010, 0x0820, 0x0440, 0x0280, 0x0100, 0x0100, //Y
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0xfff8, 0x0010, 0x0020, 0x0040, 0x0080, 0x0100, 0x0200, //Z
0x0400, 0x0800, 0x1000, 0x2000, 0x4000, 0xfff8, 0x0000, 0x0000, 

0x0000, 0x0380, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, // [
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0380, 0x0000, 
0x0000, 0x1010, 0x0820, 0x0440, 0x0280, 0x0100, 0x0100, 0x0fe0, // ￥
0x0100, 0x0100, 0x0fe0, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x0380, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, // ]
0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0080, 0x0380, 0x0000, 
0x0000, 0x0100, 0x0280, 0x0440, 0x0820, 0x0000, 0x0000, 0x0000, // ^
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, //_
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1ff8, 0x0000, 

0x0000, 0x0400, 0x0200, 0x0100, 0x0080, 0x0040, 0x0000, 0x0000, // `
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 

0x0000, 0x0000, 0x0000, 0x0fc0, 0x0020, 0x0010, 0x0010, 0x07d0, //a
0x0830, 0x1010, 0x1010, 0x1010, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x17c0, 0x1820, //b
0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1020, 0x1fc0, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, //c
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x07d0, 0x0830, //d
0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0810, 0x07f0, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, //e
0x1010, 0x1010, 0x1ff0, 0x1000, 0x1000, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x01c0, 0x0200, 0x0200, 0x0400, 0x0400, 0x1fc0, 0x0400, //f
0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0000, 
0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, 0x1010, 0x1010, 0x1010, //g
0x1010, 0x1010, 0x0830, 0x07d0, 0x0010, 0x0020, 0x0fc0, 0x0000, 
0x0000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, //h
0x1fc0, 0x1020, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 
0x0000, 0x0100, 0x0100, 0x0100, 0x0000, 0x0000, 0x0100, 0x0100, //i
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, //j
0x0010, 0x0010, 0x0010, 0x1010, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x1000, 0x1000, 0x1000, 0x1040, 0x1080, 0x1100, 0x1200, //k
0x1400, 0x1800, 0x1400, 0x1200, 0x1100, 0x1080, 0x1040, 0x0000, 
0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, //l
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3fe0, 0x2110, //m
0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x2108, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1fc0, 0x1020, //n
0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, //o
0x1010, 0x1010, 0x1010, 0x1010, 0x1010, 0x0820, 0x07c0, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, 0x1010, //p
0x1010, 0x1010, 0x1010, 0x1010, 0x1820, 0x17c0, 0x1000, 0x1000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x07c0, 0x0820, 0x1010, //q
0x1010, 0x1010, 0x1010, 0x1010, 0x0830, 0x07d0, 0x0010, 0x0010, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x17c0, 0x1820, //r
0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x1000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x07e0, 0x0800, 0x1000, 0x1000, //s
0x0800, 0x07c0, 0x0020, 0x0010, 0x0010, 0x0020, 0x0fc0, 0x0000, 
0x0000, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x1fe0, 0x0200, //t
0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x0200, 0x01c0, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010, 0x1010, 0x1010, //u
0x1010, 0x1010, 0x1010, 0x1010, 0x0810, 0x0410, 0x03f0, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010, 0x1010, 0x1010, //v
0x1010, 0x1010, 0x1010, 0x0820, 0x0440, 0x0280, 0x0100, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x2008, 0x2008, 0x2008, 0x2008, //w
0x2008, 0x2108, 0x2288, 0x2448, 0x2828, 0x3018, 0x2008, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x2008, 0x1010, 0x0820, 0x0440, //x
0x0280, 0x0100, 0x0280, 0x0440, 0x0820, 0x1010, 0x2008, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x1010, 0x1010, 0x1010, 0x1010, //y
0x0820, 0x0440, 0x0280, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1ff0, 0x0020, //z
0x0040, 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1ff0, 0x0000, 

0x0000, 0x0080, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0200, // {
0x0200, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0080, 0x0000, 
0x0000, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, // |
0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0000, 
0x0000, 0x0200, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0080, // }
0x0080, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0200, 0x0000, 
0x0000, 0x0220, 0x0540, 0x0880, 0x0000, 0x0000, 0x0000, 0x0000, // ~
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, //■
0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc, 0x3ffc 


};


```


StampS3 ハローワールドと出力



```c++



//ESP_NOW_Serial_Hello_M5StampS3_1


//インクルド
#include "ESP32_NOW_Serial.h"
#include "MacAddress.h"
#include "WiFi.h"
#include "esp_wifi.h"


//定義
// Channel to be used by the ESP-NOW protocol
#define ESPNOW_WIFI_CHANNEL 1
#define ESPNOW_WIFI_MODE WIFI_STA     // WiFi Mode
#define ESPNOW_WIFI_IF   WIFI_IF_STA  // WiFi Interface

//ここは、相手先のMACアドレスを記述する。
// Set the MAC address of the device that will receive the data
// For example: XX:XX:XX:XX:XX:XX
//const MacAddress peer_mac({0x48, 0x27, 0xE2, 0xE3, 0xBD, 0x50});
const MacAddress peer_mac({0x40, 0x4C, 0xCA, 0x5A, 0xE3, 0x1C});

//無線のシリアル
ESP_NOW_Serial_Class NowSerial(peer_mac, ESPNOW_WIFI_CHANNEL, ESPNOW_WIFI_IF);


//MACを16進に変換
char *mac_add_conv(const uint8_t *a) {

  char h[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  static char b[16 + 1];

  for(int i=0;i<6;i++){
    b[i*2+0] = h[a[i] >> 4];
    b[i*2+1] = h[a[i] & 0x0f];
  }
  b[12] = 0;

  return ( b );
  
}//mac_add_conv


//1文字の送信
void now_ch(char ch) {

  while ( !(NowSerial.availableForWrite()) ) {
    delay(5);//連続送信防止
    Serial.println(".");
  }

  if (NowSerial.write(ch) <= 0) {
    Serial.println("Failed to send data");
  }

}//now_ch


//文字列の送信
void now_print(char *str1)
{
  //文字の中身がゼロか
  while (*str1) {now_ch(*str1 ++); /*一文字出力*/}
}//now_print


//初期化
void setup() {

  //WiFiモードとWifiチャンネルの設定
  WiFi.mode(ESPNOW_WIFI_MODE);
  WiFi.setChannel(ESPNOW_WIFI_CHANNEL, WIFI_SECOND_CHAN_NONE);

  //シリアルポートの初期化
  Serial.begin(115200);

  //WiFiの起動待ち
  for (int i = 0; i < (6+3); i++) {
    Serial.print(".");
    delay(500); //接続待ち
  }
  while (!(WiFi.STA.started())) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();

  //WiFiメッセージの表示
  Serial.print("to  MAC Address: " );
  Serial.println( mac_add_conv( peer_mac  ) );
  Serial.print("WiFi Mode: ");
  Serial.println("Station");
  Serial.print("Channel: ");
  Serial.println(ESPNOW_WIFI_CHANNEL);
  Serial.print("MAC Address: ");
  Serial.println(WiFi.macAddress());

  //ESP_NOW_Serialの起動
  // Start the ESP-NOW communication
  Serial.println("ESP-NOW communication starting...");
  NowSerial.begin(115200); //無線シリアル
  Serial.println("You can now send data to the peer device using the Serial Monitor.\n");

}//setup


//メインループ
void loop() {

  now_print("Hello,\n");
  now_print("world!\n");

  delay(1000);//1秒待つ
}//loop



```