Giter VIP home page Giter VIP logo

lovebox's Introduction

❤️ Lovebox ❤️

DIY project to lasercut a lovebox inspired from https://en.lovebox.love/. It was a homemade Christmas present for my mom. So I can send her messages or pictures at any time to start the day motivated. When a new message is received, the heart moves in front of the box. It stops as soon as the message has been read (more specifically the built-in brightness sensor reacts when the box is opened). Have fun building your own!

Materials

  1. 3mm or 4mm wood(to cut the case + heart)
  2. WeMos D1 Mini
  3. Servo motor
  4. Light sensor
  5. 10kΩ resistor
  6. OLED display
  7. Perfboard
  8. Breakaway PCB Connector
  9. 1mm acryl (to cut the display)
  10. Darkening foil/dazzle strip

Composition

Below you can see where the OLED display, the light sensor with resistor and the servo motor are connected to the WeMos D1 Mini. The second photo is the soldered assembly. As you can see the micro-USB connector of the microcotroller board is at the ground. On top of the microcontroller a perfboard is soldered. Now the servo motor is added and also soldered to the perfboard. Notice the resistor and the light sensor that are also soldered to the board, with the light sensor pointing up. The display is soldered to another perfboard. The board provides a flat surface to hold the display in place. It is put on the motor and is connected to the other perfboard by using a Breakaway PCB Connector. It serves as a spacer to hold the other board above the motor.

After finishing the electronics, you have to cut the case, cap and hearts out of the wood and the display out of the 1mm acryl with a lasercutter. For that four SVGs are provided containing the cutting plan. Then you have to glue the little heart on the larger heart and paint it red. After that, you have to cut with scissors the size of the display out of the darkening foil and put it on the acryl display. Finally, stuck the white servo horn into the back of the heart. The last step is to assemble the case and the cap. Now you can put the hardware inside the case and program the microcontroller.

How it works

For programming I used the Arduino IDE. The cool thing about the Wemos D1 Mini is the built in ESP8266, so you can connect to the internet. Messages like pictures and texts can be sent to the Lovebox via the internet. In order to control the ESP8266, the following address must be added in the Arduino IDE under "File->Preferences->Additional Board Manager URLs": http://arduino.esp8266.com/stable/package_esp8266com_index.json. Then you can type "esp8266" in the search field under "Tools->Board->Boards Manager" and click on "Install". Now the WeMos D1 Mini appears under the boards and can be selected.

Then you can open the "Lovebox.ino" and upload it to the board, just connect it to your computer with a micro usb cable. You should first enter your WLAN, password and the path to your gist file (without the part "https://gist.github.com" and add "/raw/yourFilename" behind) in the "credentials.h". The gist file is a text document, which you create online as "private" and then almost always leave your message there, which the microcontroller can then retrieve.

The microcontroller will then always call your text document on gist.github and see if the first number in the first line is a different one. This serves as an identifier to determine if a new message is retrievable. If this is different from the previous one, then the algorithm looks into the second line, if it contains a "t", then the microcontroller expects a text and shows the message on the display. If there is another character, e.g. a "b", then an image is expected. For the picture I use the website: https://www.dcode.fr/binary-image. There you can upload your black and white image and set the target width to 128 pixels. The image will then be converted to "0" and "1" only, so each black pixel becomes a 0 and each white pixel a 1. You can then simply enter this string in the third line of your text document on gist.github. So your text document could look like this:

Acknowledgements

Thanks to @blblblu for the idea of hosting the message content for free on GitHub Gist and Deus for helping me with my first lasercut attempts.

Marcel (co-founder of ThingPulse, which provides the open-source display driver used in the project) was one of the first, who wrote about my project and added more photos of the soldering. He made suggestions for improvement there, which I integrated.

Thanks to @Nounnours who found out the reason for the display error with binary images and was able to solve it. I have also included this solution.

I am very excited that so many of you have already been able to build your own Lovebox with my instruction and that you are sending me messages, photos and videos of it. I want to especially share two versions. Bartha Zoltán has integrated the Lovebox into a hexagonal shape and Fabian Weller has designed the Lovebox for Nelly with small shiny silver and red hearts.

