The final reflections

The group work

Our group work progress has generally been working really well. At the early stage we experimented a lot, and tried connecting things outside of our exercises. However, one downfall we have had as a group has been, that we have not each individually changed between the tasks. This means that not everyone has tried to make a component inside nodeRED apart from the exercises. We had one time when the work practice was really good: Making the flow diagram, and deciding what the locker should do in different scenarios, made it very clear what tasks should be done. For the next project we will do the flow diagram earlier, define what tasks should be done, and make sure that everyone get to work on all parts of the project.

A new world of things connected to the internet

This project has opened up the world of IoT devices for us. Most interesting is how we could save memory on the nodeMCU, by making cloud computing do most of the tasks for us, by simply communicating with our NodeMCU via MQTT. The nodeRED layout was a very simple way to “program” specific tasks for us. Especially the dashboard functions was amazing to quickly prototype a functional UI, without much knowledge of html and css. Combining it with an MQTT server, made it super easy to send and receive messages (or commands) to the nodeMCU.

It is nice to experiment with making every-day things work on the internet. However as design engineers we must also remember to think about the Raison d’être of our inventions – otherwise they might be chindogu inventions.

The assembly of mechanics and electronics

The construction of the locker was through lots of trial and error. Corners are extremely fragile during assembly, and has costed the lives of a few boxes. We got a tip, that moisturizing the wood before assembly, would make the bendable corners less prone to break. The tip was given post-assembly of the final box, and is therefore something we can take with us to the next project, if bendable laser cut wood still is the thing we want to work with.

We wanted to lessen the resistance in the breadboard, so we could be sure everything would run smoothly, and so no cable would loosen itself during the setup post-assembly. We thought it would be a great idea to solder everything together on the day before delivery, with very little experience in soldering circuits. We got extra cable from the instrument group in building 414. Next time we will ask for something more specific than “cable”, so the instrument group won’t mock us and get a bad impression of Design and Innovation students. In the students workshop in 413 we got a few tips and tricks for creating powerbridges for parallel connections with jumper cables. We got hold of a perfboard which was very helpful on the soldering process.

We were quite excited when we learned that no components was burned in our soldering adventure. With great momentum, we were ready to assemble it. But before we would hide the electronics inside the safe, we had to make sure that it all worked. We had a strange experience with the nodeMCU, that suddenly did not want to connect to our wifi. We re-uploaded the code, and tried to reset it, but nothing worked. We then tried to upload the code on another NodeMCU, and it worked flawlessly. We desoldered the NodeMCU and replaced it with the one that worked. The new NodeMCU now did not want to connect to the wifi. So we tried changing the code, but nothing worked.

The point of no return

At one point we wanted to see if it worked, and plugged in the 12 volt adapter to the nodeMCU. A loud pop went into the room, and we sat back in silence looking at each other. The LEDs had stopped emitting light. It was dead. So we found a third NodeMCU and soldered it onto the board, after cutting loose the old one. And suddenly the wifi was working. So the moral of the story is, sometimes things just don’t work, and if we get stuck, we should try to disassemble everything and try to replace the cables and components.

Project 2: IoT Safe, final overview

  1. Introduction
  2. Electric circuit
  3. Dashboard and Node-RED
  4. Buzzer + OLED
  5. The locker

The goal of this projet has been to create a single IoT safe that can be unlocked via a web-browser. We have achieved this by using a node MCU, Node-RED hosted on IBM cloud, using CloudMQQT as our broker and various other hardware components.

The Node-MCU, acts as the hardware controller. It’s code defines its functions but it is at no point in control over the safe, the Node-RED is in charge of what the safe does. This makes it easy to adapt the hardware part of this project to a completely different IoT safe experience.

All Node-MCU functions are triggered via strings over the broker, from Node-RED: Ie. we can play specific buzzer sounds by sending either “success” or “failure”.

The project can be seen as a proof of concept, as it only accounts for one safe. It would require a database to have multiple safes running over one flow. Ideally one could have multiple safes running over one Node-MCU or one central server handling it. Another possibility is just accepting the higher safe costs and each safe running on its own cloud instance, own Node-MCU and so forth.

2. Electric circuit

The electric circuit and components can be analysed via the schematic seen below.

Power Supply:
Our Node-MCU is powered form 12 volt direct current outputted by an adapter. It transforms 220 voltage alternating current from a standard house power plug. This way the locker can be be powered from any outlet. Same adapter delivers power to the solenoid motor inside the electronic lock.

