IoT Small Remote - 3D Printed Universal ESP-NOW Remote Control Based on ESP-01 (ESP8266)

by Jan Wojcik in Circuits > Wireless

2756 Views, 26 Favorites, 0 Comments

IoT Small Remote - 3D Printed Universal ESP-NOW Remote Control Based on ESP-01 (ESP8266)

IMG_20221023_131416.jpg
IMG_20221023_131554.jpg
IMG_20221023_140312.jpg

[Updated version, please pay attention to the connections!]

Small (~ 4.6cm x 1.9cm x 1.6cm) and easy to make remote. It can control other ESP devices via ESP-NOW protocol.

Features:

  • decent range (due to the ESP-NOW)
  • multiple actions (2 buttons, long hold detection)
  • very long battery life - no power consumption when buttons aren't pressed
  • battery voltage reading
  • quick response time (about 0.2s; WiFi IoT buttons are much slower)
  • possibility of integration with smart home systems (in my case Home Assistant + MQTT via another ESP on my smart diy lamp connected to WiFi)

Supplies

IMG_20221023_150107.jpg

Electronic parts needed:

  • ESP-01(S) and another ESP as a receiver (you can use your existing IoT device, for example connected to the MQTT broker)
  • 150mAh LiPo battery (~ 24mm x 16.6mm x 7mm) or smaller
  • any diode with a voltage drop of 0.7 V
  • 1kΩ resistor (or similar; at least 330Ω)
  • 2x micro switch (~ 13mm x 6mm x 7mm, like DM1-00P)

Print the Housing

3d printed enclosure.png

It's designed for a 0.4mm nozzle and 0.2mm layer height. PLA and 100% infill recommended. Don't use supports.

Mount Switches and Buttons Inside

IMG_20221020_190341.jpg
3dpencsection.png

Insert 3D printed buttons in the housing and secure the micro switches with super glue (as shown in the pictures).

Program Your ESPs

espmac.png

Let's program our ESP devices. Use Arduino IDE environment.


To find out the receiver MAC address, use the code below:

#include <ESP8266WiFi.h>

void setup(){
Serial.begin(115200);
Serial.println();
Serial.print("ESP8266 Board MAC Address: ");
Serial.println(WiFi.macAddress());
}

void loop(){
}


Here are my demo codes you can upload:


ESP-01 remote (you need USB-UART converter or other board with USB such as NodeMCU to upload a sketch)

#include <ESP8266WiFi.h>
#include <espnow.h>
ADC_MODE(ADC_VCC);

// Replace with receiver MAC address
uint8_t receiverMAC[] = {0x2D, 0xA4, 0x31, 0x2C, 0x6B, 0x47};

typedef struct dataStructure {
  int n;
  float voltage;
} dataStructure;
dataStructure myData;
 
void setup() {
  float vcc = ESP.getVcc() / 1000.0 + 0.7;
  myData.voltage=vcc;
  
  WiFi.mode(WIFI_STA);
  pinMode(3,INPUT_PULLUP);
  
  esp_now_init();
  esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);
  esp_now_add_peer(receiverMAC, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);
  
  if(digitalRead(3)==HIGH){ //press left button
    myData.n=1;
    esp_now_send(receiverMAC, (uint8_t *) &myData, sizeof(myData));
  }
  else{ //hold right button and press the left one
    myData.n=0;
    esp_now_send(receiverMAC, (uint8_t *) &myData, sizeof(myData));
  }
}

void loop() {
  //hold actions
  /*
  delay(500);
  myData.n+=10;
  esp_now_send(receiverMAC, (uint8_t *) &myData, sizeof(myData));
  */
}


ESP receiver

#include <ESP8266WiFi.h>
#include <espnow.h>

typedef struct dataStructure {
    int n;
    float voltage;
} dataStructure;
dataStructure myData;

void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
  memcpy(&myData, incomingData, sizeof(myData));
  Serial.print("Received message: ");
  Serial.print(myData.n);
  Serial.print("  Battery voltage: ");
  Serial.print(myData.voltage);
  Serial.println("V");
}
 
void setup() {
  Serial.begin(115200);
  Serial.println();
  WiFi.mode(WIFI_STA);
  
  esp_now_init();
  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
  esp_now_register_recv_cb(OnDataRecv);
}

void loop() {
}

Solder and Assemble Everything

diagram.png
IMG_20221023_122601.jpg
IMG_20221023_122626.jpg
IMG_20221024_205640.jpg

Solder everything as shown in the diagram and pictures. I left the positive leg of the diode sticking out, because it will make it easier to charge the battery.

The End

Zrzut ekranu 2022-10-23 215218.png
IMG_20221024_210304.jpg
IMG_20221024_210255.jpg

Charging

The arrows in the diagram from the previous step are points where you should connect LiPo charger (e.g. TP4056) with jumper wires. But don't worry, you won't have to do it too often :)



If you find any bugs, have ideas for improvement or have questions, leave a comment below. Thanks :)

PS sorry for my english, I'm still learning