Feel also free to check out Julian's fork using the Arduino Nano 33 IoT.

tags: Lovebox Instruction

lovebox's People

Contributors

julisa99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lovebox's Issues

SSD1306Wire.h Not included

Hello!
I absolutely love this project but due to this file not being included I am confused as to how to include it. I tried to find the file online but it does not match up. I am not the most advanced with coding so if you could include or explain how to get the file it would be much appreciated. Thank you so much!

#include "credentials.h"

I keep getting this error message:
credentials.h: No such file or directory

Is there another library I need in order to use this?

.

.

Help HTTPS request doesn't work

Hi,
I have been at this for 2 months (crying face).
This is my first time using Arduino so could be a very easy fix.
When this code is run it prints "Connection to GitHub lost" which from what I know just means it's not even connecting to the git file.

Here is the txt file : https://gist.githubusercontent.com/thomasmore72/b3ca747d9852fbe407a11e629d854f96/raw/28a9bccb6b4e0f4d163644063b5a092e29700ed0/gistfile1.txt

Like I said brand new to this so if you have a potential solution I might need a bit of code to understand :D

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <EEPROM.h>
#include <Servo.h>
#include "SSD1306Wire.h"

const String url = "/thomasmore72/b3ca747d9852fbe407a11e629d854f96/raw/28a9bccb6b4e0f4d163644063b5a092e29700ed0/gistfile1.txt";

SSD1306Wire oled(0x3C, D2, D1);
Servo myservo; 
int pos = 90;
int increment = -1;
int lightValue;
String line;
String messageMode;
char idSaved; 
bool wasRead;  

void drawMessage(const String& message) {
  oled.clear();

  // differentiat between 't'ext and image message
  if(messageMode[0] == 't'){
    oled.drawStringMaxWidth(0, 0, 128, message);    
  } 
  else {
    for(int i = 0; i <= message.length(); i++){
      int x = i % 129;
      int y = i / 129;
    
      if(message[i] == '1'){
        oled.setPixel(x, y);
      }
    } 
  }    
  oled.display();
}

void wifiConnect() {
  Serial.begin(9600);
  Serial.println();

  WiFi.begin("Wifi Name", "Wifi Pass");

  Serial.print("Connecting");

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  
  if (WiFi.status() == WL_CONNECTED) {
    Serial.print("Connected, IP address: ");
    Serial.println(WiFi.localIP());
  }
}

void getGistMessage() {
  const int httpsPort = 443;
  const char* host = "gist.githubusercontent.com";
  const char fingerprint[] = "A1 46 14 C7 2A 1D 52 79 F6 AA 2B B2 C5 0A 3B D3 F5 02 06 75";
  
  WiFiClientSecure client;
  client.setFingerprint(fingerprint);
  
  if (!client.connect(host, httpsPort)) {
    Serial.println("Failed to connect to GitHub");
    return; // failed to connect
  }
  
  client.print(String("GET ") + "/thomasmore72/b3ca747d9852fbe407a11e629d854f96/raw/28a9bccb6b4e0f4d163644063b5a092e29700ed0/gistfile1.txt" + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "User-Agent: ESP8266\r\n" +
               "Connection: close\r\n\r\n");

  // Wait for a response
  if (!client.connected()) {
    Serial.println("Connection to GitHub lost");
    client.stop();
    return;
  }

  // Read the response status code
  String response = client.readStringUntil('\n');
  if (!response.startsWith("HTTP/1.1 200 OK")) {
    Serial.println("GitHub request failed with status: " + response);
    client.stop();
    return;
  }

  while (client.connected()) {
    String temp = client.readStringUntil('\n');
    if (temp == "\r") {
      break;
    }
  }

  //String id = client.readStringUntil('\n'); 
  if(response[0] != idSaved){ // new message
    messageMode = client.readStringUntil('\n');
    if (messageMode[0] == 't'){
      line = client.readStringUntil(0);
    } else {
      // binary image is corrupted if readStringUntil() takes too long
      // fix: read string line by line
      line = "";
      for (int i = 0; i < 64; i++)     
      {
        line += client.readStringUntil('\n');
        line += "\n";
      }
      if (line.length() != 8256)
      {
        getGistMessage();
      }
    }
    wasRead = 0;
    idSaved = response[0];
    EEPROM.write(142, idSaved);
    EEPROM.write(144, wasRead);
    EEPROM.commit(); 
    drawMessage(line);
  }
}