The powered Node-MCU delivers 3 volts direct current to the OLED and the buzzer is powered by the digital output pin D0.

3. Dashboard

The Dashboard, or UI (user interface), is an important facette of the product. It’s the digital front end and it must guide the user. The UI consists of 3 elements.

A presentation element welcomes the user and displays the locker’s status (Available / Occupied). This is connected to the OLED that will also display OLED.

An ‘Unlock’ element asks for passcode. In case the user has already registered with a passcode he/she must enter the code and the closet will automatically unlock. Entering a passcode without registering will display the messages: “Please sign up to use the locker” and if it is in use and the passcode is incorrect: “Wrong password, thief”.

Lastly: The register element. This is where you type your email and passcode. Registering will send the user an email with instructions on how to use the locker along with a link to the UI and the registered password (in case you forget).

The confirmation mail looks as such:

4. Buzzer & OLED

OLED screen

The OLED is located behind a acrylic plate, to give the locker a nicer finish and make the screen look better. The acrylic plate makes the screen more appenrent and it lights up more.

The buzzer is located behind the airholes made to let sounds pass through.

The hole in the buzzer is locate behinde one of the holes, this make the sound go though better. The rest of the holes if for the look of the locker.

5. The locker

We are signing in with e-mail and password, and the locker opens as it should, playing the right tone
An incorrect password played the FAIL-melody.
The correct password opened the locker playing the SUCCESS-melody.
The final Locker

The final locker will open when the user signs up, and it opens again when the user types in their password. The lock is mounted on the wall in Skylab and is fully functional.

Assembling the final locker – week 6

Our locker is made from laser cut plywood and designed using the website called festi.info, where we made a Rounded Box. This made it simpler to assemble the box and allowed the corners to be rounded. We modified the design in AutoCad, were we drev the holes for the OLED, the Buzzer and the power supply. We also drew the shelf in AutoCad with a hole for the chords. Then we printed the box in 6 mm plywood, and engraved the drawings, text and symbol, drawn in Illustrator.

The laser cut pieces

We engraved the QR-code on the front together with the link for the webside. We also engraved our group name, DTU-logo, and course info. On the inside of the locker we engraved “Remember to close me when you’re done” as this is an important step for the closet to function properly. We used a piano hinge, so we were sure the door would be aligned.

We decided to solder the NodeMCU and chords to a perfboard, and soldered the chords connected to the buzzer, the OLED and the other components. We chose to solder everything together, to make sure that everything would stay connected as we were moving it around.

On the inside of the door we mounted a mirror. The electronic part is hidden by a top shelf, so both the lock and OLED is placed at the top. The board and NodeMCU was glued to the shelf, and the OLED and buzzer was glued to the front of the locker.

At last we assembled the front, back, sides and shelf, and tested if our door and the lock fit together. We wanted the OLED screen to have a better appearance, so we laser cut an acrylic plate for the screen. Finally we drilled the holes for the bolt and nuts to mound it on the pegboard in Skylab.

See the finished design here: https://wordpress.com/block-editor/post/chindogu.home.blog/138

The final Node-RED logic sprint – week 6

By: Aksel N. Ladegaard and Sebastian Mc. Aleer

Aksel:

Today has been the last sprint in finishing the cloud based logic for the IoT Safe. I’d just like to offer a quick overview of the methodology of solving this task and why we chose the solutions we did.

The assignment requirement was 1 safe, which means there isn’t need for a database (which we haven’t been taught about yet) so we have done all dependent on flow variables.

The whole flow is initially triggered by 1 of 2 things:

  1. Registering a new user
  2. Unlocking the safe

The administrator of the safe has the option of doing a few more things:

  1. Manually injecting MQTT commands through the interface on cloudmqtt, which is the broker that we use
  2. Manually reset it through nodeRed, where we have made an admin reset button (inject)

The safe is constantly governed by a few flow variables which are set in nodeRed over mqtt, these variables are:

  1. Safe
  2. Lockerstate
  3. Password
  4. Email

Safe, can be one of three values: undefined, available & inUse. Depending on this we can check whether the safe is ready for registering a new user, unlocking and so forth.

Lockerstate is initiated from the nodeMcu which changes everytime the lock solenoid is triggered. This is only triggered for around 100ms, so it immediately sends a message over the broker and the flow variable is set in a function node.
This is essential as to detect when the safe is just closed and in use. This can be detected with 2 switches (ie. if else statements).
First one checking the Safe status, if it is in use and it is locked, then the locker has been closed after registering.

