Long Distance IoT Hug Plushie

by caghjayan in Circuits > Arduino

426 Views, 8 Favorites, 0 Comments

Long Distance IoT Hug Plushie

hugging plush 1.jpeg

Everyone has someone they miss. Maybe it's distance, maybe it's conflicting schedules, but seeing loved ones in adulthood is hard. If you miss someone and want to get love and spread some love, here’s how!

Supplies

il_1588xN.3582263599_yo8z.jpeg
il_1588xN.3848395354_58yl.jpeg
328-07.jpg
3965-07.jpg
adafruit_products_5691-03.jpg
adafruit_products_5691-04.jpg

Circuit Diagram

HugCircuit.png

The Adafruit MPRLS Ported Pressure Sensor Breakout and Li-ion battery are attached to the Adafruit ESP32-S3 Reverse TFT Feather.

Attach Air Bladder to Tubing to Sensor

separated tube 1.jpeg
separated tube 2.jpeg
silicone adhesive.jpeg
tube only attach to sensor.jpeg
playing with air bladder.jpeg

Make sure to use a silicone adhesive when attaching the tube to your sensor, because the only thing that makes silicone stick is silicone. 

I personally had a lot of trouble with this one. The first one attached like bread to butter, perfection! The second tube on the other hand….. Messy.


Connect to Arduino IoT Cloud

In order to connect my board, I created a boolean variable for my Thing through the Arduino IoT Cloud. By inputting my network and device information within the code, I was able to connect.

Patterns & Sewing

not quite done.jpeg
side profile.jpeg

For the patterns, I was originally going to make a stingray and an octopus, but due to time constraints, I am going with my mom’s favorite shape, a triangle!


Genuinely making the pattern to sew for this was pretty intuitive. I just cut out two large triangle pieces then cut out the strips that go in between the two triangles to create volume.

Hug Code

// Long Distance Hug by Ana Jay, code from Parihug IoT Hug project by Xyla Foxlin, adapted 2023 & 2024 by Becky Stern
// Watch the video: https://youtu.be/u6gj8VzrHBo
// Tutorial: https://beckystern.com/2023/11/27/hug-sensing-iot-parihug-toy-w-xyla-foxlin/
// This code is in the Public Domain


#define SECRET_SSID "Internet of Things Class"
#define SECRET_OPTIONAL_PASS "iheartarduino"
#define SECRET_DEVICE_KEY "gg0N8MV!wlYjIqlA8m#Db@yW@"


#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>


// Use dedicated hardware SPI pins
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);


const char DEVICE_LOGIN_NAME[] = "15f3eccb-0c6f-46a8-8ef1-183a610a3a3c";


const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password


void onHugChange();


bool hug;


void initProperties(){


ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
ArduinoCloud.addProperty(hug, READWRITE, ON_CHANGE, onHugChange);


}


WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);


#include <Wire.h>
#include "Adafruit_MPRLS.h"


// You dont *need* a reset and EOC pin for most uses, so we set to -1 and don't connect
#define RESET_PIN -1 // set to any GPIO pin # to hard-reset on begin()
#define EOC_PIN -1 // set to any GPIO pin to read end-of-conversion by pin
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);


void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
//pinMode(12, OUTPUT);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);


// Defined in thingProperties.h
initProperties();


// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);


/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
Serial.println("Testing MPRLS sensor...");
if (! mpr.begin()) {
Serial.println("Failed to communicate with MPRLS sensor, check wiring?");
while (1) {
delay(10);
}
}
Serial.println("Found MPRLS sensor");


// turn on backlite
pinMode(TFT_BACKLITE, OUTPUT);
digitalWrite(TFT_BACKLITE, HIGH);


// turn on the TFT / I2C power supply
pinMode(TFT_I2C_POWER, OUTPUT);
digitalWrite(TFT_I2C_POWER, HIGH);
delay(10);


// initialize TFT
tft.init(135, 240); // Init ST7789 240x135
tft.setRotation(3);
tft.fillScreen(ST77XX_BLACK);
// large block of text
tft.fillScreen(ST77XX_BLACK);
testdrawtext(
"Booting hugs... ",
ST77XX_WHITE);
delay(1000);
tft.fillScreen(ST77XX_BLACK);


Serial.println(F("Initialized"));
}


void loop() {
ArduinoCloud.update();
float pressure_hPa = mpr.readPressure();
Serial.print("Pressure (hPa): "); Serial.println(pressure_hPa);
Serial.print("Pressure (PSI): "); Serial.println(pressure_hPa / 68.947572932);
if (pressure_hPa > 1100){
hug=true;
Serial.println("Hug = true");
// Serial.println("buzz buzz loop");
// digitalWrite(12, HIGH);
// delay(1000);
// digitalWrite(12, LOW);
// large block of text
tft.fillScreen(ST77XX_BLACK);
testdrawtext(
"Hugs! I love you. ",
ST77XX_WHITE);
delay(5000);
tft.fillScreen(ST77XX_BLACK);
}else{
hug=false;
Serial.println("Hug = false");
}
delay(1000);




}


/*
Since Hug is READ_WRITE variable, onHugChange() is
executed every time a new value is received from IoT Cloud.
*/
void onHugChange() {
if(hug==true){
Serial.println("onHugChange has been called");
// digitalWrite(12, HIGH);
// delay(1000);
// digitalWrite(12, LOW);
tft.fillScreen(ST77XX_BLACK);
testdrawtext(
"Hugs! I love you. ",
ST77XX_WHITE);
delay(5000);
tft.fillScreen(ST77XX_BLACK);
}
}


void testdrawtext(char *text, uint16_t color) {
tft.setCursor(0, 0);
tft.setTextColor(color);
tft.setTextWrap(true);
tft.print(text);
}

[Optional] Film a Video!

HiFi Draft Promo