void setup() {
  myservo.attach(16);       // Servo on D0
  
  oled.init();
  oled.flipScreenVertically();
  oled.setColor(WHITE);
  oled.setTextAlignment(TEXT_ALIGN_LEFT);
  oled.setFont(ArialMT_Plain_10);
     
  oled.clear();
  oled.drawString(30, 30, "<3 LOVEBOX <3");
  oled.display();
  
  wifiConnect();

  EEPROM.begin(512);
  idSaved = EEPROM.get(142, idSaved);
  wasRead = EEPROM.get(144, wasRead);
}

void loop() {
  if (WiFi.status() != WL_CONNECTED) {
    wifiConnect();
  }
  
  getGistMessage();   
  Serial.print("/");
  delay(5000); // wait a minute before request gist again
}

Display Error with binary images

First of all thank you very much for this cute tiny cool box! I almost finished my first box. Unfortunately I have trouble with the display when using images. Every time the image is loaded another image with errors in the lower half / third of the display is shown. It seems that there is something shifted wrong. I attached some example images of that. Do you have any idea what's the cause? I already reduced the I2C clock down to 100kHz, used another display from another provider, added pull up resistors to the I2C pins. Nothing helped so far.

image

image

image

Hello with gist

Hello,

first thanks for this amazing project.

Like you know chrismas coming :) and i want build this project for my girlfriend.

for the moment your program compil well and i have the message <3 LoveBox <3 appear on my screnn YESSS !!!!

But my probleme is about message on GIT.

I go to GIT i login , i click on "your gist" then i create new file name "test" inside i put that :

1
t
hello

Like i understand (let me know if i'm wrong)

  1. 1 --> your program see if différent number if yes he go to the net line to see if is "t" or someting else
  2. t --> your program detect the message is a texte message but if we have another letter your programe detect img
    3 ) hello --> message to show

so i've Two question if i'm correct on 1,2 and 3 why my message not appear ? My wireless works perfectly and i make my pat to my gist like this :
myusernameGIT/420b6eb87445c1eb50fb365b28fb7503.js/raw/test
maybe i mistake something ?

the second question can you explain me what you do exactly to show img.

for me i understant that :

  1. 1 --> your program see if différent number if yes he go to the net line to see if is "t" or someting else
  2. w --> your program detect the message is a texte message if we make "t" letter but if we have another letter your programe detect img
    3 ) here i need make img ? or only the binary code 0001111 img convert on the website you give ?

Thanks for your amazing works and your help.

Wemos D1 mini Pro isn't able to retrieve message from Gist file

Hi! I was trying to replicate this project on my D1 mini Pro and realised that it wasn´t being able to fetch the message from my gist file in any way.
I even tested all the componnents to look for any flaw on their connctions, but there is any and the Servo, Display and light sensor are working correctly. I am really lost, because it is indeed connecting to the WiFi (If I use my cellphone's conection as a router, it appears as a connected device) and my Gist url is written as /GitHub-username/Hash-Value/raw, but it still doesn't work.
Can somebody help me PLEASE?
Thanks :)

Microcontroller seems to never check gist after first time

I have everything built and the code is uploaded. However after getting the first message it seems the code just stops checking for the new message. The while loop appears to just stop after the first time (I know this because my code is no longer looking for the lightValue).

Light sensor link is broken

Hi Lisa.

Unfortunately the link to the light sensor is broken.
Can you tell me what kind of sensor i need to buy or provide a different link?

Thanks :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.