Emails: we use 2 flow variables to store the email recipient and the flow password as content.
Our emails are created out from a simple email template with some custom styling which has been written in HTML and CSS. We have then converted it into a single line string. In one example we have made it insert password as a string.
This could also have been done in a template node, but we have used the function node.

Much of the logic and inputs in the flow has been created with trigger nodes, which need to be reset before they can be triggered again. This results in most of the complexity in the system with a dedicated MQTT topic for resetting the system when it’s relevant. There are also smaller resets, for example at the unlocking logic for checking if the password is incorrect.

Some places in the flow, there are a few unintuitive delays, for example before a few password/email resets. This is due to ensure that all relevant emails or other flow variable dependent functions trigger before the reset.

Sebastian:

Todays work has consisted of examining, editing and commenting the NodeRed code. Organising the flow with aligning nodes and branches makes reading and understanding easier. Comments can be read to gain better understanding.

A big leap – week 5

Before the Easter holidays, we wanted to try and finish the project, in order to enjoy our vacation time. Therefore we worked hard during the time in class, and we met up to spend a whole day together working on the project.

During the class we worked with the NodeRed, the NodeMCU code and with incorporating the buzzer. We also made our first locker prototype out of cardboard.

When we meet up on the following sunday, we startede with making a to do list, and then dividing the tasks among us.

The user flow draft

We also drew up the user flow in order to get an overview of it. In short the user would come, sign up for the locker, put in their stuff, close it and walk away. When they go to pick their stuff up again and close the door, the locker should reset. But to make a successful locker, there are different cases that we need to account for.

The first scenario is that the user signs up, but then changes their mind, and doesn’t close the locker. We agreed that if the locker was left open, it should reset after 5 minutes, and that the OLED should write “Close me”.

The next scenario is that the use does not come and pick up their stuff. Should the locker reset after 24 hours? 48 hours? or 72 hours? We agreed that it should open and reset after 48 hours, and that we wanted to send an email notification to warn the user 2 hours before the locker would open automatically.

The user flow

The code

After making the user flow diagram, it got clearer what the NodeMCU should communicate to NodeRed and vise versa. We decided that, based on the function, there should be different topics, so the communication between NodeMCU and NodeRed would become more readable. It also made it easier for us, to implement a function that directly takes the payload from the NodeMCU to the OLED, without printing things unnecessarily for the user. Our whole setup has been made to ease the memory of the NodeMCU and do as much functioning possible inside NodeRED. In one line; the nodeMCU controls the hardware and NodeRed handles the UI and UX.

The code has also been cleaned up, so that only functions, we still use, remain. The text for the OLED was changed, so that it matches the lockers status. It will say “The safe is available” when not in use, “Welcome to the locker” when the user is putting their belongings in, “The safe is in use” when in use, and “Please close me” if it has been open for more than 5 minutes. The different buzzer sounds were also successfully implemented (see separate blog post).

NodeRed

We also continued reorganising the NodeRed. We set up the log-in forms, so the user could fill in their email and password when signing up, and insert their password for unlocking. We wanted the user to receive an email with their chosen password

We had a bit of trouble, with NodeRed remembering the users password and matching it to the e-mail when signing in. No matter what it would just say wrong password. We made the password a flow variable and made a switch (a NodeRed node, a glorified if elif, else statement), where it checks the sign in password against the sign up password.

The emails we created with NodeRed, was a bit simple and they looked very plain. Therefore we made the different emails we needed with HTML and CSS, to give it a nicer, more readable design. There is an email for the sign up, the 2 hours warning email, the reset email after 48 hours, an email for wrong password, an email for correct password, and one for the 5 minutes reset. This could be improved in the future by using NodeRed template nodes.

The locker

The first prototype of the locker was a simple box, with a hole for the OLED and space for at shelf to hide the Node MCU and the breadboard. Both the prototype and the final locker would be laser cut.

The cardbord version

During the class we cut the first version of the box, in cardbord, but later we decided to change the design a bit.

The cardboard version

We changed the corners to rounded corners, and we added a hole for the buzzer. Read more about the changes in the blog post about the locker assembly.

Buzzer completion = Success

A code has been completed which outputs little custom melodies to the Piezo buzzer (passive).

In the process of determining which melodies was relevant, we also discussed a lot of overall functions about the locker so that the product produces clear feedback to the user and acts accordingly. As result we came to 5 unique sounds for 5 unique scenarios:

