Back to tech

Arduinoにおけるuint8_t *型からchar *型またはinteger型への変換

1 min read
Table of Contents

ESP8266を使用しているときに受け取ったuint8_t型の文字列をchar型やinteger型への変換したいときに困りましたが、解決したのでメモとして記述しておきます。

uint8_t * payload = "hello";

//char *型への変換
char * chr_payload = (const char *)payload;

//integer型への変換
int int_payload = atoi((const char *)payload);

参考文献