“SUCCESS” = When the closet has been succesfully accessed via email pincode, an anthem plays.

“LOCKED” = When the locker has been locked, a short confirmation tone will be played.

“FAILED” = If accessing the locker fails (wrong password) or timer runs out when the door is open, a failed tone plays to alert the user.

“PING” = When the locker has been open for 30 seconds, a reminder will alert the user that the locker is still open.

“KIM POSSIBLE” = When the rental time has run out (after 48 hours) the Kim Possible signature plays, hopefully to deter any nearby thieves; as thieves fear Kim Possible. It’s common knowledge.

The code was initially set up from code originating from:
https://pastebin.com/jdhs9LXB

The melodies were created and customised within the sketch. Rearrangements and shortening made it ready for implementing it in the main code.

Figuring out the buzzer, password and email notifications // plan for week 5

For this week we have four main goals for finishing our smart locker:

  • Getting the buzzer to work
  • Unlocking via password
  • Sending an email notification with text and password
  • Assembling the box

The buzzer is the only hardware we need to implement. We know how to make the buzzer work using the bare minimum circuit, so we are working on making the buzzer sounds more appealing. This is done by using som libraries that allow for playing notes and then structuring them into melodies.

We also know how to control the lock using the button in MQTT, but we have yet to figure out how to control the lock via Node Red logic dependent on a password.

By using the node ‘form’ in NodeRed we have succeeded in sending an email to the email address we provided in MQTT. What we need to work on, is getting the text in the email correct – for example adding the chosen password to the email.

We have already made the blue print for the box, so the goal is to laser cut it and glue it together before we go home. The box will be vertical with the OLED screen at the top. The electronics will hidden by an upper plate.


NodeRed and MQTT Connect – week 4

NodeRed is an online coding platform accessed via Cloud IBM (BlueMix). The coding form is to connect the wanted node functions and specify their behavior via programming and various inputs ( such as perhaps Topic, Passcode and Port for MQTT input/output ). Initially NodeRed has been programmed with two functioning “button messages”, so that when they’re clicked on the UI message strings are sent to the MQTT.

Our nodeMCU is subscribed to the Topic and will receive the strings. Now our web client will show the text current on the OLED, now you can know from our web client is the lock is lock or not.

We also set up the web client with to form so it remembers the Email for the confirmation and remember the password. The next step is to set up NodeRed so it remember the password and check the password, when you need to unlock the lock.

Flow model of the communication between the MQTT broker, the NodeRed and the NodeMCU


Play with the lock – week 3

The set up the lock, we had to set up the different cloud services.

First of all we need an account for IBM cloud, Sebatian and Aksel made two different account. The IBM cloud gives acces to NodeRed. We also made at an MQTT server.

From the NodeRed, we can via the MQTT send different messages to the NodeMCU, and we can also send message from the NodeMCU to the NodeRed – also via the MQTT.

To begin with, we controlled the lock in a simple way. In the NodeRed we set up a flow, connected to the NodeMCU, and programmed the lock to open if it received the text “unlock”. The unlock message is send from a text field. Other messages typed in the text field could also be send and showed on the OLED.

Afterwards we created an unlock button in the NodeRed instead, which sends the unlock message to the MQTT, so that the lock would unlock and the OLED would show “unlock”. All messages was send from NodeRed via the MQTT server to the NodeMCU.

Unlocking Project II – week 2

Project II: Connectivity and IoT has kicked off. We are beginning to plan and structure our approach to the project as well as brainstorming ideas for the design. So far we have created a function tree and a few sketches of design variations of the smart locker:

Function tree
Overview of components and functions of the smart locker
Design idea
Door variation

[more pictures of locker ideas]

The physical front door of the cabinet will have an OLED screen and a piezo buzzer. We will look into the details of the user interface (buttons, LEDs etc.) after developing the basic functionality and designing the cloud logic.

The physical front door of the cabinet will have an OLED screen and a piezo buzzer. We will look into the details of the user interface (buttons, LEDs etc.) after developing the basic functionality and designing the cloud logic.

Today we are working on designing the cabinet itself. We have decided to build the box using laser cutters, and are using the service makercase.com. We have the following measurements of the box:

height: 30 cm, width: 21 cm & depth: 21 cm


The lock and hardware are mounted on a plate inside the cabinet which also serves to hide the hardware.

We have also signed up for IBM Cloud, and are working on setting up the first course program with NodeRed.